diff --git a/applications/condition/load_report.py b/applications/condition/load_report.py new file mode 100644 index 000000000..eedba9c78 --- /dev/null +++ b/applications/condition/load_report.py @@ -0,0 +1,25 @@ +from dataclasses import dataclass +from typing import List + +from domain.condition.records.calico.calico_property import CalicoProperty + + +@dataclass(frozen=True) +class LoadReport: + """The reconciliation a Calico load emits so nothing vanishes silently + (ADR-0064): how many observations were loaded versus dropped, and why.""" + + loaded: int + unmatched_to_portfolio: int + null_uprn: int + blank_placeholder: int + + @classmethod + def from_calico_load( + cls, + properties: List[CalicoProperty], + blank_placeholder_count: int, + unmatched_reference_count: int, + null_uprn_references: List[str], + ) -> "LoadReport": + raise NotImplementedError diff --git a/tests/condition/test_load_report.py b/tests/condition/test_load_report.py new file mode 100644 index 000000000..038ea0ab4 --- /dev/null +++ b/tests/condition/test_load_report.py @@ -0,0 +1,38 @@ +from applications.condition.load_report import LoadReport +from domain.condition.records.calico.calico_asset_condition import CalicoAssetCondition +from domain.condition.records.calico.calico_property import CalicoProperty + + +def _property(uprn: int, reference: int, covering: str) -> CalicoProperty: + return CalicoProperty( + uprn=uprn, + assets=[ + CalicoAssetCondition( + asset_reference=reference, path="Roof Covering", covering_type=covering + ) + ], + ) + + +def test_load_report_summarises_the_four_reconciliation_counts(): + # Arrange + properties = [ + _property(100093305101, 443, "Concrete Tiles"), + _property(100093388053, 444, "Natural Slate"), + ] + + # Act + report = LoadReport.from_calico_load( + properties=properties, + blank_placeholder_count=1239, + unmatched_reference_count=5, + null_uprn_references=["999", "888"], + ) + + # Assert + assert report == LoadReport( + loaded=2, + unmatched_to_portfolio=5, + null_uprn=2, + blank_placeholder=1239, + )