diff --git a/backend/ecmk_fetcher/tests/test_xml_processor.py b/backend/ecmk_fetcher/tests/test_xml_processor.py new file mode 100644 index 00000000..10381198 --- /dev/null +++ b/backend/ecmk_fetcher/tests/test_xml_processor.py @@ -0,0 +1,74 @@ +from backend.ecmk_fetcher.xml_processor import parse_rdsap + + +SAMPLE_XML = """ + + +
+ 1 + Fake Avenue + Random + AB24 5CD +
+
+
+ + + + 0 + + + + Main Dwelling + + + + 25.31 + 2.46 + 43.61 + 0 + + + + 26.16 + 2.44 + 42.33 + 0 + + + + 4 + 2 + 100mm + + + + + +
+""" + + +def test_parse_rdsap_wide_flat_contract(): + # arrange + act + result = parse_rdsap(SAMPLE_XML) + + # assert + assert result == { + "address": "1, Fake Avenue, Random, AB24 5CD", + "property_type": "House", + # Main Dwelling - floor 0 + "main_dwelling_floor_index_0_area_m2": 43.61, + "main_dwelling_floor_index_0_height_m": 2.46, + "main_dwelling_floor_index_0_heat_loss_perimeter_m": 25.31, + "main_dwelling_floor_index_0_party_wall_length_m": 0.0, + # Main Dwelling - floor 1 + "main_dwelling_floor_index_1_area_m2": 42.33, + "main_dwelling_floor_index_1_height_m": 2.44, + "main_dwelling_floor_index_1_heat_loss_perimeter_m": 26.16, + "main_dwelling_floor_index_1_party_wall_length_m": 0.0, + # Roof (building-level, repeated across floors or stored once) + "main_dwelling_roof_construction": "4", + "main_dwelling_roof_insulation_location": "2", + "main_dwelling_roof_insulation_thickness": "100mm", + } diff --git a/backend/ecmk_fetcher/xml_processor.py b/backend/ecmk_fetcher/xml_processor.py new file mode 100644 index 00000000..5a392d38 --- /dev/null +++ b/backend/ecmk_fetcher/xml_processor.py @@ -0,0 +1,8 @@ +from typing import Any + +from etl.xml_survey_extraction.XmlParser import PROPERTY_TYPE_LOOKUP + + +# This file should ultimately live somewhere different, probably +def parse_rdsap(xml_string: str) -> Any: # TODO: define shape of return object + raise NotImplementedError diff --git a/datatypes/epc/domain/field_mappings.py b/datatypes/epc/domain/field_mappings.py new file mode 100644 index 00000000..55156d3d --- /dev/null +++ b/datatypes/epc/domain/field_mappings.py @@ -0,0 +1 @@ +PROPERTY_TYPE_LOOKUP = {0: "House", 1: "Bungalow", 2: "Flat", 3: "Maisonette"} diff --git a/pytest.ini b/pytest.ini index 55c2873a..8f8ceeef 100644 --- a/pytest.ini +++ b/pytest.ini @@ -3,6 +3,6 @@ pythonpath = . log_cli = true log_cli_level = INFO addopts = --cov-report term-missing --cov=etl/epc --cov=recommendations --cov=backend --cov=etl/epc_clean --cov=etl/spatial -testpaths = recommendations/tests backend/tests etl/epc/tests etl/epc_clean/tests etl/spatial/tests backend/condition/tests backend/address2UPRN/tests backend/onboarders/tests backend/categorisation/tests backend/export/tests etl/hubspot/tests backend/hubspot_trigger_orchestrator/tests datatypes/epc/schema/tests datatypes/epc/surveys/tests datatypes/epc/domain/tests +testpaths = recommendations/tests backend/tests etl/epc/tests etl/epc_clean/tests etl/spatial/tests backend/condition/tests backend/address2UPRN/tests backend/onboarders/tests backend/categorisation/tests backend/export/tests etl/hubspot/tests backend/hubspot_trigger_orchestrator/tests datatypes/epc/schema/tests datatypes/epc/surveys/tests datatypes/epc/domain/tests backend/ecmk_fetcher/tests/ markers = integration: mark a test as an integration test