diff --git a/help_to_heat/frontdoor/mock_epc_api.py b/help_to_heat/frontdoor/mock_epc_api.py index 746e64d0..61755410 100644 --- a/help_to_heat/frontdoor/mock_epc_api.py +++ b/help_to_heat/frontdoor/mock_epc_api.py @@ -27,6 +27,11 @@ def get_epc_recommendations(self, lmk_key): return load_test_reponse("sample_epc_recommendations_response.json") +class MockEPCApiWithMultipleEPC(MockEPCApi): + def search_epc_details(self, building, postcode): + return load_test_reponse("sample_search_response_with_multiple_epc.json") + + class MockEPCApiWithEPCC(MockEPCApi): def get_epc_details(self, rrn): epc = load_test_reponse("sample_epc_response.json") diff --git a/help_to_heat/frontdoor/mock_epc_api_data/sample_search_response.json b/help_to_heat/frontdoor/mock_epc_api_data/sample_search_response.json index 39839dec..62c8ec8f 100644 --- a/help_to_heat/frontdoor/mock_epc_api_data/sample_search_response.json +++ b/help_to_heat/frontdoor/mock_epc_api_data/sample_search_response.json @@ -281,100 +281,6 @@ "low-energy-lighting": "0", "walls-description": "Sandstone, as built, no insulation (assumed)", "hotwater-description": "Electric immersion, standard tariff" - }, - { - "low-energy-fixed-light-count": "", - "address": "22 Acacia Avenue, Upper Wellgood, Fulchester, FL23 4JA", - "uprn-source": "Address Matched", - "floor-height": "2.833", - "heating-cost-potential": "1100", - "unheated-corridor-length": "2.05", - "hot-water-cost-potential": "166", - "construction-age-band": "England and Wales: before 1900", - "potential-energy-rating": "F", - "mainheat-energy-eff": "Very Poor", - "windows-env-eff": "Average", - "lighting-energy-eff": "Very Poor", - "environment-impact-potential": "28", - "glazed-type": "double glazing, unknown install date", - "heating-cost-current": "1916", - "address3": "", - "mainheatcont-description": "Programmer and appliance thermostats", - "sheating-energy-eff": "N/A", - "property-type": "Maisonette", - "local-authority-label": "Westminster", - "fixed-lighting-outlets-count": "", - "energy-tariff": "Unknown", - "mechanical-ventilation": "natural", - "hot-water-cost-current": "365", - "county": "Greater London Authority", - "postcode": "FL23 4JA", - "solar-water-heating-flag": "N", - "constituency": "E14000639", - "co2-emissions-potential": "9.9", - "number-heated-rooms": "3", - "floor-description": "(other premises below)", - "energy-consumption-potential": "602", - "local-authority": "E09000033", - "built-form": "NO DATA!", - "number-open-fireplaces": "0", - "windows-description": "Fully double glazed", - "glazed-area": "Normal", - "inspection-date": "2010-07-20", - "mains-gas-flag": "N", - "co2-emiss-curr-per-floor-area": "81", - "address1": "22 Acacia Avenue", - "heat-loss-corridor": "unheated corridor", - "flat-storey-count": "5.0", - "constituency-label": "Cities of London and Westminster", - "roof-energy-eff": "Very Poor", - "total-floor-area": "109.021", - "building-reference-number": "8502528768", - "environment-impact-current": "33", - "co2-emissions-current": "8.8", - "roof-description": "Pitched, no insulation (assumed)", - "floor-energy-eff": "N/A", - "number-habitable-rooms": "3", - "address2": "Upper Wellgood", - "hot-water-env-eff": "Poor", - "posttown": "Fulchester", - "mainheatc-energy-eff": "Good", - "main-fuel": "electricity - this is for backwards compatibility only and should not be used", - "lighting-env-eff": "Very Poor", - "windows-energy-eff": "Average", - "floor-env-eff": "N/A", - "sheating-env-eff": "N/A", - "lighting-description": "No low energy lighting", - "roof-env-eff": "Very Poor", - "walls-energy-eff": "Very Poor", - "photo-supply": "0.0", - "lighting-cost-potential": "136", - "mainheat-env-eff": "Poor", - "multi-glaze-proportion": "100", - "main-heating-controls": "2603", - "lodgement-datetime": "2010-07-20 16:38:12", - "flat-top-storey": "Y", - "current-energy-rating": "G", - "secondheat-description": "None", - "walls-env-eff": "Very Poor", - "transaction-type": "rental (private)", - "uprn": "001234567890", - "current-energy-efficiency": "8", - "energy-consumption-current": "538", - "mainheat-description": "Room heaters, electric", - "lighting-cost-current": "121", - "lodgement-date": "2010-07-20", - "extension-count": "0", - "mainheatc-env-eff": "Good", - "lmk-key": "333333333333333333333333333333333", - "wind-turbine-count": "0", - "tenure": "rental (private)", - "floor-level": "3rd", - "potential-energy-efficiency": "35", - "hot-water-energy-eff": "Very Poor", - "low-energy-lighting": "0", - "walls-description": "Sandstone, as built, no insulation (assumed)", - "hotwater-description": "Electric immersion, standard tariff" } ] } \ No newline at end of file diff --git a/help_to_heat/frontdoor/mock_epc_api_data/sample_search_response_with_multiple_epc.json b/help_to_heat/frontdoor/mock_epc_api_data/sample_search_response_with_multiple_epc.json new file mode 100644 index 00000000..fcf8a676 --- /dev/null +++ b/help_to_heat/frontdoor/mock_epc_api_data/sample_search_response_with_multiple_epc.json @@ -0,0 +1,286 @@ +{ + "column-names": [ + "lmk-key", + "address1", + "address2", + "address3", + "postcode", + "building-reference-number", + "current-energy-rating", + "potential-energy-rating", + "current-energy-efficiency", + "potential-energy-efficiency", + "property-type", + "built-form", + "inspection-date", + "local-authority", + "constituency", + "county", + "lodgement-date", + "transaction-type", + "environment-impact-current", + "environment-impact-potential", + "energy-consumption-current", + "energy-consumption-potential", + "co2-emissions-current", + "co2-emiss-curr-per-floor-area", + "co2-emissions-potential", + "lighting-cost-current", + "lighting-cost-potential", + "heating-cost-current", + "heating-cost-potential", + "hot-water-cost-current", + "hot-water-cost-potential", + "total-floor-area", + "energy-tariff", + "mains-gas-flag", + "floor-level", + "flat-top-storey", + "flat-storey-count", + "main-heating-controls", + "multi-glaze-proportion", + "glazed-type", + "glazed-area", + "extension-count", + "number-habitable-rooms", + "number-heated-rooms", + "low-energy-lighting", + "number-open-fireplaces", + "hotwater-description", + "hot-water-energy-eff", + "hot-water-env-eff", + "floor-description", + "floor-energy-eff", + "floor-env-eff", + "windows-description", + "windows-energy-eff", + "windows-env-eff", + "walls-description", + "walls-energy-eff", + "walls-env-eff", + "secondheat-description", + "sheating-energy-eff", + "sheating-env-eff", + "roof-description", + "roof-energy-eff", + "roof-env-eff", + "mainheat-description", + "mainheat-energy-eff", + "mainheat-env-eff", + "mainheatcont-description", + "mainheatc-energy-eff", + "mainheatc-env-eff", + "lighting-description", + "lighting-energy-eff", + "lighting-env-eff", + "main-fuel", + "wind-turbine-count", + "heat-loss-corridor", + "unheated-corridor-length", + "floor-height", + "photo-supply", + "solar-water-heating-flag", + "mechanical-ventilation", + "address", + "local-authority-label", + "constituency-label", + "posttown", + "construction-age-band", + "lodgement-datetime", + "tenure", + "fixed-lighting-outlets-count", + "low-energy-fixed-light-count", + "uprn", + "uprn-source" + ], + "rows": [ + { + "low-energy-fixed-light-count": "", + "address": "22 Acacia Avenue, Upper Wellgood, Fulchester, FL23 4JA", + "uprn-source": "Address Matched", + "floor-height": "2.833", + "heating-cost-potential": "1100", + "unheated-corridor-length": "2.05", + "hot-water-cost-potential": "166", + "construction-age-band": "England and Wales: before 1900", + "potential-energy-rating": "F", + "mainheat-energy-eff": "Very Poor", + "windows-env-eff": "Average", + "lighting-energy-eff": "Very Poor", + "environment-impact-potential": "28", + "glazed-type": "double glazing, unknown install date", + "heating-cost-current": "1916", + "address3": "", + "mainheatcont-description": "Programmer and appliance thermostats", + "sheating-energy-eff": "N/A", + "property-type": "Maisonette", + "local-authority-label": "Westminster", + "fixed-lighting-outlets-count": "", + "energy-tariff": "Unknown", + "mechanical-ventilation": "natural", + "hot-water-cost-current": "365", + "county": "Greater London Authority", + "postcode": "FL23 4JA", + "solar-water-heating-flag": "N", + "constituency": "E14000639", + "co2-emissions-potential": "9.9", + "number-heated-rooms": "3", + "floor-description": "(other premises below)", + "energy-consumption-potential": "602", + "local-authority": "E09000033", + "built-form": "NO DATA!", + "number-open-fireplaces": "0", + "windows-description": "Fully double glazed", + "glazed-area": "Normal", + "inspection-date": "2010-07-20", + "mains-gas-flag": "N", + "co2-emiss-curr-per-floor-area": "81", + "address1": "22 Acacia Avenue", + "heat-loss-corridor": "unheated corridor", + "flat-storey-count": "5.0", + "constituency-label": "Cities of London and Westminster", + "roof-energy-eff": "Very Poor", + "total-floor-area": "109.021", + "building-reference-number": "8502528768", + "environment-impact-current": "33", + "co2-emissions-current": "8.8", + "roof-description": "Pitched, no insulation (assumed)", + "floor-energy-eff": "N/A", + "number-habitable-rooms": "3", + "address2": "Upper Wellgood", + "hot-water-env-eff": "Poor", + "posttown": "Fulchester", + "mainheatc-energy-eff": "Good", + "main-fuel": "electricity - this is for backwards compatibility only and should not be used", + "lighting-env-eff": "Very Poor", + "windows-energy-eff": "Average", + "floor-env-eff": "N/A", + "sheating-env-eff": "N/A", + "lighting-description": "No low energy lighting", + "roof-env-eff": "Very Poor", + "walls-energy-eff": "Very Poor", + "photo-supply": "0.0", + "lighting-cost-potential": "136", + "mainheat-env-eff": "Poor", + "multi-glaze-proportion": "100", + "main-heating-controls": "2603", + "lodgement-datetime": "2010-07-23 16:38:12", + "flat-top-storey": "Y", + "current-energy-rating": "G", + "secondheat-description": "None", + "walls-env-eff": "Very Poor", + "transaction-type": "rental (private)", + "uprn": "001234567890", + "current-energy-efficiency": "8", + "energy-consumption-current": "538", + "mainheat-description": "Room heaters, electric", + "lighting-cost-current": "121", + "lodgement-date": "2010-07-23", + "extension-count": "0", + "mainheatc-env-eff": "Good", + "lmk-key": "222222222222222222222222222222222", + "wind-turbine-count": "0", + "tenure": "rental (private)", + "floor-level": "3rd", + "potential-energy-efficiency": "35", + "hot-water-energy-eff": "Very Poor", + "low-energy-lighting": "0", + "walls-description": "Sandstone, as built, no insulation (assumed)", + "hotwater-description": "Electric immersion, standard tariff" + }, + { + "low-energy-fixed-light-count": "", + "address": "22 Acacia Avenue, Upper Wellgood, Fulchester, FL23 4JA", + "uprn-source": "Address Matched", + "floor-height": "2.833", + "heating-cost-potential": "1100", + "unheated-corridor-length": "2.05", + "hot-water-cost-potential": "166", + "construction-age-band": "England and Wales: before 1900", + "potential-energy-rating": "F", + "mainheat-energy-eff": "Very Poor", + "windows-env-eff": "Average", + "lighting-energy-eff": "Very Poor", + "environment-impact-potential": "28", + "glazed-type": "double glazing, unknown install date", + "heating-cost-current": "1916", + "address3": "", + "mainheatcont-description": "Programmer and appliance thermostats", + "sheating-energy-eff": "N/A", + "property-type": "Maisonette", + "local-authority-label": "Westminster", + "fixed-lighting-outlets-count": "", + "energy-tariff": "Unknown", + "mechanical-ventilation": "natural", + "hot-water-cost-current": "365", + "county": "Greater London Authority", + "postcode": "FL23 4JA", + "solar-water-heating-flag": "N", + "constituency": "E14000639", + "co2-emissions-potential": "9.9", + "number-heated-rooms": "3", + "floor-description": "(other premises below)", + "energy-consumption-potential": "602", + "local-authority": "E09000033", + "built-form": "NO DATA!", + "number-open-fireplaces": "0", + "windows-description": "Fully double glazed", + "glazed-area": "Normal", + "inspection-date": "2010-07-20", + "mains-gas-flag": "N", + "co2-emiss-curr-per-floor-area": "81", + "address1": "22 Acacia Avenue", + "heat-loss-corridor": "unheated corridor", + "flat-storey-count": "5.0", + "constituency-label": "Cities of London and Westminster", + "roof-energy-eff": "Very Poor", + "total-floor-area": "109.021", + "building-reference-number": "8502528768", + "environment-impact-current": "33", + "co2-emissions-current": "8.8", + "roof-description": "Pitched, no insulation (assumed)", + "floor-energy-eff": "N/A", + "number-habitable-rooms": "3", + "address2": "Upper Wellgood", + "hot-water-env-eff": "Poor", + "posttown": "Fulchester", + "mainheatc-energy-eff": "Good", + "main-fuel": "electricity - this is for backwards compatibility only and should not be used", + "lighting-env-eff": "Very Poor", + "windows-energy-eff": "Average", + "floor-env-eff": "N/A", + "sheating-env-eff": "N/A", + "lighting-description": "No low energy lighting", + "roof-env-eff": "Very Poor", + "walls-energy-eff": "Very Poor", + "photo-supply": "0.0", + "lighting-cost-potential": "136", + "mainheat-env-eff": "Poor", + "multi-glaze-proportion": "100", + "main-heating-controls": "2603", + "lodgement-datetime": "2010-07-20 16:38:12", + "flat-top-storey": "Y", + "current-energy-rating": "G", + "secondheat-description": "None", + "walls-env-eff": "Very Poor", + "transaction-type": "rental (private)", + "uprn": "001234567890", + "current-energy-efficiency": "8", + "energy-consumption-current": "538", + "mainheat-description": "Room heaters, electric", + "lighting-cost-current": "121", + "lodgement-date": "2010-07-20", + "extension-count": "0", + "mainheatc-env-eff": "Good", + "lmk-key": "333333333333333333333333333333333", + "wind-turbine-count": "0", + "tenure": "rental (private)", + "floor-level": "3rd", + "potential-energy-efficiency": "35", + "hot-water-energy-eff": "Very Poor", + "low-energy-lighting": "0", + "walls-description": "Sandstone, as built, no insulation (assumed)", + "hotwater-description": "Electric immersion, standard tariff" + } + ] +} \ No newline at end of file diff --git a/tests/test_frontdoor.py b/tests/test_frontdoor.py index d346d5fe..30d934b6 100644 --- a/tests/test_frontdoor.py +++ b/tests/test_frontdoor.py @@ -20,6 +20,7 @@ from help_to_heat.frontdoor.mock_epc_api import ( MockEPCApi, MockEPCApiWithEPCC, + MockEPCApiWithMultipleEPC, MockNotFoundEPCApi, MockRecommendationsInternalServerErrorEPCApi, MockRecommendationsNotFoundEPCApi, @@ -2126,7 +2127,7 @@ def test_epc_page_shows_epc_info(): assert page.has_one("p:contains('23 July 2010')") -@unittest.mock.patch("help_to_heat.frontdoor.interface.EPCApi", MockEPCApi) +@unittest.mock.patch("help_to_heat.frontdoor.interface.EPCApi", MockEPCApiWithMultipleEPC) def test_epc_select_only_shows_most_recent_epc_per_uprn(): client = utils.get_client() page = client.get("/start") @@ -2160,11 +2161,9 @@ def test_epc_select_only_shows_most_recent_epc_per_uprn(): data = interface.api.session.get_answer(session_id, page_name=address_page) assert page.has_one("label:contains('22 Acacia Avenue, Upper Wellgood, Fulchester, FL23 4JA')") - assert page.has_one("label:contains('11 Acacia Avenue, Upper Wellgood, Fulchester, FL23 4JA')") - assert len(data[address_all_address_and_lmk_details_field]) == 2 + assert len(data[address_all_address_and_lmk_details_field]) == 1 assert data[address_all_address_and_lmk_details_field][0]["lmk-key"] != "3333333333333333333333333333333333" - assert data[address_all_address_and_lmk_details_field][1]["lmk-key"] != "3333333333333333333333333333333333" @unittest.mock.patch("help_to_heat.frontdoor.interface.EPCApi", MockRecommendationsNotFoundEPCApi)