Model/tests/domain/property_baseline/test_performance.py
Khalim Conn-Kowlessar c3691d9af2 refactor(property-baseline): rename baseline → property_baseline aggregate (PR #1139 review)
Wholesale rename of the Baseline aggregate to PropertyBaseline for clarity /
to disambiguate from baselines that appear elsewhere in Modelling. Scoped to
this aggregate only — the distinct Rebaselining term (rebaseline_reason,
StubRebaseliner, RebaselineNotImplemented) is deliberately untouched.

- domain/baseline → domain/property_baseline; BaselinePerformance →
  PropertyBaselinePerformance.
- repositories/baseline → repositories/property_baseline; BaselineRepository
  / BaselinePostgresRepository → PropertyBaseline*.
- orchestration/baseline_orchestrator.py → property_baseline_orchestrator.py;
  BaselineOrchestrator → PropertyBaselineOrchestrator. BaselineStage →
  PropertyBaselineStage.
- infrastructure/postgres: baseline_performance_table.py →
  property_baseline_performance_table.py; table `baseline_performance` →
  `property_baseline_performance`; Model renamed.
- UnitOfWork attribute `.baseline` → `.property_baseline`.
- Docs: ADR-0004 references + migration doc (renamed to
  property-baseline-performance-table.md) updated.

CONTEXT.md glossary term ("Baseline Performance") left as-is pending a
ubiquitous-language call (raised on the PR). 123 tests pass; pyright strict
clean (only the unrelated pre-existing moto import errors remain).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-01 14:54:59 +00:00

34 lines
1.1 KiB
Python

from __future__ import annotations
from datatypes.epc.domain.epc import Epc
from datatypes.epc.domain.epc_property_data import EpcPropertyData
from domain.property_baseline.performance import Performance, lodged_performance
def _epc_with_recorded_performance(
*, sap: int, band: Epc, co2: float, peui: int
) -> EpcPropertyData:
# A bare instance with only the recorded-performance fields the reader
# touches — mirrors the opaque-EPC idiom used in the ingestion tests.
epc = object.__new__(EpcPropertyData)
epc.energy_rating_current = sap
epc.current_energy_efficiency_band = band
epc.co2_emissions_current = co2
epc.energy_consumption_current = peui
return epc
def test_lodged_performance_reads_the_four_recorded_quantities_off_the_epc() -> None:
# Arrange
epc = _epc_with_recorded_performance(sap=72, band=Epc.C, co2=1.8, peui=180)
# Act
performance = lodged_performance(epc)
# Assert
assert performance == Performance(
sap_score=72,
epc_band=Epc.C,
co2_emissions=1.8,
primary_energy_intensity=180,
)