diff --git a/tests/workflows/test_medua_preingest_curation.py b/tests/workflows/test_medua_preingest_curation.py index f0f9c3f6d..436c60b57 100644 --- a/tests/workflows/test_medua_preingest_curation.py +++ b/tests/workflows/test_medua_preingest_curation.py @@ -58,7 +58,44 @@ def test_sort_item_data(self, workflow, monkeypatch): "files": ["./some/file.txt"], "directories": ["./some/directory/"], } + def test_discover_task_metadata(self, workflow, default_args, monkeypatch): + initial_results = [] + def isfile(path): + return path == "somefile.txt" + def isdir(path): + return path == "somedir" + def iterdir(self): + return [] + + def is_dir(self): + return self.name == 'somedir' + + monkeypatch.setattr(workflow_medusa_preingest.os.path, "isdir", isdir) + monkeypatch.setattr(workflow_medusa_preingest.os.path, "isfile", isfile) + monkeypatch.setattr(workflow_medusa_preingest.Path, "iterdir", iterdir) + monkeypatch.setattr(workflow_medusa_preingest.Path, "is_dir", is_dir) + + new_tasks = workflow.discover_task_metadata( + initial_results, + additional_data={ + "to remove": [ + "somefile.txt", + "somedir", + ] + # "files": ["somefile.txt"], + # "directories": ["somedir"], + }, + **default_args, + ) + + assert all( + new_task in new_tasks + for new_task in [ + {"type": "file", "path": "somefile.txt"}, + {"type": "directory", "path": "somedir"}, + ] + ) def test_get_additional_info_opens_dialog( self, workflow,