diff --git a/server/tests/test_db_storage.py b/server/tests/test_db_storage.py index 8304c21..35664f5 100644 --- a/server/tests/test_db_storage.py +++ b/server/tests/test_db_storage.py @@ -4,11 +4,13 @@ from app.config import Settings from app.docs_repository import DocsRepository +from app.freshness import build_freshness_report from app.inventory import InventoryRepository from app.pending_changes import PendingChangeError, PendingChangeRepository, ProposedChangeRequest from app.storage.db import Database from app.storage.db_repositories import PostgresDocsRepository, PostgresInventoryRepository from app.storage.factory import make_docs_repository, make_inventory_repository +from app.storage.freshness import build_freshness_report_db from app.storage.importer import database_counts, import_file_repository from app.storage.parity import compare_repositories @@ -62,6 +64,20 @@ repo.read_item("services", "does-not-exist") +def test_freshness_matches_file_backend(imported: tuple[Settings, Database]) -> None: + settings, database = imported + file_report = build_freshness_report( + Settings(repo_root=settings.repo_root, storage_backend="file") + ) + db_report = build_freshness_report_db(database) + + def key(issue: dict[str, str]) -> tuple[str, str, str]: + return (issue["path"], issue["code"], issue["message"]) + + assert db_report["document_count"] == file_report["document_count"] + assert sorted(map(key, db_report["issues"])) == sorted(map(key, file_report["issues"])) + + def test_document_read_returns_expected_shape(imported: tuple[Settings, Database]) -> None: _, database = imported repo = PostgresDocsRepository(database)