Model/tests/orchestration/test_first_run_without_database.py
Khalim Conn-Kowlessar c5520b82f9 feat(modelling): run_one console entrypoint for DB-less inspection
Slice 3. `harness.console.run_one(epc, goal_band=...)` wires the full
AraFirstRunPipeline against in-memory fakes — no Postgres, no network —
runs one property, prints the sense-check table, and returns the Plan
for interactive poking from a REPL at the worktree root. Defaults to the
committed harness sample catalogue.

Refactors the slice-1 integration test to delegate to run_one (dropping
~70 lines of duplicated wiring + the now-unused test catalogue fixture),
so it exercises the shipped entrypoint rather than a parallel copy. The
new console test covers run_one's print/return contract.

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

46 lines
1.8 KiB
Python

"""First Run end-to-end with NO database, via the harness console entrypoint.
`harness.console.run_one` wires the full AraFirstRunPipeline (Ingestion ->
Baseline -> Modelling) against in-memory fakes. This proves the whole flow runs
start-to-finish with no Session ever opened and yields a multi-measure Plan;
`tests/harness/test_console.py` covers the entrypoint's print/return contract.
"""
from __future__ import annotations
import dataclasses
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:
# 000490: an uninsulated cavity wall + suspended floor (loft already 300mm),
# so the wall + floor Generators fire and the ventilation Dependency follows.
# The calculator fixture carries no lodged recorded-performance, so we fill it
# in (it already carries the RHI block) so the Baseline stage can run inside
# the full pipeline.
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_first_run_produces_a_multi_measure_plan_without_a_database() -> None:
# Arrange
epc: EpcPropertyData = _uninsulated_lodged_epc()
# Act — the whole First Run, no Session ever opened.
plan = run_one(epc, goal_band="C", print_table=False)
# Assert — a multi-measure Plan that improves on the baseline SAP.
assert len(plan.measures) >= 1
assert plan.post_sap_continuous >= plan.baseline.sap_continuous