From 6700250891dbefddad536e58caddd372ffec1166 Mon Sep 17 00:00:00 2001 From: Patrick Robertson Date: Thu, 20 Mar 2025 18:18:53 +0400 Subject: [PATCH] Add a test for checking module type on setup --- .../test_modules/example_extractor/__manifest__.py | 11 +++++++++++ .../example_extractor/example_extractor.py | 6 ++++++ tests/test_orchestrator.py | 13 +++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 tests/data/test_modules/example_extractor/__manifest__.py create mode 100644 tests/data/test_modules/example_extractor/example_extractor.py diff --git a/tests/data/test_modules/example_extractor/__manifest__.py b/tests/data/test_modules/example_extractor/__manifest__.py new file mode 100644 index 0000000..dc18dc7 --- /dev/null +++ b/tests/data/test_modules/example_extractor/__manifest__.py @@ -0,0 +1,11 @@ +{ + # Display Name of your module + "name": "Example Extractor", + # Optional version number, for your own versioning purposes + "version": 2.0, + # The type of the module, must be one (or more) of the built in module types + "type": ["extractor"], + # a boolean indicating whether or not a module requires additional user setup before it can be used + # for example: adding API keys, installing additional software etc. + "requires_setup": False, +} diff --git a/tests/data/test_modules/example_extractor/example_extractor.py b/tests/data/test_modules/example_extractor/example_extractor.py new file mode 100644 index 0000000..1c63383 --- /dev/null +++ b/tests/data/test_modules/example_extractor/example_extractor.py @@ -0,0 +1,6 @@ +from auto_archiver.core import Extractor + + +class ExampleExtractor(Extractor): + def download(self, item): + print("download") diff --git a/tests/test_orchestrator.py b/tests/test_orchestrator.py index 326b93d..3367ce0 100644 --- a/tests/test_orchestrator.py +++ b/tests/test_orchestrator.py @@ -4,6 +4,7 @@ from auto_archiver.core.orchestrator import ArchivingOrchestrator from auto_archiver.version import __version__ from auto_archiver.core.config import read_yaml, store_yaml from auto_archiver.core import Metadata +from auto_archiver.core.consts import SetupError TEST_ORCHESTRATION = "tests/data/test_orchestration.yaml" TEST_MODULES = "tests/data/test_modules/" @@ -224,3 +225,15 @@ def test_multiple_orchestrator(test_args): output: Metadata = list(o2.feed()) assert len(output) == 1 assert output[0].get_url() == "https://example.com" + + +def test_wrong_step_type(test_args, caplog): + args = test_args + [ + "--feeders", + "example_extractor", # example_extractor is not a valid feeder! + ] + + orchestrator = ArchivingOrchestrator() + with pytest.raises(SetupError) as err: + orchestrator.setup(args) + assert "Module 'example_extractor' is not a feeder" in str(err.value)