Model/infrastructure/epc_client/tests/test_mapper_dispatcher.py
Khalim Conn-Kowlessar caee4de2f4 feat(ingestion): relocate EpcClientService to infrastructure + SolarRepo (#1133)
Move the EpcClientService package (client + _retry + exceptions + tests) from
the dying backend/ tree to infrastructure/epc_client/ as the New-EPC-API Fetcher;
update the two callers (address2UPRN, a script). All 14 client tests pass.

Add SolarRepository port + SolarPostgresRepository persisting Google Solar
building insights as JSONB (solar_building_insights table), one row per Property.
The EPC repo half of this slice already landed in #1129. pyright strict clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-30 19:45:26 +00:00

31 lines
1.4 KiB
Python

import pytest
from datatypes.epc.domain.mapper import EpcPropertyDataMapper
from datatypes.epc.domain.epc_property_data import EpcPropertyData
# ---------------------------------------------------------------------------
# Test 1: from_api_response with RdSAP-Schema-21.0.0 fixture → EpcPropertyData
# ---------------------------------------------------------------------------
def test_from_api_response_rdsap_21_0_0(rdsap_21_0_0_cert):
result = EpcPropertyDataMapper.from_api_response(rdsap_21_0_0_cert)
assert isinstance(result, EpcPropertyData)
# ---------------------------------------------------------------------------
# Test 2: from_api_response with RdSAP-Schema-21.0.1 fixture → EpcPropertyData
# ---------------------------------------------------------------------------
def test_from_api_response_rdsap_21_0_1(rdsap_21_0_1_cert):
result = EpcPropertyDataMapper.from_api_response(rdsap_21_0_1_cert)
assert isinstance(result, EpcPropertyData)
# ---------------------------------------------------------------------------
# Test 3: unknown schema_type → ValueError
# ---------------------------------------------------------------------------
def test_from_api_response_unknown_schema_raises():
with pytest.raises(ValueError, match="Unsupported EPC schema"):
EpcPropertyDataMapper.from_api_response({"schema_type": "RdSAP-Schema-99.0.0"})