Lock model-A scoping: exclude properties without a default plan 🟩

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Khalim Conn-Kowlessar 2026-07-13 23:27:39 +00:00
parent 1bb1e605e2
commit 14763638e2

View file

@ -59,3 +59,35 @@ def test_returns_a_row_for_a_property_with_a_default_plan_under_the_scenario(
assert row.uprn == "100023"
assert row.post_sap_points == 78.0
assert row.cost_of_works == 4200.0
def test_excludes_requested_properties_without_a_default_plan_under_the_scenario(
db_engine: Engine,
) -> None:
# arrange — four requested Properties: only #1 has a default Plan under
# scenario 5. #2 has a non-default Plan there, #3 a default Plan under a
# different scenario, #4 no Plan at all.
with Session(db_engine) as session:
for pid in (1, 2, 3, 4):
session.add(
PropertyRow(id=pid, portfolio_id=100, landlord_property_id=f"LP{pid}")
)
session.add(
PlanModel(portfolio_id=100, property_id=1, scenario_id=5, is_default=True)
)
session.add(
PlanModel(portfolio_id=100, property_id=2, scenario_id=5, is_default=False)
)
session.add(
PlanModel(portfolio_id=100, property_id=3, scenario_id=9, is_default=True)
)
session.commit()
# act — request all four.
with Session(db_engine) as session:
rows = ScenarioExportPostgresRepository(session).rows_for(
portfolio_id=100, scenario_id=5, property_ids=[1, 2, 3, 4]
)
# assert — only #1 (a default Plan under scenario 5) survives (model A).
assert [r.property_id for r in rows] == [1]