mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
The Plan derives its Valuation Uplift (ADR-0018) from its baseline -> post band jump and works+contingency cost, given one external input — the Property's current market value (a Property Valuation, mostly absent). `Plan.valuation` / `Plan.baseline_epc_rating` are derived like the other headline figures; `PlanModel.from_domain` maps the £ forms to the live plan.valuation_* columns (NULL when no value — the percentage is not persisted on those columns). `Property.current_market_value` is the new optional source; the orchestrator threads it onto the Plan. `run_one` takes a `current_market_value` so the harness can value the uplift, and the sense-check table shows the average % (always) plus the £ forms when known. Sourcing the current market value (upload / default) remains deferred (ADR-0018); it is None throughout until that lands, so the columns stay NULL at scale. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
57 lines
1.8 KiB
Python
57 lines
1.8 KiB
Python
"""The one-property console entrypoint for interactive sense-checking."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import dataclasses
|
|
|
|
import pytest
|
|
|
|
from datatypes.epc.domain.epc import Epc
|
|
from datatypes.epc.domain.epc_property_data import EpcPropertyData
|
|
from harness.console import run_one
|
|
from tests.domain.sap10_calculator.worksheet._elmhurst_worksheet_000490 import (
|
|
build_epc as _build_uninsulated_cavity_and_floor_epc,
|
|
)
|
|
|
|
|
|
def _uninsulated_lodged_epc() -> EpcPropertyData:
|
|
epc = _build_uninsulated_cavity_and_floor_epc()
|
|
return dataclasses.replace(
|
|
epc,
|
|
energy_rating_current=57,
|
|
current_energy_efficiency_band=Epc.D,
|
|
co2_emissions_current=3.0,
|
|
energy_consumption_current=300,
|
|
)
|
|
|
|
|
|
def test_run_one_returns_a_plan_and_prints_the_table(
|
|
capsys: pytest.CaptureFixture[str],
|
|
) -> None:
|
|
# Arrange
|
|
epc: EpcPropertyData = _uninsulated_lodged_epc()
|
|
|
|
# Act — run one property end-to-end with no database, against the default
|
|
# sample catalogue.
|
|
plan = run_one(epc, goal_band="C")
|
|
|
|
# Assert — a multi-measure Plan came back, and its sense-check table printed.
|
|
assert len(plan.measures) >= 1
|
|
printed: str = capsys.readouterr().out
|
|
assert "Plan SAP" in printed
|
|
assert "cavity_wall_insulation" in printed
|
|
|
|
|
|
def test_run_one_threads_a_current_market_value_onto_the_plan() -> None:
|
|
# Arrange
|
|
epc: EpcPropertyData = _uninsulated_lodged_epc()
|
|
|
|
# Act — supply a Property Valuation so the Plan can value the uplift.
|
|
plan = run_one(
|
|
epc, goal_band="C", current_market_value=250_000.0, print_table=False
|
|
)
|
|
|
|
# Assert — the value reached the Plan, which derives its Valuation Uplift
|
|
# from it (the £ amount is 0 here as 000490 stays within band D).
|
|
assert plan.current_market_value == 250_000.0
|
|
assert plan.valuation.average_value is not None
|