mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-19 17:03:02 +00:00
An unrecognised schema_type used to raise ValueError and abort the whole call; now from_api_response logs a warning and returns None so one unmapped cert doesn't break a batch. Schema 15.0 already has a mapper (PR #1531) so it's unaffected; only genuinely unmapped versions skip.
33 lines
1.5 KiB
Python
33 lines
1.5 KiB
Python
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 → logged warning, None returned (not raised)
|
|
# ---------------------------------------------------------------------------
|
|
|
|
def test_from_api_response_unknown_schema_returns_none(caplog):
|
|
with caplog.at_level("WARNING"):
|
|
result = EpcPropertyDataMapper.from_api_response(
|
|
{"schema_type": "RdSAP-Schema-99.0.0"}
|
|
)
|
|
assert result is None
|
|
assert "RdSAP-Schema-99.0.0" in caplog.text
|