From b2d450d0ba4162a044f508deb50f0c6887054a25 Mon Sep 17 00:00:00 2001 From: Cristhian Garcia Date: Mon, 12 Feb 2024 10:02:48 -0500 Subject: [PATCH] chore: quality fixes --- .../commands/test_dump_data_to_clickhouse.py | 48 ++++++++++++------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/tests/commands/test_dump_data_to_clickhouse.py b/tests/commands/test_dump_data_to_clickhouse.py index 2b6913f..5de898c 100644 --- a/tests/commands/test_dump_data_to_clickhouse.py +++ b/tests/commands/test_dump_data_to_clickhouse.py @@ -4,11 +4,11 @@ from collections import namedtuple from datetime import datetime -from unittest.mock import Mock import django.core.management.base import pytest from django.core.management import call_command +from django_mock_queries.query import MockModel, MockSet from event_sink_clickhouse.sinks.base_sink import ModelBaseSink @@ -16,10 +16,6 @@ "TestCommandOptions", ["options", "expected_num_submitted", "expected_logs"] ) -from django_mock_queries.query import MockSet, MockModel - - - def dummy_model_factory(): """ @@ -81,11 +77,11 @@ class DummySink(ModelBaseSink): def get_queryset(self, start_pk=None): qs = MockSet( - MockModel(mock_name='john', email='john@edx.com', pk=1), - MockModel(mock_name='jeff', email='jeff@edx.com', pk=2), - MockModel(mock_name='bill', email='bill@edx.com', pk=3), - MockModel(mock_name='joe', email='joe@edx.com', pk=4), - MockModel(mock_name='jim', email='jim@edx.com', pk=5), + MockModel(mock_name="john", email="john@edx.com", pk=1), + MockModel(mock_name="jeff", email="jeff@edx.com", pk=2), + MockModel(mock_name="bill", email="bill@edx.com", pk=3), + MockModel(mock_name="joe", email="joe@edx.com", pk=4), + MockModel(mock_name="jim", email="jim@edx.com", pk=5), ) if start_pk: qs = qs.filter(pk__gt=start_pk) @@ -109,7 +105,9 @@ def dump_command_basic_options(): CommandOptions( options={"object": "dummy", "batch_size": 1, "sleep_time": 0}, expected_num_submitted=5, - expected_logs=["Dumped 5 objects to ClickHouse",], + expected_logs=[ + "Dumped 5 objects to ClickHouse", + ], ), CommandOptions( options={"object": "dummy", "limit": 1, "batch_size": 1, "sleep_time": 0}, @@ -119,17 +117,35 @@ def dump_command_basic_options(): CommandOptions( options={"object": "dummy", "batch_size": 2, "sleep_time": 0}, expected_num_submitted=2, - expected_logs=["Now dumping 2 Dummy to ClickHouse",], + expected_logs=[ + "Now dumping 2 Dummy to ClickHouse", + ], ), CommandOptions( - options={"object": "dummy", "batch_size": 1, "sleep_time": 0, "ids": ["1", "2", "3"]}, + options={ + "object": "dummy", + "batch_size": 1, + "sleep_time": 0, + "ids": ["1", "2", "3"], + }, expected_num_submitted=3, - expected_logs=["Now dumping 1 Dummy to ClickHouse", "Dumped 3 objects to ClickHouse"], + expected_logs=[ + "Now dumping 1 Dummy to ClickHouse", + "Dumped 3 objects to ClickHouse", + ], ), CommandOptions( - options={"object": "dummy", "batch_size": 1, "sleep_time": 0, "start_pk": 1}, + options={ + "object": "dummy", + "batch_size": 1, + "sleep_time": 0, + "start_pk": 1, + }, expected_num_submitted=4, - expected_logs=["Now dumping 1 Dummy to ClickHouse", "Dumped 4 objects to ClickHouse"], + expected_logs=[ + "Now dumping 1 Dummy to ClickHouse", + "Dumped 4 objects to ClickHouse", + ], ), ]