From 8ca7698fa0e770322edf0044f38dbe01013788cd Mon Sep 17 00:00:00 2001 From: erinhmclark Date: Tue, 11 Mar 2025 19:58:02 +0000 Subject: [PATCH] Move Makefile and fix import error with unused import. --- docs/Makefile => Makefile | 4 ++-- src/auto_archiver/core/storage.py | 1 + tests/storages/test_storage_base.py | 19 ++++++++++++++++++- 3 files changed, 21 insertions(+), 3 deletions(-) rename docs/Makefile => Makefile (91%) diff --git a/docs/Makefile b/Makefile similarity index 91% rename from docs/Makefile rename to Makefile index 92dd33a..988ac2c 100644 --- a/docs/Makefile +++ b/Makefile @@ -5,8 +5,8 @@ # from the environment for the first two. SPHINXOPTS ?= SPHINXBUILD ?= sphinx-build -SOURCEDIR = source -BUILDDIR = _build +SOURCEDIR = docs/source +BUILDDIR = docs/_build # Put it first so that "make" without argument is like "make help". help: diff --git a/src/auto_archiver/core/storage.py b/src/auto_archiver/core/storage.py index a13aa89..c73e29c 100644 --- a/src/auto_archiver/core/storage.py +++ b/src/auto_archiver/core/storage.py @@ -30,6 +30,7 @@ from slugify import slugify from auto_archiver.utils.misc import random_str from auto_archiver.core import Media, BaseModule, Metadata +from auto_archiver.modules.hash_enricher.hash_enricher import HashEnricher class Storage(BaseModule): diff --git a/tests/storages/test_storage_base.py b/tests/storages/test_storage_base.py index 53dfbd7..62f2ddc 100644 --- a/tests/storages/test_storage_base.py +++ b/tests/storages/test_storage_base.py @@ -92,4 +92,21 @@ def test_really_long_name(storage_base, dummy_file): url = f"https://example.com/{'file'*100}" media = Media(filename=dummy_file) storage.set_key(media, url, Metadata()) - assert media.key == f"https-example-com-{'file'*13}/6ae8a75555209fd6c44157c0.txt" \ No newline at end of file + assert media.key == f"https-example-com-{'file'*13}/6ae8a75555209fd6c44157c0.txt" + + +def test_storage_loads_hash_enricher(storage_base, dummy_file): + """Ensure 'hash_enricher' is properly loaded without an explicit import.""" + config = {"path_generator": "url", "filename_generator": "static"} + storage = storage_base(config) + + url = "https://example.com/file/" + media = Media(filename=dummy_file) + metadata = Metadata() + + try: + storage.set_key(media, url, metadata) + except Exception as e: + pytest.fail(f"Storage failed to dynamically load hash_enricher: {e}") + + assert media.key is not None, "Expected media.key to be set, but it was None"