mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-27 23:35:01 +00:00
Roll up each Property's SAP points and savings across its measures 🟥
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
23ff1e73a8
commit
478ee20aaa
1 changed files with 40 additions and 0 deletions
|
|
@ -4,6 +4,8 @@ Property, and the Plan's post-works figures."""
|
|||
|
||||
from typing import Optional, Sequence
|
||||
|
||||
import pytest
|
||||
|
||||
from domain.scenario_export.scenario_sheet import (
|
||||
MEASURE_COLUMNS,
|
||||
ExportMeasure,
|
||||
|
|
@ -86,3 +88,41 @@ def test_every_measure_column_is_present_and_blank_where_the_property_lacks_it()
|
|||
assert row["cavity_wall_insulation"] == 800.0
|
||||
assert row["loft_insulation"] == ""
|
||||
assert row["solar_pv"] == ""
|
||||
|
||||
|
||||
def test_savings_and_sap_points_are_summed_across_a_propertys_measures() -> None:
|
||||
# arrange — two measures, each pivoting to its own cost column and each
|
||||
# contributing SAP points and carbon / energy / bill savings.
|
||||
prop = _property(
|
||||
measures=[
|
||||
_measure(
|
||||
measure_type="loft_insulation",
|
||||
estimated_cost=1000.0,
|
||||
sap_points=3.0,
|
||||
co2_equivalent_savings=0.4,
|
||||
kwh_savings=900.0,
|
||||
energy_cost_savings=120.0,
|
||||
),
|
||||
_measure(
|
||||
measure_type="solar_pv",
|
||||
estimated_cost=5000.0,
|
||||
sap_points=5.0,
|
||||
co2_equivalent_savings=1.1,
|
||||
kwh_savings=2500.0,
|
||||
energy_cost_savings=300.0,
|
||||
),
|
||||
]
|
||||
)
|
||||
|
||||
# act
|
||||
sheet = shape_scenario_sheet([prop])
|
||||
|
||||
# assert — each cost pivots to its own column, and the savings roll up to the
|
||||
# Property's totals.
|
||||
row = sheet.rows[0]
|
||||
assert row["loft_insulation"] == 1000.0
|
||||
assert row["solar_pv"] == 5000.0
|
||||
assert row["sap_points"] == 8.0
|
||||
assert row["co2_equivalent_savings"] == pytest.approx(1.5)
|
||||
assert row["kwh_savings"] == 3400.0
|
||||
assert row["energy_cost_savings"] == 420.0
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue