Model/tests/domain/epc/test_main_fuel_overlay.py
Jun-te Kim 39950d410c Map community mains gas to its distinct fuel code 🟥
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 12:22:56 +00:00

52 lines
1.5 KiB
Python

"""The Landlord-Override main-fuel → heating Simulation Overlay mapping.
A main-fuel value resolves to the RdSAP `main_fuel_type` int code the calculator
reads from the dwelling's primary heating system; the overlay is whole-dwelling.
"""
from __future__ import annotations
import pytest
from domain.epc.property_overlays.main_fuel_overlay import fuel_overlay_for
def test_mains_gas_overlays_the_primary_fuel() -> None:
# Act
simulation = fuel_overlay_for("mains gas", 0)
# Assert — mains gas (not community) is RdSAP main_fuel code 26.
assert simulation is not None
assert simulation.heating is not None
assert simulation.heating.main_fuel_type == 26
@pytest.mark.parametrize(
("main_fuel_value", "code"),
[
("electricity", 29),
("LPG (bulk)", 27),
("oil", 28),
("house coal", 33),
],
)
def test_fuels_decode_to_their_modern_not_community_codes(
main_fuel_value: str, code: int
) -> None:
# Act
simulation = fuel_overlay_for(main_fuel_value, 0)
# Assert
assert simulation is not None
assert simulation.heating is not None
assert simulation.heating.main_fuel_type == code
def test_community_mains_gas_is_a_distinct_fuel_code() -> None:
# Act
simulation = fuel_overlay_for("mains gas (community)", 0)
# Assert — community mains gas is code 20, distinct from 26 (not community).
assert simulation is not None
assert simulation.heating is not None
assert simulation.heating.main_fuel_type == 20