mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
Legacy property columns no longer resolve type or built form 🟥
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
60c448e66d
commit
ddd64a9297
1 changed files with 23 additions and 8 deletions
|
|
@ -1,6 +1,6 @@
|
|||
from typing import Optional
|
||||
|
||||
from sqlalchemy import Engine
|
||||
from sqlalchemy import Engine, text
|
||||
from sqlmodel import Session
|
||||
|
||||
from backend.app.modelling.property_filters import (
|
||||
|
|
@ -220,24 +220,39 @@ def test_epc_without_property_type_falls_back_to_dwelling_type(
|
|||
assert [p.property_id for p in resolved] == [fallback]
|
||||
|
||||
|
||||
def test_property_without_epc_falls_back_to_the_legacy_column(
|
||||
db_engine: Engine,
|
||||
) -> None:
|
||||
# arrange — no override, no EPC rows; only property.property_type
|
||||
def test_legacy_property_columns_are_ignored(db_engine: Engine) -> None:
|
||||
"""property.property_type / built_form are legacy: with no override and no
|
||||
EPC the property is "Unknown", whatever the legacy columns say (ADR-0056
|
||||
amendment)."""
|
||||
# arrange — no override, no EPC rows; the FE-owned legacy column exists in
|
||||
# prod but is no longer mirrored, so add it here and set a value that must
|
||||
# not count
|
||||
with Session(db_engine) as session:
|
||||
legacy = _seed_property(session, portfolio_id=814)
|
||||
session.get_one(PropertyRow, legacy).property_type = "Bungalow"
|
||||
session.connection().execute(
|
||||
text("ALTER TABLE property ADD COLUMN IF NOT EXISTS property_type TEXT")
|
||||
)
|
||||
session.connection().execute(
|
||||
text("UPDATE property SET property_type = 'Bungalow' WHERE id = :id"),
|
||||
{"id": legacy},
|
||||
)
|
||||
session.commit()
|
||||
|
||||
# act
|
||||
resolved = resolve_filtered_property_ids(
|
||||
as_bungalow = resolve_filtered_property_ids(
|
||||
session,
|
||||
portfolio_id=814,
|
||||
filters=PropertyGroupFilters(property_types=["Bungalow"]),
|
||||
)
|
||||
as_unknown = resolve_filtered_property_ids(
|
||||
session,
|
||||
portfolio_id=814,
|
||||
filters=PropertyGroupFilters(property_types=["Unknown"]),
|
||||
)
|
||||
|
||||
# assert
|
||||
assert [p.property_id for p in resolved] == [legacy]
|
||||
assert as_bungalow == []
|
||||
assert [p.property_id for p in as_unknown] == [legacy]
|
||||
|
||||
|
||||
def test_unknown_is_a_selectable_property_type_bucket(db_engine: Engine) -> None:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue