Skip to content

Commit

Permalink
test: replace tests naming starting with tests_ to test_
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasgomide authored and joaodaher committed Jul 13, 2023
1 parent 7c9f323 commit 1c38cff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
4 changes: 2 additions & 2 deletions django_cloud_tasks/tests/tests_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ def setUp(self):


class RoutineTaskTestMixin(EagerTasksMixin):
def tests_revert_should_revert_routine(self):
def test_revert_should_revert_routine(self):
# When not implemented this method raises an Error
self.task.revert(data=self.task_revert_data_params)

def tests_run_expects_return_dict(self):
def test_run_expects_return_dict(self):
output = self.task.sync(**self.task_run_params)
self.assertIsInstance(output, dict)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ def setUp(self):
self.mock_lock.start()
self.addCleanup(self.mock_lock.stop)

def assert_routine_lock(self, routine_id: int):
def assert_routine_lock(self, routine_id: int, task_name: str = "RoutineExecutorTask"):
self.mock_lock.assert_called_with(
key=f"lock-RoutineExecutorTask-{routine_id}",
key=f"lock-{task_name}-{routine_id}",
timeout=60,
blocking_timeout=5,
)

def tests_dont_process_completed_routine(self):
def test_dont_process_completed_routine(self):
routine = factories.RoutineWithoutSignalFactory(
status="completed",
task_name="SayHelloTask",
Expand All @@ -37,15 +37,14 @@ def tests_dont_process_completed_routine(self):
self.assert_routine_lock(routine_id=routine.pk)
self.assertEqual(context.output, [f"INFO:root:Routine #{routine.pk} is already completed"])

def tests_start_pipeline_revert_flow_if_exceeded_retries(self):
def test_start_pipeline_revert_flow_if_exceeded_retries(self):
routine = factories.RoutineWithoutSignalFactory(
status="running",
task_name="SayHelloTask",
max_retries=3,
attempt_count=1,
)
with (
patch("django_cloud_tasks.models.Pipeline.revert") as revert,
self.assertLogs(level="INFO") as context,
patch("sample_app.tasks.SayHelloTask.sync", side_effect=Exception("any error")),
):
Expand All @@ -63,10 +62,9 @@ def tests_start_pipeline_revert_flow_if_exceeded_retries(self):
],
)

self.assert_routine_lock(routine_id=routine.pk)
revert.assert_called_once()
self.assert_routine_lock(routine_id=routine.pk, task_name="RoutineReverterTask")

def tests_store_task_output_into_routine(self):
def test_store_task_output_into_routine(self):
routine = factories.RoutineWithoutSignalFactory(
status="running",
task_name="SayHelloTask",
Expand All @@ -87,7 +85,7 @@ def tests_store_task_output_into_routine(self):
self.assertEqual("completed", routine.status)
self.assertEqual(2, routine.attempt_count)

def tests_retry_and_complete_task_processing_once_failure(self):
def test_retry_and_complete_task_processing_once_failure(self):
routine = factories.RoutineWithoutSignalFactory(
status="scheduled",
task_name="SayHelloTask",
Expand Down

0 comments on commit 1c38cff

Please sign in to comment.