From 478ee20aaa7d59d1d0425b35c7e654d7f15a3fff Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Mon, 13 Jul 2026 23:11:01 +0000 Subject: [PATCH] =?UTF-8?q?Roll=20up=20each=20Property's=20SAP=20points=20?= =?UTF-8?q?and=20savings=20across=20its=20measures=20=F0=9F=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.8 (1M context) --- .../scenario_export/test_scenario_sheet.py | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/tests/domain/scenario_export/test_scenario_sheet.py b/tests/domain/scenario_export/test_scenario_sheet.py index 6712074bc..eaa2190ce 100644 --- a/tests/domain/scenario_export/test_scenario_sheet.py +++ b/tests/domain/scenario_export/test_scenario_sheet.py @@ -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