mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
update tests to reflect wall types
This commit is contained in:
parent
3e30b4af40
commit
7f2f2b95a0
1 changed files with 12 additions and 12 deletions
|
|
@ -49,13 +49,13 @@ def test_inserts_a_fresh_row_with_source_classifier(session: Session) -> None:
|
|||
|
||||
# act
|
||||
repo.upsert_all(
|
||||
portfolio_id=1, descriptions_to_values={"cavity insulated": WallType.CAVITY}
|
||||
portfolio_id=1, descriptions_to_values={"cavity insulated": WallType.CAVITY_FILLED}
|
||||
)
|
||||
session.commit()
|
||||
|
||||
# assert
|
||||
row = _select_row(session, portfolio_id=1, description="cavity insulated")
|
||||
assert row.value is WallType.CAVITY
|
||||
assert row.value is WallType.CAVITY_FILLED
|
||||
assert row.source == OverrideSource.CLASSIFIER
|
||||
|
||||
|
||||
|
|
@ -63,19 +63,19 @@ def test_reupsert_overwrites_a_classifier_row(session: Session) -> None:
|
|||
# arrange: a stale classifier row exists.
|
||||
repo = LandlordWallTypeOverridePostgresRepository(session)
|
||||
repo.upsert_all(
|
||||
portfolio_id=1, descriptions_to_values={"old red brick": WallType.CAVITY}
|
||||
portfolio_id=1, descriptions_to_values={"old red brick": WallType.CAVITY_FILLED}
|
||||
)
|
||||
session.commit()
|
||||
|
||||
# act: re-classify with a different category.
|
||||
repo.upsert_all(
|
||||
portfolio_id=1, descriptions_to_values={"old red brick": WallType.SOLID_BRICK}
|
||||
portfolio_id=1, descriptions_to_values={"old red brick": WallType.SOLID_BRICK_AS_BUILT_NO_INSULATION_ASSUMED}
|
||||
)
|
||||
session.commit()
|
||||
|
||||
# assert: the new classification wins.
|
||||
row = _select_row(session, portfolio_id=1, description="old red brick")
|
||||
assert row.value is WallType.SOLID_BRICK
|
||||
assert row.value is WallType.SOLID_BRICK_AS_BUILT_NO_INSULATION_ASSUMED
|
||||
assert row.source == OverrideSource.CLASSIFIER
|
||||
|
||||
|
||||
|
|
@ -86,7 +86,7 @@ def test_reupsert_does_not_overwrite_a_user_row(session: Session) -> None:
|
|||
user_row = LandlordWallTypeOverrideRow(
|
||||
portfolio_id=1,
|
||||
description="old red brick",
|
||||
value=WallType.SANDSTONE,
|
||||
value=WallType.SANDSTONE_AS_BUILT_NO_INSULATION_ASSUMED,
|
||||
source=OverrideSource.USER,
|
||||
)
|
||||
session.add(user_row)
|
||||
|
|
@ -97,13 +97,13 @@ def test_reupsert_does_not_overwrite_a_user_row(session: Session) -> None:
|
|||
# be silently skipped -- user edits beat classifier reruns.
|
||||
repo = LandlordWallTypeOverridePostgresRepository(session)
|
||||
repo.upsert_all(
|
||||
portfolio_id=1, descriptions_to_values={"old red brick": WallType.SOLID_BRICK}
|
||||
portfolio_id=1, descriptions_to_values={"old red brick": WallType.SOLID_BRICK_AS_BUILT_NO_INSULATION_ASSUMED}
|
||||
)
|
||||
session.commit()
|
||||
|
||||
# assert: the user row is unchanged.
|
||||
row = _select_row(session, portfolio_id=1, description="old red brick")
|
||||
assert row.value is WallType.SANDSTONE
|
||||
assert row.value is WallType.SANDSTONE_AS_BUILT_NO_INSULATION_ASSUMED
|
||||
assert row.source == OverrideSource.USER
|
||||
|
||||
|
||||
|
|
@ -114,16 +114,16 @@ def test_upsert_keeps_other_portfolios_descriptions_independent(
|
|||
# same description for two different portfolios must coexist as two rows.
|
||||
repo = LandlordWallTypeOverridePostgresRepository(session)
|
||||
repo.upsert_all(
|
||||
portfolio_id=1, descriptions_to_values={"old red brick": WallType.CAVITY}
|
||||
portfolio_id=1, descriptions_to_values={"old red brick": WallType.CAVITY_FILLED}
|
||||
)
|
||||
repo.upsert_all(
|
||||
portfolio_id=2, descriptions_to_values={"old red brick": WallType.SOLID_BRICK}
|
||||
portfolio_id=2, descriptions_to_values={"old red brick": WallType.SOLID_BRICK_AS_BUILT_NO_INSULATION_ASSUMED}
|
||||
)
|
||||
session.commit()
|
||||
|
||||
# assert: both rows survive with their own values.
|
||||
assert _select_row(session, 1, "old red brick").value is WallType.CAVITY
|
||||
assert _select_row(session, 2, "old red brick").value is WallType.SOLID_BRICK
|
||||
assert _select_row(session, 1, "old red brick").value is WallType.CAVITY_FILLED
|
||||
assert _select_row(session, 2, "old red brick").value is WallType.SOLID_BRICK_AS_BUILT_NO_INSULATION_ASSUMED
|
||||
|
||||
|
||||
def test_upsert_persists_unknown_so_a_user_can_resolve_it_later(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue