mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
The calculator tests lived under domain/sap10_calculator/{tests,worksheet/
tests,rdsap/tests,climate/tests,validation/tests}, none of which are in
pytest.ini testpaths — so CI (which collects tests/) never ran them. Relocate
all five dirs to tests/domain/sap10_calculator/{,worksheet,rdsap,climate,
validation}, mirroring the tests/domain/property_baseline/ convention, so the
cascade-pin / golden / e2e conformance suites run in CI.
Mechanics:
- git mv preserves history (110 files).
- Flattening the trailing /tests keeps each file's depth-to-repo-root
identical, so all 16 repo-root parents[4] fixture refs stay valid. Only
test_pcdb_etl.py's parents[1] (→ pcdb data) and one hardcoded absolute
golden-fixture path in test_cert_to_inputs.py needed rebasing.
- Cross-imports rewritten domain.sap10_calculator.worksheet.tests →
tests.domain.sap10_calculator.worksheet (21 files incl. the external
importer backend/documents_parser/tests/test_summary_pdf_mapper_chain.py).
- Golden-fixture path strings in test_summary_pdf_mapper_chain.py +
scripts/fetch_cohort2_api_jsons.py updated to the new location (the JSONs
moved with the rdsap tests).
load_cells / gitignored worksheet xlsx: the xlsx-pinned tests (test_dimensions
/ ventilation / water_heating) read 2026-05-19-17-18 RdSap10Worksheet.xlsx,
which is gitignored (.gitignore `*.xlsx`) and so absent in CI. _xlsx_loader.
load_cells now pytest.skip()s when the file is absent, so those tests run
locally and skip cleanly in CI instead of erroring — no new CI failures from
the move, and the gitignore policy is respected.
Verified: tests/domain/sap10_calculator + backend/documents_parser +
tests/domain/property_baseline = 2248 pass, 1 skipped; pyright resolves the
new import paths with zero import-resolution errors.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
41 lines
1.4 KiB
Python
41 lines
1.4 KiB
Python
"""Tests for the runtime PCDB lookup module.
|
|
|
|
The lookup loads pcdb_table_105_gas_oil_boilers.jsonl at import time and
|
|
caches it as a by-pcdb-id dict. Callers (cert_to_inputs) invoke
|
|
`gas_oil_boiler_record(pcdb_id)` to obtain the typed record or None when
|
|
the ID is not in the PCDB.
|
|
|
|
Reference: BRE PCDB pcdb10.dat (April 2026); user-verified records.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from domain.sap10_calculator.tables.pcdb import gas_oil_boiler_record
|
|
|
|
|
|
def test_gas_oil_boiler_record_returns_verified_baxi_98() -> None:
|
|
"""Baxi Heating Wm 20/3rs (user-verified against ncm-pcdb.org.uk):
|
|
winter SAP seasonal efficiency 66.0%, summer 56.0%, comparative HW
|
|
40.8%. Lookup by `main_heating_index_number = 98` returns the typed
|
|
record."""
|
|
# Arrange
|
|
# Act
|
|
record = gas_oil_boiler_record(98)
|
|
|
|
# Assert
|
|
assert record is not None
|
|
assert record.brand_name == "Baxi Heating"
|
|
assert record.model_name == "Wm"
|
|
assert record.winter_efficiency_pct == 66.0
|
|
assert record.summer_efficiency_pct == 56.0
|
|
|
|
|
|
def test_gas_oil_boiler_record_returns_none_for_unknown_pcdb_id() -> None:
|
|
"""`main_heating_index_number` values not in Table 105 return None so
|
|
`cert_to_inputs` can fall back to the Table 4a/4b category default."""
|
|
# Arrange
|
|
# Act
|
|
record = gas_oil_boiler_record(99999999)
|
|
|
|
# Assert
|
|
assert record is None
|