mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-08-02 21:08:24 +00:00
Aligns the historical backfill with the go-forward finaliser: it now writes a boiler_efficiency_band row for EVERY main_heating_system row — the parseable band (A-G) where present, else an explicit Unknown — so historical and go-forward data match. Unknown is fine on non-boilers (inert to modelling). Confirmed with Khalim. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
62 lines
2.1 KiB
Python
62 lines
2.1 KiB
Python
from __future__ import annotations
|
|
|
|
from scripts.backfill_boiler_efficiency_band import (
|
|
BandBackfillRow,
|
|
MainHeatingRow,
|
|
band_backfill_rows,
|
|
)
|
|
|
|
|
|
def _row(desc: str, *, property_id: int = 1, building_part: int = 0) -> MainHeatingRow:
|
|
return MainHeatingRow(
|
|
property_id=property_id,
|
|
portfolio_id=796,
|
|
building_part=building_part,
|
|
original_spreadsheet_description=desc,
|
|
)
|
|
|
|
|
|
def test_backfills_a_band_row_per_boiler_with_a_parseable_band() -> None:
|
|
rows = [
|
|
_row("Boiler: D rated Regular Boiler", property_id=10),
|
|
_row("Boiler: G rated Combi", property_id=11, building_part=1),
|
|
]
|
|
|
|
result = band_backfill_rows(rows)
|
|
|
|
assert result == [
|
|
BandBackfillRow(10, 796, 0, "D", "Boiler: D rated Regular Boiler"),
|
|
BandBackfillRow(11, 796, 1, "G", "Boiler: G rated Combi"),
|
|
]
|
|
|
|
|
|
def test_records_unknown_for_descriptions_without_a_band() -> None:
|
|
# Aligned with the finaliser: every main_heating_system row gets a band row —
|
|
# a description with no determinable band (plain boiler, non-boiler system) is
|
|
# recorded as an explicit Unknown, so historical + go-forward data match.
|
|
# Unknown is fine for non-boilers (inert to modelling).
|
|
rows = [
|
|
_row("Gas boiler", property_id=1),
|
|
_row("Community Heating Systems: Community boilers only (RdSAP)", property_id=2),
|
|
]
|
|
|
|
result = band_backfill_rows(rows)
|
|
|
|
assert [(r.property_id, r.override_value) for r in result] == [
|
|
(1, "Unknown"),
|
|
(2, "Unknown"),
|
|
]
|
|
|
|
|
|
def test_uses_the_same_guard_as_the_live_path_for_multi_system_and_electric() -> None:
|
|
rows = [
|
|
# Multi-system: primary (system 1) band wins — matches the guard.
|
|
_row("Boiler: A rated Combi, System 2: Boiler: C rated Combi", property_id=20),
|
|
# Band letter on an electric "NA" boiler is stored for fidelity; the
|
|
# gas/oil modelling gate ignores it at overlay time (ADR-0068).
|
|
_row("Boiler: A rated NA", property_id=21),
|
|
]
|
|
|
|
result = band_backfill_rows(rows)
|
|
|
|
assert [(r.property_id, r.override_value) for r in result] == [(20, "A"), (21, "A")]
|