mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
39 lines
1.3 KiB
Python
39 lines
1.3 KiB
Python
from __future__ import annotations
|
|
|
|
import pytest
|
|
|
|
from domain.epc.property_overrides.glazing_type import GlazingType
|
|
from domain.epc.property_overrides.glazing_mix_guard import glazing_mix_guard
|
|
|
|
|
|
def test_a_genuine_percentage_mix_classifies_as_mixed() -> None:
|
|
# Arrange — the bug: an aggregate mix the LLM would flatten to "Double".
|
|
description = "40% double glazing 2002 or later, 60% single glazing"
|
|
|
|
# Act
|
|
result = glazing_mix_guard(description)
|
|
|
|
# Assert — a mix defers to the cert's per-window glazing, not a whole-dwelling
|
|
# type.
|
|
assert result is GlazingType.MIXED
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"description",
|
|
[
|
|
"100% double glazing 2002 or later", # uniform — one type
|
|
"96% double glazing 2002 or later, 4% single glazing", # >= 90% -> uniform
|
|
"80% double glazing 2002 or later, 20% double glazing pre-2002", # same base type
|
|
"some double glazing and a bit of single", # unparseable — no percentages
|
|
"",
|
|
],
|
|
)
|
|
def test_uniform_or_unparseable_glazing_defers_to_the_llm(description: str) -> None:
|
|
# The guard only claims a genuine percentage mix; a uniform assertion (applied
|
|
# as that type) or a varied phrasing is left for the LLM classifier.
|
|
|
|
# Act
|
|
result = glazing_mix_guard(description)
|
|
|
|
# Assert
|
|
assert result is None
|