mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-19 17:03:02 +00:00
35 lines
1.6 KiB
Python
35 lines
1.6 KiB
Python
"""Every override component must be wired through the WHOLE chain.
|
|
|
|
The finaliser reader (`_ROW_TYPES`, component -> landlord table) and the overlay
|
|
registry (`_COMPONENT_OVERLAYS`, component -> overlay mapper) must cover exactly
|
|
the same set of components. If a component is classified + stored but has no
|
|
reader entry, the finaliser silently never writes its `property_overrides` rows;
|
|
if it has no overlay entry, the row never reaches the calculator. This guard
|
|
keeps the two registries in lock-step (it would have caught the missing
|
|
main_fuel / glazing / construction_age_band reader entries).
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import cast
|
|
|
|
from infrastructure.landlord_overrides.landlord_override_reader_postgres_repository import (
|
|
_ROW_TYPES, # pyright: ignore[reportPrivateUsage]
|
|
)
|
|
from infrastructure.postgres.property_override_table import override_component_sa_enum
|
|
from repositories.property.landlord_override_overlays import (
|
|
_COMPONENT_OVERLAYS, # pyright: ignore[reportPrivateUsage]
|
|
)
|
|
|
|
|
|
def test_reader_and_overlay_registries_cover_the_same_components() -> None:
|
|
# Assert
|
|
assert set(_ROW_TYPES) == set(_COMPONENT_OVERLAYS)
|
|
|
|
|
|
def test_override_component_pgenum_covers_every_component() -> None:
|
|
# The property_overrides.override_component pgEnum mirror must list every
|
|
# component, or writing/reading a new-component row through it throws a
|
|
# LookupError against Postgres (caught live on the Hyde portfolio-796 run).
|
|
pgenum_values = cast(list[str], getattr(override_component_sa_enum, "enums"))
|
|
assert set(pgenum_values) == set(_COMPONENT_OVERLAYS)
|