Refactoring ArchiveDownloader so that it is more testable.

This commit is contained in:
Roland 2026-05-06 16:35:10 -06:00
parent 0a2e343201
commit 39bd25acfe
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
6 changed files with 433 additions and 109 deletions

View file

@ -1185,8 +1185,12 @@ async def test_archive_download_uses_domain_collection_directory(async_client, t
test_session.add(download)
test_session.commit()
# Call the archive downloader
result = await archive_downloader.do_download(download)
# Drive the phase-split API directly: prepare → execute → finalize.
from modules.archive.conftest import make_test_ctx
prepared = archive_downloader.prepare_download(test_session, download)
executed = await archive_downloader.execute_download(prepared, make_test_ctx())
result = archive_downloader.finalize_download(test_session, download, executed)
test_session.commit()
# Verify the download was successful
assert result.success is True
@ -1247,8 +1251,12 @@ async def test_archive_download_explicit_destination_overrides_domain_collection
test_session.add(download)
test_session.commit()
# Call the archive downloader
result = await archive_downloader.do_download(download)
# Drive the phase-split API directly: prepare → execute → finalize.
from modules.archive.conftest import make_test_ctx
prepared = archive_downloader.prepare_download(test_session, download)
executed = await archive_downloader.execute_download(prepared, make_test_ctx())
result = archive_downloader.finalize_download(test_session, download, executed)
test_session.commit()
# Verify the download was successful
assert result.success is True