mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
One-time script (dry-run default, --apply in a transaction, idempotent) that maps every party-ceiling override (another/same dwelling or premises above) currently stored as an external roof value onto the party-ceiling member, reusing the live roof_party_ceiling_guard so the backfill and the classifier cannot drift. Updates property_overrides (TEXT, the modelling read path) and the roof classifier cache; dry-run against the audited DB reports 106 rows. No FE migration — the party- ceiling values already exist in the roof pgEnum. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
33 lines
1.3 KiB
Python
33 lines
1.3 KiB
Python
"""The party-ceiling roof reclassify corrects only the mis-read rows, to the
|
|
guard's member, and is idempotent (#1376)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from scripts.reclassify_party_ceiling_roofs import party_ceiling_corrections
|
|
|
|
|
|
def test_only_misclassified_party_ceiling_rows_are_corrected() -> None:
|
|
# Arrange — a party ceiling mis-read as an external pitched roof (the bug),
|
|
# one already on the correct member, and a genuine pitched roof.
|
|
stored = [
|
|
("another dwelling above: 100mm", "Pitched, 100 mm loft insulation"),
|
|
("another dwelling above: unknown", "(another dwelling above)"),
|
|
("pitched, normal loft access: 150mm", "Pitched, 150 mm loft insulation"),
|
|
]
|
|
|
|
# Act
|
|
corrections = party_ceiling_corrections(stored)
|
|
|
|
# Assert — only the mis-read party ceiling is corrected, to its member value;
|
|
# the already-correct row and the genuine pitched roof are left alone.
|
|
assert corrections == {
|
|
"another dwelling above: 100mm": "(another dwelling above)"
|
|
}
|
|
|
|
|
|
def test_already_corrected_data_yields_no_further_corrections() -> None:
|
|
# Arrange — a re-run over data the first pass already fixed.
|
|
stored = [("another dwelling above: 100mm", "(another dwelling above)")]
|
|
|
|
# Act / Assert — idempotent: nothing left to change.
|
|
assert party_ceiling_corrections(stored) == {}
|