mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-30 13:10:47 +00:00
The Rebaseliner is the assemble-and-score step (ADR-0013 amendment); its
SapResult is the scored picture that Bill Derivation also prices (ADR-0014),
so rebaseline() now returns a RebaselineResult{effective, reason, sap_result}
instead of (Performance, reason). CalculatorRebaseliner sets sap_result on
both branches (the bill prices it whether lodged or calculated figures win);
StubRebaseliner returns sap_result=None (runs no calculator). Orchestrator
unpacks the result; the bill wiring lands in the next slice.
Also refreshes the stale ML-era docstrings in rebaseliner.py to the
assemble-and-score model (the calculator, not ML, is the rebaseliner
mechanism per ADR-0013).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
50 lines
1.6 KiB
Python
50 lines
1.6 KiB
Python
from __future__ import annotations
|
|
|
|
from typing import Optional
|
|
|
|
import pytest
|
|
|
|
from datatypes.epc.domain.epc import Epc
|
|
from datatypes.epc.domain.epc_property_data import EpcPropertyData
|
|
from domain.property_baseline.performance import Performance
|
|
from domain.property_baseline.rebaseliner import RebaselineNotImplemented, StubRebaseliner
|
|
|
|
|
|
def _epc(*, sap_version: Optional[float]) -> EpcPropertyData:
|
|
epc = object.__new__(EpcPropertyData)
|
|
epc.sap_version = sap_version
|
|
return epc
|
|
|
|
|
|
def _lodged() -> Performance:
|
|
return Performance(
|
|
sap_score=72, epc_band=Epc.C, co2_emissions=1.8, primary_energy_intensity=180
|
|
)
|
|
|
|
|
|
def test_sap10_epc_is_not_rebaselined_so_effective_equals_lodged() -> None:
|
|
# Arrange — a SAP 10.2 cert: no rebaselining trigger fires.
|
|
epc = _epc(sap_version=10.2)
|
|
lodged = _lodged()
|
|
rebaseliner = StubRebaseliner()
|
|
|
|
# Act
|
|
result = rebaseliner.rebaseline(10, epc, lodged)
|
|
|
|
# Assert — Effective Performance equals Lodged, reason "none", no SapResult
|
|
# (the stub runs no calculator).
|
|
assert result.effective == lodged
|
|
assert result.reason == "none"
|
|
assert result.sap_result is None
|
|
|
|
|
|
def test_pre_sap10_epc_raises_because_rebaselining_is_not_implemented() -> None:
|
|
# Arrange — a cert lodged under a pre-SAP10 schema genuinely needs
|
|
# rebaselining, which this stub does not do; it must not fabricate a
|
|
# "none" answer for it.
|
|
epc = _epc(sap_version=9.94)
|
|
rebaseliner = StubRebaseliner()
|
|
|
|
# Act / Assert
|
|
with pytest.raises(RebaselineNotImplemented):
|
|
rebaseliner.rebaseline(10, epc, _lodged())
|