mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +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 = [
|
recs = [
|
||||||
[ # loft insulation measure
|
[ # loft insulation measure
|
||||||
{"recommendation_id": "loft1", "type": "loft_insulation", "total": 100, "kwh_savings": 200,
|
{"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)
|
measures = optimiser_functions.prepare_input_measures(recs, goal="Energy Savings", needs_ventilation=False)
|
||||||
|
|
@ -27,9 +30,12 @@ class TestPrepareInputMeasures:
|
||||||
["internal_wall_insulation"])
|
["internal_wall_insulation"])
|
||||||
recs = [
|
recs = [
|
||||||
[{"recommendation_id": "wall1", "type": "internal_wall_insulation", "total": 500, "kwh_savings": 300,
|
[{"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,
|
[{"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)
|
measures = optimiser_functions.prepare_input_measures(recs, goal="Energy Savings", needs_ventilation=True)
|
||||||
wall_option = measures[0][0]
|
wall_option = measures[0][0]
|
||||||
|
|
@ -40,7 +46,8 @@ class TestPrepareInputMeasures:
|
||||||
def test_filters_out_negative_cost_savings(self):
|
def test_filters_out_negative_cost_savings(self):
|
||||||
recs = [
|
recs = [
|
||||||
[{"recommendation_id": "bad1", "type": "loft_insulation", "total": 200, "kwh_savings": 100,
|
[{"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)
|
measures = optimiser_functions.prepare_input_measures(recs, goal="Energy Savings", needs_ventilation=False)
|
||||||
assert measures == [] # should skip negative cost saving recs
|
assert measures == [] # should skip negative cost saving recs
|
||||||
|
|
@ -149,14 +156,14 @@ class TestIncreasingEpcE2e:
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def setup_case(self):
|
def setup_case(self):
|
||||||
# ✅ Dummy property object
|
# Dummy property object
|
||||||
p = SimpleNamespace(
|
p = SimpleNamespace(
|
||||||
id="P1",
|
id="P1",
|
||||||
has_ventilation=False,
|
has_ventilation=False,
|
||||||
data={"current-energy-efficiency": "52"},
|
data={"current-energy-efficiency": "52"},
|
||||||
)
|
)
|
||||||
|
|
||||||
# ✅ Dummy request body
|
# Dummy request body
|
||||||
body = SimpleNamespace(
|
body = SimpleNamespace(
|
||||||
goal="Increasing EPC",
|
goal="Increasing EPC",
|
||||||
goal_value="C",
|
goal_value="C",
|
||||||
|
|
@ -165,9 +172,6 @@ class TestIncreasingEpcE2e:
|
||||||
simulate_sap_10=False,
|
simulate_sap_10=False,
|
||||||
required_measures=[]
|
required_measures=[]
|
||||||
)
|
)
|
||||||
|
|
||||||
# ✅ Use your massive measures_to_optimise list
|
|
||||||
|
|
||||||
recommendations = {"P1": measures_to_optimise}
|
recommendations = {"P1": measures_to_optimise}
|
||||||
|
|
||||||
return p, body, recommendations
|
return p, body, recommendations
|
||||||
|
|
@ -190,6 +194,18 @@ class TestIncreasingEpcE2e:
|
||||||
|
|
||||||
assert needs_ventilation
|
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)
|
input_measures = optimiser_functions.prepare_input_measures(measures_to_optimise, body.goal, needs_ventilation)
|
||||||
|
|
||||||
assert input_measures, "Expected measures to optimise"
|
assert input_measures, "Expected measures to optimise"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue