Model/recommendations/tests/test_optimisers.py
2026-01-22 08:49:57 +00:00

70 lines
3.7 KiB
Python

import pytest
from recommendations.optimiser.funding_optimiser import build_heat_pump_paths
class DummyProp:
"""Minimal property stub exposing just what your code reads."""
def __init__(self):
self.data = {
"current-energy-rating": "E", # or "D" for the special Social+D path
"current-energy-efficiency": 55, # numeric SAP points used in eligibility calc
"mainheat-energy-eff": "Very Good",
}
self.has_ventilation = False
self.floor_area = 70.0
self.main_heating_controls = {"clean_description": "time and temperature zone control"}
self.walls = {'original_description': 'Solid brick, as built, no insulation (assumed)',
'thermal_transmittance': None,
'thermal_transmittance_unit': None, 'is_cavity_wall': False, 'is_filled_cavity': False,
'is_solid_brick': True,
'is_system_built': False, 'is_timber_frame': False, 'is_granite_or_whinstone': False,
'is_as_built': True,
'is_cob': False, 'is_assumed': True, 'is_sandstone_or_limestone': False,
'insulation_thickness': 'none',
'external_insulation': False, 'internal_insulation': False}
self.main_heating = {
'original_description': 'Boiler and radiators, mains gas',
'clean_description': 'Boiler and radiators, mains gas',
'has_radiators': True, 'has_fan_coil_units': False, 'has_pipes_in_screed_above_insulation': False,
'has_pipes_in_insulated_timber_floor': False, 'has_pipes_in_concrete_slab': False, 'has_boiler': True,
'has_air_source_heat_pump': False, 'has_room_heaters': False, 'has_electric_storage_heaters': False,
'has_warm_air': False, 'has_electric_underfloor_heating': False, 'has_electric_ceiling_heating': False,
'has_community_scheme': False, 'has_ground_source_heat_pump': False, 'has_no_system_present': False,
'has_portable_electric_heaters': False, 'has_water_source_heat_pump': False, 'has_electric_heat_pump':
False,
'has_micro-cogeneration': False, 'has_solar_assisted_heat_pump': False, 'has_exhaust_source_heat_pump':
False,
'has_community_heat_pump': False, 'has_hot-water-only': False, 'has_electric': False, 'has_mains_gas':
True,
'has_wood_logs': False, 'has_coal': False, 'has_oil': False, 'has_wood_pellets': False,
'has_anthracite': False,
'has_dual_fuel_mineral_and_wood': False, 'has_smokeless_fuel': False, 'has_lpg': False, 'has_b30k': False,
'has_mineral_and_wood': False, 'has_dual_fuel_appliance': False, 'has_assumed': False,
'has_electricaire': False,
'has_assumed_for_most_rooms': False, 'has_underfloor_heating': False
}
self.main_fuel = {
'original_description': 'mains gas (not community)', 'clean_description': 'Mains gas not community',
'fuel_type': 'mains gas', 'tariff_type': None, 'is_community': False,
'no_individual_heating_or_community_network': False, 'complex_fuel_type': None
}
@pytest.fixture
def p():
return DummyProp()
def test_build_heat_pump_paths():
eg1 = build_heat_pump_paths([], ["loft_insulation"])
assert eg1 == [{'AND': ['loft_insulation', 'air_source_heat_pump']}]
eg2 = build_heat_pump_paths(["internal_wall_insulation", "external_wall_insulation"], ["loft_insulation"])
assert eg2 == [{'AND': ['internal_wall_insulation', 'loft_insulation', 'air_source_heat_pump']},
{'AND': ['external_wall_insulation', 'loft_insulation', 'air_source_heat_pump']}]