mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
fixed funding test cases
This commit is contained in:
parent
ef934f6b7c
commit
a8905f442e
1 changed files with 25 additions and 9 deletions
|
|
@ -12,7 +12,10 @@ class TestPrepareInputMeasures:
|
|||
recs = [
|
||||
[ # loft insulation measure
|
||||
{"recommendation_id": "loft1", "type": "loft_insulation", "total": 100, "kwh_savings": 200,
|
||||
"energy_cost_savings": 10, "has_battery": False, "measure_type": "loft_insulation"},
|
||||
"energy_cost_savings": 10, "has_battery": False, "measure_type": "loft_insulation",
|
||||
"partial_project_funding": 0, "partial_project_score": 0,
|
||||
"uplift_project_score": 0,
|
||||
},
|
||||
],
|
||||
]
|
||||
measures = optimiser_functions.prepare_input_measures(recs, goal="Energy Savings", needs_ventilation=False)
|
||||
|
|
@ -27,9 +30,12 @@ class TestPrepareInputMeasures:
|
|||
["internal_wall_insulation"])
|
||||
recs = [
|
||||
[{"recommendation_id": "wall1", "type": "internal_wall_insulation", "total": 500, "kwh_savings": 300,
|
||||
"energy_cost_savings": 5, "has_battery": False, "measure_type": "internal_wall_insulation"}],
|
||||
"energy_cost_savings": 5, "has_battery": False, "measure_type": "internal_wall_insulation",
|
||||
"partial_project_funding": 0, "partial_project_score": 0, "uplift_project_score": 0,
|
||||
}],
|
||||
[{"recommendation_id": "vent1", "type": "mechanical_ventilation", "total": 50, "kwh_savings": 30,
|
||||
"energy_cost_savings": 5, "has_battery": False, "measure_type": "mechanical_ventilation"}],
|
||||
"energy_cost_savings": 5, "has_battery": False, "measure_type": "mechanical_ventilation",
|
||||
"partial_project_funding": 0, "partial_project_score": 0, "uplift_project_score": 0, }],
|
||||
]
|
||||
measures = optimiser_functions.prepare_input_measures(recs, goal="Energy Savings", needs_ventilation=True)
|
||||
wall_option = measures[0][0]
|
||||
|
|
@ -40,7 +46,8 @@ class TestPrepareInputMeasures:
|
|||
def test_filters_out_negative_cost_savings(self):
|
||||
recs = [
|
||||
[{"recommendation_id": "bad1", "type": "loft_insulation", "total": 200, "kwh_savings": 100,
|
||||
"energy_cost_savings": -5, "has_battery": False}],
|
||||
"energy_cost_savings": -5, "has_battery": False,
|
||||
"partial_project_funding": 0, "partial_project_score": 0, "uplift_project_score": 0, }],
|
||||
]
|
||||
measures = optimiser_functions.prepare_input_measures(recs, goal="Energy Savings", needs_ventilation=False)
|
||||
assert measures == [] # should skip negative cost saving recs
|
||||
|
|
@ -149,14 +156,14 @@ class TestIncreasingEpcE2e:
|
|||
|
||||
@pytest.fixture
|
||||
def setup_case(self):
|
||||
# ✅ Dummy property object
|
||||
# Dummy property object
|
||||
p = SimpleNamespace(
|
||||
id="P1",
|
||||
has_ventilation=False,
|
||||
data={"current-energy-efficiency": "52"},
|
||||
)
|
||||
|
||||
# ✅ Dummy request body
|
||||
# Dummy request body
|
||||
body = SimpleNamespace(
|
||||
goal="Increasing EPC",
|
||||
goal_value="C",
|
||||
|
|
@ -165,9 +172,6 @@ class TestIncreasingEpcE2e:
|
|||
simulate_sap_10=False,
|
||||
required_measures=[]
|
||||
)
|
||||
|
||||
# ✅ Use your massive measures_to_optimise list
|
||||
|
||||
recommendations = {"P1": measures_to_optimise}
|
||||
|
||||
return p, body, recommendations
|
||||
|
|
@ -190,6 +194,18 @@ class TestIncreasingEpcE2e:
|
|||
|
||||
assert needs_ventilation
|
||||
|
||||
# Input the various things we need - set all to 0
|
||||
for group in measures_to_optimise:
|
||||
for r in group:
|
||||
(
|
||||
r["partial_project_score"],
|
||||
r["partial_project_funding"],
|
||||
r["innovation_uplift"],
|
||||
r["uplift_project_score"],
|
||||
) = (
|
||||
0, 0, 0, 0
|
||||
)
|
||||
|
||||
input_measures = optimiser_functions.prepare_input_measures(measures_to_optimise, body.goal, needs_ventilation)
|
||||
|
||||
assert input_measures, "Expected measures to optimise"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue