mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
pr review, move domain and orhcestration
This commit is contained in:
parent
9c1b6c76a9
commit
c9a9620527
24 changed files with 28 additions and 71 deletions
|
|
@ -27,3 +27,4 @@ pytest-postgresql
|
||||||
# Formatting
|
# Formatting
|
||||||
black==26.1.0
|
black==26.1.0
|
||||||
boto3-stubs
|
boto3-stubs
|
||||||
|
openai
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,11 @@ import boto3
|
||||||
from applications.landlord_description_overrides.landlord_description_overrides_trigger_body import (
|
from applications.landlord_description_overrides.landlord_description_overrides_trigger_body import (
|
||||||
LandlordDescriptionOverridesTriggerBody,
|
LandlordDescriptionOverridesTriggerBody,
|
||||||
)
|
)
|
||||||
from domain.landlord_description_overrides.built_form_type import BuiltFormType
|
from domain.epc.built_form_type import BuiltFormType
|
||||||
from domain.landlord_description_overrides.property_type import PropertyType
|
from domain.epc.property_type import PropertyType
|
||||||
from domain.landlord_description_overrides.roof_type import RoofType
|
from domain.epc.roof_type import RoofType
|
||||||
from domain.landlord_description_overrides.wall_type import WallType
|
from domain.epc.wall_type import WallType
|
||||||
from domain.landlord_description_overrides.wall_type_construction_dates import (
|
from domain.epc.wall_type_construction_dates import (
|
||||||
wall_type_construction_date_prompt_hint,
|
wall_type_construction_date_prompt_hint,
|
||||||
)
|
)
|
||||||
from infrastructure.chatgpt.chatgpt import ChatGPT
|
from infrastructure.chatgpt.chatgpt import ChatGPT
|
||||||
|
|
|
||||||
|
|
@ -14,55 +14,11 @@ class TestSearchEpcIntegration:
|
||||||
def epc_auth_token(self):
|
def epc_auth_token(self):
|
||||||
return os.getenv("EPC_AUTH_TOKEN")
|
return os.getenv("EPC_AUTH_TOKEN")
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
|
||||||
"address, postcode, uprn, skip_os, lmk_key, n_old_epcs",
|
|
||||||
[
|
|
||||||
# Test case 1: Valid address and postcode, skipping OS
|
|
||||||
# In this case, the property is an individual flat but the uprn associated to the
|
|
||||||
# EPC is for the building as a whole, possibly because there was a conversion of sorts
|
|
||||||
("Garden Flat, 48 Bedminster Parade", "BS3 4HS", 308249, True,
|
|
||||||
"260907a5431fa073d193cc6bbec51fbf1ba9a61845ab2503f85aa19ce3ed6afd", 1),
|
|
||||||
|
|
||||||
# Test case 2: Another valid address and postcode
|
|
||||||
# In this case, the newest EPC, does not have a uprn associated to it. If we did a search by
|
|
||||||
# uprn, we would get an old EPC
|
|
||||||
("Flat 8, Hainton House", "DN32 9AQ", "", True,
|
|
||||||
"bd1149a20a73397184f07a9955f872424826e70f4870c058d71be887766ee1f8", 2),
|
|
||||||
# Test case 3: When we make a request to the API for this property, we get back results for
|
|
||||||
# flats 1, 2 and 3. We have some logic to handle the response so that we get back flat 1
|
|
||||||
("Flat 1, 1 Tottenham Street, London", "W1T 2AE", 5167411, True,
|
|
||||||
"3e6414d7f15f4cf7a69dc20c469bcf043d31a49239b183f1bd0c0e1aafa23c93", 0),
|
|
||||||
|
|
||||||
],
|
|
||||||
)
|
|
||||||
def test_find_property(self, epc_auth_token, address, postcode, uprn, skip_os, lmk_key, n_old_epcs):
|
|
||||||
"""
|
|
||||||
Integration test for `find_property`, making actual API calls.
|
|
||||||
"""
|
|
||||||
# Provide your actual API keys or tokens here
|
|
||||||
os_api_key = ""
|
|
||||||
|
|
||||||
# Initialize the SearchEpc instance
|
|
||||||
epc_searcher = SearchEpc(
|
|
||||||
address1=address,
|
|
||||||
postcode=postcode,
|
|
||||||
uprn=uprn,
|
|
||||||
auth_token=epc_auth_token,
|
|
||||||
os_api_key=os_api_key,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Execute the method
|
|
||||||
epc_searcher.find_property(skip_os=skip_os)
|
|
||||||
|
|
||||||
# We check that we have the correct epc
|
|
||||||
assert epc_searcher.newest_epc["lmk-key"] == lmk_key
|
|
||||||
assert len(epc_searcher.older_epcs) == n_old_epcs
|
|
||||||
|
|
||||||
def test_search_housenumber(self):
|
def test_search_housenumber(self):
|
||||||
eg1 = 'Flat A11, Mortimer House, Grendon Road, Exeter'
|
eg1 = "Flat A11, Mortimer House, Grendon Road, Exeter"
|
||||||
res1 = SearchEpc.get_house_number(eg1, None)
|
res1 = SearchEpc.get_house_number(eg1, None)
|
||||||
assert res1 == "A11"
|
assert res1 == "A11"
|
||||||
|
|
||||||
eg2 = 'Flat A9, Mortimer House, Grendon Road, Exeter, EX1 2NL'
|
eg2 = "Flat A9, Mortimer House, Grendon Road, Exeter, EX1 2NL"
|
||||||
res2 = SearchEpc.get_house_number(eg2, None)
|
res2 = SearchEpc.get_house_number(eg2, None)
|
||||||
assert res2 == "A9"
|
assert res2 == "A9"
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ from __future__ import annotations
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Mapping, Optional
|
from typing import Mapping, Optional
|
||||||
|
|
||||||
from domain.landlord_description_overrides.wall_type import WallType
|
from domain.epc.wall_type import WallType
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
|
|
@ -4,7 +4,7 @@ import json
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import Any, Optional, TypeVar
|
from typing import Any, Optional, TypeVar
|
||||||
|
|
||||||
from domain.landlord_description_overrides.column_classifier import (
|
from infrastructure.column_classifier import (
|
||||||
ClassificationError,
|
ClassificationError,
|
||||||
ColumnClassifier,
|
ColumnClassifier,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ from sqlalchemy import Table
|
||||||
from sqlalchemy.dialects.postgresql import insert as pg_insert
|
from sqlalchemy.dialects.postgresql import insert as pg_insert
|
||||||
from sqlmodel import Session
|
from sqlmodel import Session
|
||||||
|
|
||||||
from domain.landlord_description_overrides.built_form_type import BuiltFormType
|
from domain.epc.built_form_type import BuiltFormType
|
||||||
from infrastructure.postgres.landlord_built_form_type_override_table import (
|
from infrastructure.postgres.landlord_built_form_type_override_table import (
|
||||||
LandlordBuiltFormTypeOverrideRow,
|
LandlordBuiltFormTypeOverrideRow,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ from sqlalchemy import BigInteger, Column, UniqueConstraint
|
||||||
from sqlalchemy import Enum as SAEnum
|
from sqlalchemy import Enum as SAEnum
|
||||||
from sqlmodel import Field, SQLModel
|
from sqlmodel import Field, SQLModel
|
||||||
|
|
||||||
from domain.landlord_description_overrides.built_form_type import BuiltFormType
|
from domain.epc.built_form_type import BuiltFormType
|
||||||
from infrastructure.postgres.landlord_override_enums import override_source_sa_enum
|
from infrastructure.postgres.landlord_override_enums import override_source_sa_enum
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ from sqlalchemy import Table
|
||||||
from sqlalchemy.dialects.postgresql import insert as pg_insert
|
from sqlalchemy.dialects.postgresql import insert as pg_insert
|
||||||
from sqlmodel import Session
|
from sqlmodel import Session
|
||||||
|
|
||||||
from domain.landlord_description_overrides.property_type import PropertyType
|
from domain.epc.property_type import PropertyType
|
||||||
from infrastructure.postgres.landlord_override_enums import OverrideSource
|
from infrastructure.postgres.landlord_override_enums import OverrideSource
|
||||||
from infrastructure.postgres.landlord_property_type_override_table import (
|
from infrastructure.postgres.landlord_property_type_override_table import (
|
||||||
LandlordPropertyTypeOverrideRow,
|
LandlordPropertyTypeOverrideRow,
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ from sqlalchemy import BigInteger, Column, UniqueConstraint
|
||||||
from sqlalchemy import Enum as SAEnum
|
from sqlalchemy import Enum as SAEnum
|
||||||
from sqlmodel import Field, SQLModel
|
from sqlmodel import Field, SQLModel
|
||||||
|
|
||||||
from domain.landlord_description_overrides.property_type import PropertyType
|
from domain.epc.property_type import PropertyType
|
||||||
from infrastructure.postgres.landlord_override_enums import override_source_sa_enum
|
from infrastructure.postgres.landlord_override_enums import override_source_sa_enum
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ from sqlalchemy import Table
|
||||||
from sqlalchemy.dialects.postgresql import insert as pg_insert
|
from sqlalchemy.dialects.postgresql import insert as pg_insert
|
||||||
from sqlmodel import Session
|
from sqlmodel import Session
|
||||||
|
|
||||||
from domain.landlord_description_overrides.roof_type import RoofType
|
from domain.epc.roof_type import RoofType
|
||||||
from infrastructure.postgres.landlord_override_enums import OverrideSource
|
from infrastructure.postgres.landlord_override_enums import OverrideSource
|
||||||
from infrastructure.postgres.landlord_roof_type_override_table import (
|
from infrastructure.postgres.landlord_roof_type_override_table import (
|
||||||
LandlordRoofTypeOverrideRow,
|
LandlordRoofTypeOverrideRow,
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ from sqlalchemy import BigInteger, Column, UniqueConstraint
|
||||||
from sqlalchemy import Enum as SAEnum
|
from sqlalchemy import Enum as SAEnum
|
||||||
from sqlmodel import Field, SQLModel
|
from sqlmodel import Field, SQLModel
|
||||||
|
|
||||||
from domain.landlord_description_overrides.roof_type import RoofType
|
from domain.epc.roof_type import RoofType
|
||||||
from infrastructure.postgres.landlord_override_enums import override_source_sa_enum
|
from infrastructure.postgres.landlord_override_enums import override_source_sa_enum
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ from sqlalchemy import Table
|
||||||
from sqlalchemy.dialects.postgresql import insert as pg_insert
|
from sqlalchemy.dialects.postgresql import insert as pg_insert
|
||||||
from sqlmodel import Session
|
from sqlmodel import Session
|
||||||
|
|
||||||
from domain.landlord_description_overrides.wall_type import WallType
|
from domain.epc.wall_type import WallType
|
||||||
from infrastructure.postgres.landlord_override_enums import OverrideSource
|
from infrastructure.postgres.landlord_override_enums import OverrideSource
|
||||||
from infrastructure.postgres.landlord_wall_type_override_table import (
|
from infrastructure.postgres.landlord_wall_type_override_table import (
|
||||||
LandlordWallTypeOverrideRow,
|
LandlordWallTypeOverrideRow,
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ from sqlalchemy import BigInteger, Column, UniqueConstraint
|
||||||
from sqlalchemy import Enum as SAEnum
|
from sqlalchemy import Enum as SAEnum
|
||||||
from sqlmodel import Field, SQLModel
|
from sqlmodel import Field, SQLModel
|
||||||
|
|
||||||
from domain.landlord_description_overrides.wall_type import WallType
|
from domain.epc.wall_type import WallType
|
||||||
from infrastructure.postgres.landlord_override_enums import override_source_sa_enum
|
from infrastructure.postgres.landlord_override_enums import override_source_sa_enum
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ from dataclasses import dataclass
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import Generic, TypeVar
|
from typing import Generic, TypeVar
|
||||||
|
|
||||||
from domain.landlord_description_overrides.column_classifier import ColumnClassifier
|
from infrastructure.column_classifier import ColumnClassifier
|
||||||
from repositories.landlord_overrides.landlord_override_repository import (
|
from repositories.landlord_overrides.landlord_override_repository import (
|
||||||
LandlordOverrideRepository,
|
LandlordOverrideRepository,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,9 @@ from typing import Optional
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from domain.landlord_description_overrides.column_classifier import ClassificationError
|
from infrastructure.column_classifier import ClassificationError
|
||||||
from domain.landlord_description_overrides.property_type import PropertyType
|
from domain.epc.property_type import PropertyType
|
||||||
from domain.landlord_description_overrides.wall_type import WallType
|
from domain.epc.wall_type import WallType
|
||||||
from infrastructure.chatgpt.chatgpt import ChatGPT
|
from infrastructure.chatgpt.chatgpt import ChatGPT
|
||||||
from infrastructure.chatgpt.chatgpt_column_classifier import (
|
from infrastructure.chatgpt.chatgpt_column_classifier import (
|
||||||
ChatGptColumnClassifier,
|
ChatGptColumnClassifier,
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,10 @@ from enum import Enum
|
||||||
from typing import Any, Optional
|
from typing import Any, Optional
|
||||||
|
|
||||||
from domain.addresses.unstandardised_address import AddressList, UnstandardisedAddress
|
from domain.addresses.unstandardised_address import AddressList, UnstandardisedAddress
|
||||||
from domain.landlord_description_overrides.built_form_type import BuiltFormType
|
from domain.epc.built_form_type import BuiltFormType
|
||||||
from domain.landlord_description_overrides.column_classifier import ColumnClassifier
|
from infrastructure.column_classifier import ColumnClassifier
|
||||||
from domain.landlord_description_overrides.property_type import PropertyType
|
from domain.epc.property_type import PropertyType
|
||||||
from domain.landlord_description_overrides.wall_type import WallType
|
from domain.epc.wall_type import WallType
|
||||||
from domain.postcode import Postcode
|
from domain.postcode import Postcode
|
||||||
from orchestration.classifiable_column import ClassifiableColumn
|
from orchestration.classifiable_column import ClassifiableColumn
|
||||||
from orchestration.landlord_description_overrides_orchestrator import (
|
from orchestration.landlord_description_overrides_orchestrator import (
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ import pytest
|
||||||
from sqlalchemy import Engine
|
from sqlalchemy import Engine
|
||||||
from sqlmodel import Session, select
|
from sqlmodel import Session, select
|
||||||
|
|
||||||
from domain.landlord_description_overrides.property_type import PropertyType
|
from domain.epc.property_type import PropertyType
|
||||||
from infrastructure.postgres.landlord_override_enums import OverrideSource
|
from infrastructure.postgres.landlord_override_enums import OverrideSource
|
||||||
from infrastructure.postgres.landlord_property_type_override_postgres_repository import (
|
from infrastructure.postgres.landlord_property_type_override_postgres_repository import (
|
||||||
LandlordPropertyTypeOverridePostgresRepository,
|
LandlordPropertyTypeOverridePostgresRepository,
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import pytest
|
||||||
from sqlalchemy import Engine
|
from sqlalchemy import Engine
|
||||||
from sqlmodel import Session, select
|
from sqlmodel import Session, select
|
||||||
|
|
||||||
from domain.landlord_description_overrides.wall_type import WallType
|
from domain.epc.wall_type import WallType
|
||||||
from infrastructure.postgres.landlord_override_enums import OverrideSource
|
from infrastructure.postgres.landlord_override_enums import OverrideSource
|
||||||
from infrastructure.postgres.landlord_wall_type_override_postgres_repository import (
|
from infrastructure.postgres.landlord_wall_type_override_postgres_repository import (
|
||||||
LandlordWallTypeOverridePostgresRepository,
|
LandlordWallTypeOverridePostgresRepository,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue