diff --git a/tests/test_router.py b/tests/test_router.py index d2091ef..fea8927 100755 --- a/tests/test_router.py +++ b/tests/test_router.py @@ -164,22 +164,28 @@ def test_route_series_fail4(fs: FakeFilesystem, mercure_config, mocked): def task_will_dispatch_to(task, config, fake_process) -> None: - t = config.targets[task.dispatch.target_name] - expect_command = f"dcmsend {t.ip} {t.port} +sd /var/outgoing/{task.id} -aet -aec {t.aet_target} -nuc +sp *.dcm -to 60 +crf /var/outgoing/{task.id}/sent.txt" # type: ignore - fake_process.register(expect_command) # type: ignore - common.monitor.configure("dispatcher", "test", config.bookkeeper) - dispatcher.dispatch() - - assert Path(f"/var/success/{task.id}").is_dir() - + for target_item in task.dispatch.target_name: + t = config.targets[target_item] + expect_command = f"dcmsend {t.ip} {t.port} +sd /var/outgoing/{task.id} -aet -aec {t.aet_target} -nuc +sp *.dcm -to 60 +crf /var/outgoing/{task.id}/sent.txt" # type: ignore + fake_process.register(expect_command) # type: ignore + common.monitor.configure("dispatcher", "test", config.bookkeeper) + dispatcher.dispatch() + + assert Path(f"/var/success/{task.id}").is_dir() + + common.monitor.send_task_event.assert_has_calls( # type: ignore + [ + call(task_event.DISPATCH_BEGIN, task.id, 1, target_item, "Routing job running"), + call(task_event.DISPATCH_COMPLETE, task.id, 1, target_item, "Routing job complete"), + ], + ) common.monitor.send_task_event.assert_has_calls( # type: ignore [ - call(task_event.DISPATCH_BEGIN, task.id, 1, task.dispatch.target_name, "Routing job running"), - call(task_event.DISPATCH_COMPLETE, task.id, 1, "", "Routing job complete"), call(task_event.MOVE, task.id, 0, f"/var/success/{task.id}", "Moved to success folder"), ], ) + @pytest.mark.asyncio async def test_route_study(fs: FakeFilesystem, mercure_config, mocked, fake_process): config = mercure_config(rules) @@ -214,7 +220,7 @@ async def test_route_study(fs: FakeFilesystem, mercure_config, mocked, fake_proc task: Task = Task(**json.load(e)) assert task.id == task_id - assert task.dispatch.target_name == "test_target_2" # type: ignore + assert task.dispatch.target_name == ["test_target_2"] # type: ignore assert task.info.uid == study_uid assert task.info.uid_type == "study" assert task.info.triggered_rules["route_study"] == True # type: ignore @@ -280,7 +286,7 @@ async def test_route_series_success(fs: FakeFilesystem, mercure_config, mocked, with open(out_path / "task.json") as e: task: Task = Task(**json.load(e)) assert task.id == new_task_id - assert task.dispatch.target_name == "test_target" # type: ignore + assert task.dispatch.target_name == ["test_target"] # type: ignore assert task.info.uid == series_uid assert task.info.uid_type == "series" assert task.info.triggered_rules["route_series"] == True # type: ignore @@ -327,7 +333,7 @@ async def test_route_series_new_rule(fs: FakeFilesystem, mercure_config, mocked, with open(out_path / "task.json") as e: task: Task = Task(**json.load(e)) assert task.id == new_task_id - assert task.dispatch.target_name == "test_target" # type: ignore + assert task.dispatch.target_name == ["test_target"] # type: ignore assert task.info.uid == series_uid assert task.info.uid_type == "series" assert task.info.triggered_rules["route_series_new_rule"] == True # type: ignore diff --git a/tests/testing_common.py b/tests/testing_common.py index fe2f66e..9293eaa 100755 --- a/tests/testing_common.py +++ b/tests/testing_common.py @@ -135,7 +135,7 @@ def __init__(self): def wait(self): return {"StatusCode": 0} - def logs(self): + def logs(self, **kwargs): test_string = "Log output" return test_string.encode(encoding="utf8")