Model/tests/domain/epc/test_glazing_overlay.py
Jun-te Kim 71bdcabb73 Produce no overlay for an unresolvable landlord glazing value 🟩
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 13:19:56 +00:00

52 lines
1.5 KiB
Python

"""The Landlord-Override glazing → glazing Simulation Overlay mapping.
A glazing value resolves to the SAP10 `glazing_type` code the calculator's
Table-24 cascade reads; the overlay is whole-dwelling (expanded across every
window by `_fold_glazing`).
"""
from __future__ import annotations
import pytest
from domain.epc.property_overlays.glazing_overlay import glazing_overlay_for
def test_double_glazing_post_2002_overlays_its_glazing_code() -> None:
# Act
simulation = glazing_overlay_for("Double glazing, 2002 or later", 0)
# Assert — double glazing 2002-2021 is SAP10 glazing_type code 2.
assert simulation is not None
assert simulation.glazing is not None
assert simulation.glazing.glazing_type == 2
@pytest.mark.parametrize(
("glazing_value", "code"),
[
("Single glazing", 1),
("Double glazing, pre-2002", 3),
("Triple glazing, 2002 or later", 9),
("Triple glazing, pre-2002", 6),
],
)
def test_glazing_types_decode_to_their_sap_codes(
glazing_value: str, code: int
) -> None:
# Act
simulation = glazing_overlay_for(glazing_value, 0)
# Assert
assert simulation is not None
assert simulation.glazing is not None
assert simulation.glazing.glazing_type == code
@pytest.mark.parametrize("glazing_value", ["Unknown", ""])
def test_unresolvable_glazing_produces_no_overlay(glazing_value: str) -> None:
# Act
simulation = glazing_overlay_for(glazing_value, 0)
# Assert
assert simulation is None