From 102b250e5328167998ef58f06ae5f623d68783d6 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Thu, 9 Jul 2026 12:59:45 +0000 Subject: [PATCH] =?UTF-8?q?A=20goal-aligned=20scenario=20without=20a=20bud?= =?UTF-8?q?get=20fails=20loudly=20=F0=9F=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Fable 5 --- .../test_modelling_goal_objectives.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/orchestration/test_modelling_goal_objectives.py b/tests/orchestration/test_modelling_goal_objectives.py index ac7492085..be007ac80 100644 --- a/tests/orchestration/test_modelling_goal_objectives.py +++ b/tests/orchestration/test_modelling_goal_objectives.py @@ -11,6 +11,8 @@ from __future__ import annotations import dataclasses +import pytest + from datatypes.epc.domain.epc_property_data import EpcPropertyData from domain.fuel_rates.fuel import Fuel from domain.fuel_rates.fuel_rates import FuelRate, FuelRates @@ -67,6 +69,25 @@ def test_reducing_co2_scenario_buys_carbon_not_sap() -> None: assert MeasureType.GAS_BOILER_UPGRADE not in selected +def test_a_goal_aligned_scenario_without_a_budget_fails_loudly() -> None: + # Arrange — 'reduce as much as possible within this budget' is undefined + # without a budget: unconstrained it would recommend every beneficial + # measure. A budget-less goal-aligned Scenario is a misconfiguration and + # must fail visibly, not produce a maximal plan. + epc = _solid_brick_dwelling() + budgetless = Scenario( + id=999, + goal="Reducing CO2 emissions", + goal_value="", + budget=None, + is_default=True, + ) + + # Act / Assert + with pytest.raises(ValueError, match="budget"): + run_modelling(epc, scenario=budgetless, print_table=False) + + class _FixedFuelRates(FuelRatesRepository): def __init__(self, rates: FuelRates) -> None: self._rates = rates