mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-27 23:35:01 +00:00
Summarise a Calico load as a four-count reconciliation report 🟥
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
8510ddf161
commit
87eecc6400
2 changed files with 63 additions and 0 deletions
25
applications/condition/load_report.py
Normal file
25
applications/condition/load_report.py
Normal file
|
|
@ -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
|
||||
38
tests/condition/test_load_report.py
Normal file
38
tests/condition/test_load_report.py
Normal file
|
|
@ -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,
|
||||
)
|
||||
Loading…
Add table
Reference in a new issue