From 4d60d79cc9125326774b688843e3460749467308 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Tue, 14 Jul 2026 22:33:08 +0000 Subject: [PATCH] =?UTF-8?q?Extract=20the=20PasHub=20community=20heat-sourc?= =?UTF-8?q?e=20label=20=F0=9F=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.8 (1M context) --- .../documents_parser/tests/test_extractor.py | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/backend/documents_parser/tests/test_extractor.py b/backend/documents_parser/tests/test_extractor.py index 00275b820..63cad4be9 100644 --- a/backend/documents_parser/tests/test_extractor.py +++ b/backend/documents_parser/tests/test_extractor.py @@ -706,6 +706,43 @@ class TestRenewablesPvArrays: assert renewables.pv_arrays is None +class TestMainHeatingCommunityHeatSource: + """A community-heating dwelling lodges its heat source under "Heating + System (Other):" (e.g. "Community heating - boilers only", verbatim from + accuracy fixture deal 507644414148). Dropped, the mapper cannot lodge the + Table 4a heat-network SAP code and the dwelling is priced as an ordinary + boiler (issue #1590 follow-up). + """ + + def test_heat_source_label_is_captured(self) -> None: + # Arrange — fixture 1's heating section with the community block + # spliced in after its "Fuel:" lodgement. + lines = load_text_fixture() + idx = lines.index("Fuel:") + spliced = ( + lines[: idx + 2] + + ["Heating System (Other):", "Community heating - boilers only"] + + lines[idx + 2 :] + ) + + # Act + mh = PasHubRdSapSiteNotesExtractor( + spliced + ).extract_heating_and_hot_water().main_heating + + # Assert + assert mh.community_heat_source == "Community heating - boilers only" + + def test_absent_label_stays_blank(self) -> None: + # Arrange / Act — fixture 1 as lodged (no community block). + mh = PasHubRdSapSiteNotesExtractor( + load_text_fixture() + ).extract_heating_and_hot_water().main_heating + + # Assert + assert mh.community_heat_source == "" + + class TestRoofSpaceRoomInRoof: """"Are there rooms in the roof? Yes" lodges an RdSAP §3.10 detailed RIR block (age, floor area, gables/slopes/common walls/flat ceiling as