Model/tests/scripts/test_reclassify_heating_overrides.py
Khalim Conn-Kowlessar 585c8b1501 One-time script to re-classify stale heating overrides
Deterministic catalogue remap (no LLM) that re-resolves the stored archetype for
the canonical RdSAP heating descriptions the under-populated taxonomy
mis-classified. Dry-run by default; --apply writes inside a transaction;
idempotent. Updates property_overrides.override_value (TEXT — what the modelling
reads, the actual band-G fix: 3,028 rows incl. 2,210 community boilers + 770
panel/convector room heaters). Cache (the Drizzle-owned main_heating_system
pgEnum) updates are deferred per-value until the FE-repo enum migration adds the
new archetypes — surfaced explicitly by the script.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-30 20:30:59 +00:00

30 lines
1.2 KiB
Python

"""The one-time heating-override re-classification map is internally valid."""
from __future__ import annotations
from domain.epc.property_overlays.main_heating_system_overlay import (
main_heating_overlay_for,
)
from domain.epc.property_overrides.main_heating_system_type import (
MainHeatingSystemType,
)
from scripts.reclassify_heating_overrides import REMAP
def test_every_remap_target_is_a_resolvable_archetype() -> None:
# The remap must never point a stored description at an archetype the overlay
# can't model — that would replace one broken value with another. Every
# target must decode to a real SAP heating code (ADR-0041).
for description, archetype in REMAP.items():
simulation = main_heating_overlay_for(archetype.value, 0)
assert simulation is not None, description
assert simulation.heating is not None, description
assert simulation.heating.sap_main_heating_code is not None, description
def test_remap_targets_are_main_heating_system_members() -> None:
# Belt and braces: the values are enum members (a typo can't smuggle a
# non-archetype string into the DB).
for archetype in REMAP.values():
assert archetype in MainHeatingSystemType