diff --git a/tests/conftest.py b/tests/conftest.py index 1480a272..374b8d83 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -104,8 +104,8 @@ def path_to_test_specs() -> str: """ Fixture to provide the path to the directory containing test specifications. - This fixture returns the absolute path to the 'test_specs' directory - within the 'integration' folder of the test directory. It expands + This fixture returns the absolute path to the 'test_specs' directory + within the 'integration' folder of the test directory. It expands environment variables and user home directory as necessary. Returns: diff --git a/tests/integration/commands/test_stop_workers.py b/tests/integration/commands/test_stop_workers.py index c0100f50..9f385fa6 100644 --- a/tests/integration/commands/test_stop_workers.py +++ b/tests/integration/commands/test_stop_workers.py @@ -6,14 +6,14 @@ import re import shutil import subprocess -import yaml from enum import Enum from typing import List +import yaml from celery import Celery -from tests.integration.conditions import HasRegex from tests.context_managers.celery_workers_manager import CeleryWorkersManager +from tests.integration.conditions import HasRegex class WorkerMessages(Enum): @@ -22,6 +22,7 @@ class WorkerMessages(Enum): that we're expecting (or not expecting) to see from the tests in this module. """ + NO_WORKERS_MSG = "No workers found to stop" STEP_1_WORKER = "step_1_merlin_test_worker" STEP_2_WORKER = "step_2_merlin_test_worker" @@ -59,14 +60,14 @@ def load_workers_from_spec(self, spec_filepath: str) -> dict: # Initialize an empty dictionary to hold worker_info worker_info = {} - + # Access workers and steps from spec_contents workers = spec_contents["merlin"]["resources"]["workers"] - study_steps = {step['name']: step['run']['task_queue'] for step in spec_contents['study']} + study_steps = {step["name"]: step["run"]["task_queue"] for step in spec_contents["study"]} # Grab the concurrency and queues from each worker and add it to the worker_info dict for worker_name, worker_settings in workers.items(): - match = re.search(r'--concurrency\s+(\d+)', worker_settings["args"]) + match = re.search(r"--concurrency\s+(\d+)", worker_settings["args"]) concurrency = int(match.group(1)) if match else 1 queues = [study_steps[step] for step in worker_settings["steps"]] worker_info[worker_name] = {"concurrency": concurrency, "queues": queues} @@ -237,7 +238,7 @@ def test_no_workers( for condition in conditions: condition.ingest_info(info) assert condition.passes - + def test_no_flags( self, redis_server: str, @@ -336,7 +337,7 @@ def test_spec_flag( path_to_test_specs, merlin_server_dir, conditions, - flag=f"--spec {os.path.join(path_to_test_specs, 'multiple_workers.yaml')}" + flag=f"--spec {os.path.join(path_to_test_specs, 'multiple_workers.yaml')}", ) def test_workers_flag( @@ -387,7 +388,7 @@ def test_workers_flag( path_to_test_specs, merlin_server_dir, conditions, - flag=f"--workers {WorkerMessages.STEP_1_WORKER.value} {WorkerMessages.STEP_2_WORKER.value}" + flag=f"--workers {WorkerMessages.STEP_1_WORKER.value} {WorkerMessages.STEP_2_WORKER.value}", ) def test_queues_flag( @@ -438,5 +439,5 @@ def test_queues_flag( path_to_test_specs, merlin_server_dir, conditions, - flag=f"--queues hello_queue" + flag=f"--queues hello_queue", )