mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-19 17:03:02 +00:00
79 lines
2.6 KiB
Python
79 lines
2.6 KiB
Python
"""The landlord-description-overrides handler's column wiring (`_build_columns`).
|
|
|
|
A `column_mapping` entry of ``{category -> source header}`` must produce a
|
|
ClassifiableColumn that reads the named header and classifies into the
|
|
category's enum. This pins the main_fuel category onto the wiring.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import cast
|
|
|
|
from applications.landlord_description_overrides.handler import _build_columns # pyright: ignore[reportPrivateUsage]
|
|
from infrastructure.chatgpt.chatgpt import ChatGPT
|
|
|
|
|
|
def test_build_columns_wires_a_main_fuel_classifier_column() -> None:
|
|
# Arrange — the factory only stores the injected collaborators, so a bare
|
|
# object stands in for the (I/O-bound) ChatGPT client and the DB session.
|
|
chat_gpt = cast(ChatGPT, object())
|
|
|
|
# Act
|
|
columns = _build_columns({"main_fuel": "Main Fuel"}, chat_gpt, None)
|
|
|
|
# Assert — one column, named main_fuel, reading the "Main Fuel" header.
|
|
assert len(columns) == 1
|
|
assert columns[0].name == "main_fuel"
|
|
assert columns[0].source_column == "Main Fuel"
|
|
|
|
|
|
def test_build_columns_wires_a_glazing_classifier_column() -> None:
|
|
# Arrange
|
|
chat_gpt = cast(ChatGPT, object())
|
|
|
|
# Act
|
|
columns = _build_columns({"glazing": "Glazing"}, chat_gpt, None)
|
|
|
|
# Assert — one column, named glazing, reading the "Glazing" header.
|
|
assert len(columns) == 1
|
|
assert columns[0].name == "glazing"
|
|
assert columns[0].source_column == "Glazing"
|
|
|
|
|
|
def test_build_columns_wires_a_construction_age_band_classifier_column() -> None:
|
|
# Arrange
|
|
chat_gpt = cast(ChatGPT, object())
|
|
|
|
# Act
|
|
columns = _build_columns({"construction_age_band": "Age"}, chat_gpt, None)
|
|
|
|
# Assert — one column, named construction_age_band, reading the "Age" header.
|
|
assert len(columns) == 1
|
|
assert columns[0].name == "construction_age_band"
|
|
assert columns[0].source_column == "Age"
|
|
|
|
|
|
def test_build_columns_wires_a_water_heating_classifier_column() -> None:
|
|
# Arrange
|
|
chat_gpt = cast(ChatGPT, object())
|
|
|
|
# Act
|
|
columns = _build_columns({"water_heating": "Hot Water"}, chat_gpt, None)
|
|
|
|
# Assert
|
|
assert len(columns) == 1
|
|
assert columns[0].name == "water_heating"
|
|
assert columns[0].source_column == "Hot Water"
|
|
|
|
|
|
def test_build_columns_wires_a_main_heating_system_classifier_column() -> None:
|
|
# Arrange
|
|
chat_gpt = cast(ChatGPT, object())
|
|
|
|
# Act
|
|
columns = _build_columns({"main_heating_system": "Heating"}, chat_gpt, None)
|
|
|
|
# Assert
|
|
assert len(columns) == 1
|
|
assert columns[0].name == "main_heating_system"
|
|
assert columns[0].source_column == "Heating"
|