From 9b58bebfb88d2dcb5055e1687e49776a234520c3 Mon Sep 17 00:00:00 2001 From: Daniel Roth Date: Wed, 1 Jul 2026 10:59:21 +0000 Subject: [PATCH] =?UTF-8?q?Rename=20SapEnergySource.mains=5Fgas=20to=20gas?= =?UTF-8?q?=5Fconnection=5Favailable=20=F0=9F=9F=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 4.6 --- domain/epc/property_overlays/main_fuel_overlay.py | 8 ++++---- domain/modelling/scoring/overlay_applicator.py | 2 +- domain/modelling/simulation.py | 2 +- domain/sap10_ml/tests/_fixtures.py | 4 ++-- domain/sap10_ml/tests/test_transform.py | 2 +- tests/domain/epc/test_main_fuel_overlay.py | 4 ++-- tests/domain/modelling/test_heating_recommendation.py | 4 ++-- tests/domain/modelling/test_overlay_applicator.py | 8 ++++---- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/domain/epc/property_overlays/main_fuel_overlay.py b/domain/epc/property_overlays/main_fuel_overlay.py index 770ebb06f..3827b7524 100644 --- a/domain/epc/property_overlays/main_fuel_overlay.py +++ b/domain/epc/property_overlays/main_fuel_overlay.py @@ -32,8 +32,8 @@ _FUEL_CODES: dict[str, int] = { } # A "mains gas" main fuel asserts the dwelling has a mains-gas connection, so the -# overlay must also flip `sap_energy_source.mains_gas` — not just the fuel code. -# Without it the effective EPC says "fuel = mains gas" while `mains_gas` stays +# overlay must also flip `sap_energy_source.gas_connection_available` — not just the fuel code. +# Without it the effective EPC says "fuel = mains gas" while `gas_connection_available` stays # False, which (a) gates out the gas-boiler-upgrade Measure and (b) makes the # heating Generator read the dwelling as off-gas and wrongly offer HHRSH storage # (property 728513). Only the **private** mains-gas connection (code 26) sets it; @@ -51,7 +51,7 @@ def fuel_overlay_for( code = _FUEL_CODES.get(main_fuel_value) if code is None: return None - mains_gas = True if main_fuel_value in _MAINS_GAS_FUEL_VALUES else None + gas_connection_available = True if main_fuel_value in _MAINS_GAS_FUEL_VALUES else None return EpcSimulation( - heating=HeatingOverlay(main_fuel_type=code, gas_connection_available=mains_gas) + heating=HeatingOverlay(main_fuel_type=code, gas_connection_available=gas_connection_available) ) diff --git a/domain/modelling/scoring/overlay_applicator.py b/domain/modelling/scoring/overlay_applicator.py index 36fedb83f..216463dab 100644 --- a/domain/modelling/scoring/overlay_applicator.py +++ b/domain/modelling/scoring/overlay_applicator.py @@ -149,7 +149,7 @@ _SAP_HEATING_FIELDS: tuple[str, ...] = ( "cylinder_thermostat", "immersion_heating_type", ) -_ENERGY_SOURCE_FIELDS: tuple[str, ...] = ("meter_type", "mains_gas") +_ENERGY_SOURCE_FIELDS: tuple[str, ...] = ("meter_type", "gas_connection_available") def _is_off_peak_meter(meter_type: object) -> bool: diff --git a/domain/modelling/simulation.py b/domain/modelling/simulation.py index 761fa31a3..79855940e 100644 --- a/domain/modelling/simulation.py +++ b/domain/modelling/simulation.py @@ -154,7 +154,7 @@ class HeatingOverlay: (`water_heating_*`, cylinder size + insulation); - the top-level `EpcPropertyData` — `has_hot_water_cylinder`; - ``sap_energy_source`` — `meter_type` (an off-peak tariff for storage) and - `mains_gas` (cleared when the dwelling goes all-electric). + `gas_connection_available` (cleared when the dwelling goes all-electric). The values are **absolute target states**, not deltas (the bundle replaces the system regardless of the before). A `None` field means "leave the diff --git a/domain/sap10_ml/tests/_fixtures.py b/domain/sap10_ml/tests/_fixtures.py index 0e0e83c95..53fbdc357 100644 --- a/domain/sap10_ml/tests/_fixtures.py +++ b/domain/sap10_ml/tests/_fixtures.py @@ -276,7 +276,7 @@ def make_minimal_sap10_epc( photovoltaic_arrays: Optional[list[PhotovoltaicArray]] = None, photovoltaic_supply_percent_roof_area: Optional[int] = None, pv_connection: Optional[int] = None, - mains_gas: bool = True, + gas_connection_available: bool = True, electricity_smart_meter_present: bool = False, gas_smart_meter_present: bool = False, is_dwelling_export_capable: bool = False, @@ -319,7 +319,7 @@ def make_minimal_sap10_epc( list(sap_roof_windows) if sap_roof_windows is not None else None ), sap_energy_source=SapEnergySource( - gas_connection_available=mains_gas, + gas_connection_available=gas_connection_available, meter_type="Single", pv_connection=pv_connection, pv_battery_count=pv_battery_count, diff --git a/domain/sap10_ml/tests/test_transform.py b/domain/sap10_ml/tests/test_transform.py index 8a217fd65..5079c684e 100644 --- a/domain/sap10_ml/tests/test_transform.py +++ b/domain/sap10_ml/tests/test_transform.py @@ -1020,7 +1020,7 @@ def test_to_row_extracts_energy_source_booleans() -> None: # Arrange — gas + electricity smart meters, export capable epc = make_minimal_sap10_epc( energy_rating_current=82, - mains_gas=True, + gas_connection_available=True, electricity_smart_meter_present=True, gas_smart_meter_present=True, is_dwelling_export_capable=True, diff --git a/tests/domain/epc/test_main_fuel_overlay.py b/tests/domain/epc/test_main_fuel_overlay.py index c664563ac..1e477ba98 100644 --- a/tests/domain/epc/test_main_fuel_overlay.py +++ b/tests/domain/epc/test_main_fuel_overlay.py @@ -80,8 +80,8 @@ def test_community_mains_gas_is_a_distinct_fuel_code() -> None: def test_mains_gas_fuel_sets_the_mains_gas_connection_flag() -> None: # A "mains gas" fuel means the dwelling has a mains-gas connection, so the - # overlay must set sap_energy_source.mains_gas too — not only the fuel code. - # Without it the effective EPC says "fuel = mains gas" yet mains_gas=False, + # overlay must set sap_energy_source.gas_connection_available too — not only the fuel code. + # Without it the effective EPC says "fuel = mains gas" yet gas_connection_available=False, # which suppresses the gas-boiler-upgrade path and wrongly offers HHRSH # storage (the off-gas path). (Property 728513.) simulation = fuel_overlay_for("mains gas", 0) diff --git a/tests/domain/modelling/test_heating_recommendation.py b/tests/domain/modelling/test_heating_recommendation.py index 51b0b8f05..d1f53d638 100644 --- a/tests/domain/modelling/test_heating_recommendation.py +++ b/tests/domain/modelling/test_heating_recommendation.py @@ -190,9 +190,9 @@ def test_gas_boiler_house_yields_an_ashp_bundle() -> None: cylinder_insulation_type=1, cylinder_insulation_thickness_mm=50, cylinder_thermostat="Y", - gas_connection_availableater_cylinder=True, + has_hot_water_cylinder=True, meter_type="Single", - mains_gas=False, + gas_connection_available=False, ) diff --git a/tests/domain/modelling/test_overlay_applicator.py b/tests/domain/modelling/test_overlay_applicator.py index 2458e96a5..07abf10d5 100644 --- a/tests/domain/modelling/test_overlay_applicator.py +++ b/tests/domain/modelling/test_overlay_applicator.py @@ -336,11 +336,11 @@ def test_apply_folds_a_heating_overlay_across_all_five_locations() -> None: cylinder_insulation_thickness_mm=120, has_hot_water_cylinder=True, meter_type="18 Hour", - mains_gas=False, + gas_connection_available=False, ) ) - # Actgas_connection_available + # Act result: EpcPropertyData = apply_simulations(baseline, [simulation]) # Assert — every targeted field routed to its home object. @@ -413,11 +413,11 @@ def test_baseline_heating_is_not_mutated_by_a_heating_overlay() -> None: main_heating_control=2404, water_heating_code=903, has_hot_water_cylinder=True, - mains_gas=False, + gas_connection_available=False, ) ) ], - )gas_connection_available + ) # Assert — the baseline's heating is untouched. assert baseline.sap_heating.main_heating_details[0].main_fuel_type == original_fuel