Skip to content

Commit

Permalink
Merge pull request #392 from UKGovernmentBEIS/develop
Browse files Browse the repository at this point in the history
dev -> staging
  • Loading branch information
samyou-softwire authored Nov 1, 2024
2 parents ae5fd08 + e45ac68 commit ad6e72f
Show file tree
Hide file tree
Showing 23 changed files with 770 additions and 533 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ add-suppliers:

# -------------------------------------- Code Style -------------------------------------

.PHONY: format-python-code
format-python-code:
docker compose -f tests/docker-compose.yml build format-code-help-to-heat && docker compose -f tests/docker-compose.yml run --no-deps --rm format-code-help-to-heat

.PHONY: check-python-code
check-python-code:
docker compose -f tests/docker-compose.yml build check-code-help-to-heat && docker compose -f tests/docker-compose.yml run --no-deps --rm check-code-help-to-heat
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Migrations are run automatically at startup, and suppliers are added automatical

## Checking code

make check-python-code
make format-python-code

## Deployment

Expand Down
13 changes: 9 additions & 4 deletions docker/tests/check-code.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#!/bin/sh
#!/bin/bash

set -o errexit
set -o nounset

black .
isort .
if [[ $1 = "--format" ]]; then
black .
isort .
else
black --check --diff .
isort --check --diff .
fi

flake8 .
4 changes: 4 additions & 0 deletions help_to_heat/frontdoor/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
address_select_manual_page = "address-select-manual"
council_tax_band_page = "council-tax-band"
epc_page = "epc"
no_epc_page = "no-epc"
epc_ineligible_page = "epc-ineligible"
benefits_page = "benefits"
household_income_page = "household-income"
Expand Down Expand Up @@ -58,6 +59,7 @@
address_select_manual_page,
council_tax_band_page,
epc_page,
no_epc_page,
epc_ineligible_page,
benefits_page,
household_income_page,
Expand Down Expand Up @@ -205,6 +207,8 @@
epc_rating_field_not_found = "Not found"
epc_rating_is_eligible_field = "epc_rating_is_eligible"

no_epc_field = "confirm_no_epc"

benefits_field = "benefits"

household_income_field = "household_income"
Expand Down
64 changes: 62 additions & 2 deletions help_to_heat/frontdoor/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,14 +525,74 @@ def parse_dpa_to_address(self, dpa):


class EPC(Entity):
@with_schema(load=GetScottishEPCSchema, dump=EPCSchema)
@with_schema(load=GetScottishEPCSchema)
def get_epc_scotland(self, uprn):
try:
epc = portal.models.ScottishEpcRating.objects.get(uprn=uprn)
except portal.models.ScottishEpcRating.DoesNotExist:
return {}

return {"uprn": epc.uprn, "rating": epc.rating, "date": epc.date}
improvements = epc.improvements
alternative_improvements = epc.alternative_improvements
all_improvements = improvements + (
"|| Alternatives: " + alternative_improvements if alternative_improvements else ""
)

return {
# follows column names in help_to_heat/frontdoor/mock_epc_api_data/sample_epc_response.json
"uprn": epc.uprn,
"current-energy-rating": epc.rating,
"lodgement-date": epc.date,
"property-type": epc.property_type,
"address1": epc.address1,
"address2": epc.address2,
"address3": epc.address3,
"postcode": epc.postcode,
"building-reference-number": epc.building_reference_number,
"potential-energy-rating": epc.potential_rating,
"current-energy-efficiency": epc.current_energy_efficiency_rating,
"potential-energy-efficiency": epc.potential_energy_efficiency_rating,
"built-form": epc.built_form,
"inspection-date": epc.inspection_date,
"local-authority-label": epc.local_authority,
"constituency-label": epc.constituency,
"energy-consumption-current": epc.energy_consumption,
"energy-consumption-potential": epc.potential_energy_consumption,
"co2-emissions-current": epc.co2_emissions,
"co2-emiss-curr-per-floor-area": epc.co2_emissions_per_floor_area,
"co2-emissions-potential": epc.co2_emissions_potential,
"total-floor-area": epc.floor_area,
"floor-level": epc.floor_level,
"floor-height": epc.floor_height,
"energy-tariff": epc.energy_tariff,
"mains-gas-flag": epc.mains_gas,
"multi-glaze-proportion": epc.multiple_glazed_proportion,
"extension-count": epc.extension_count,
"number-habitable-rooms": epc.habitable_room_count,
"number-heated-rooms": epc.heated_room_count,
"floor-description": epc.floor_description,
"floor-energy-eff": epc.floor_energy_efficiency,
"windows-description": epc.windows_description,
"walls-description": epc.wall_description,
"walls-energy-eff": epc.wall_energy_efficiency,
"walls-env-eff": epc.wall_environmental_efficiency,
"mainheat-description": epc.main_heating_description,
"mainheat-energy-eff": epc.main_heating_energy_efficiency,
"mainheat-env-eff": epc.main_heating_environmental_efficiency,
"main-fuel": epc.main_heating_fuel_type,
"secondheat-description": epc.second_heating_description,
"sheating-energy-eff": epc.second_heating_energy_efficiency,
"roof-description": epc.roof_description,
"roof-energy-eff": epc.roof_energy_efficiency,
"roof-env-eff": epc.roof_environmental_efficiency,
"lighting-description": epc.lighting_description,
"lighting-energy-eff": epc.lighting_energy_efficiency,
"lighting-env-eff": epc.lighting_environmental_efficiency,
"mechanical-ventilation": epc.mechanical_ventilation,
"construction-age-band": epc.construction_age_band,
"tenure": epc.tenure,
"improvements": all_improvements,
}

def get_address_and_epc_lmk(self, building_name_or_number, postcode):
epc_api = EPCApi()
Expand Down
12 changes: 4 additions & 8 deletions help_to_heat/frontdoor/mock_epc_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,11 @@ def get_epc_recommendations(self, lmk_key):
return load_test_reponse("sample_epc_recommendations_response.json")


class MockEPCApiWithEPCC:
def search_epc_details(self, building, postcode):
return load_test_reponse("sample_search_response.json")

class MockEPCApiWithEPCC(MockEPCApi):
def get_epc_details(self, rrn):
return load_test_reponse("sample_epc_response_with_epc_c.json")

def get_epc_recommendations(self, lmk_key):
return load_test_reponse("sample_epc_recommendations_response.json")
epc = load_test_reponse("sample_epc_response.json")
epc["rows"][0]["current-energy-rating"] = "C"
return epc


class MockUnauthorizedEPCApi(MockEPCApi):
Expand Down

This file was deleted.

Loading

0 comments on commit ad6e72f

Please sign in to comment.