Log a landlord fuel that contradicts the heating archetype's natural fuel 🟥

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Khalim Conn-Kowlessar 2026-06-30 17:15:16 +00:00
parent 6276730cfe
commit 648013e05c

View file

@ -6,9 +6,16 @@ that fold onto the lodged EPC — per component, partial, skipping unmapped rows
from __future__ import annotations
import logging
import pytest
from datatypes.epc.domain.epc_property_data import BuildingPartIdentifier
from domain.modelling.scoring.overlay_applicator import apply_simulations
from repositories.property.landlord_override_overlays import overlays_from
from repositories.property.landlord_override_overlays import (
flag_fuel_mismatch,
overlays_from,
)
from repositories.property.property_overrides_reader import (
ResolvedPropertyOverride,
ResolvedPropertyOverrides,
@ -171,3 +178,26 @@ def test_main_fuel_override_wins_over_a_heating_archetype_natural_fuel() -> None
# Assert — the explicit fuel (smokeless coal 15) wins over the coal default.
assert result.sap_heating.main_heating_details[0].main_fuel_type == 15
def test_a_fuel_override_contradicting_the_heating_archetype_is_logged(
caplog: pytest.LogCaptureFixture,
) -> None:
# An electric room heater is unambiguously electricity; a "mains gas" main_fuel
# override contradicts it (a different fuel family). The override still wins
# (ADR-0041), but the implausibility is logged for later review — not raised.
overrides = ResolvedPropertyOverrides(
rows=(
ResolvedPropertyOverride(
"main_heating_system", 0, "Electric room heaters"
),
ResolvedPropertyOverride("main_fuel", 0, "mains gas"),
)
)
# Act
with caplog.at_level(logging.WARNING):
flag_fuel_mismatch(overrides)
# Assert
assert any("fuel" in r.message.lower() for r in caplog.records)