mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-27 23:35:01 +00:00
Rank costed works on an already-compliant dwelling HIGH 🟥
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
27060f4d81
commit
0df40278e5
1 changed files with 56 additions and 0 deletions
|
|
@ -1,9 +1,13 @@
|
|||
import dataclasses
|
||||
from typing import Optional
|
||||
|
||||
import pytest
|
||||
|
||||
from scripts.audit.anomalies import (
|
||||
_REGISTRY,
|
||||
PropertyAudit,
|
||||
Severity,
|
||||
_already_meets_goal_with_works,
|
||||
_effective_lodged_divergence,
|
||||
_implausible_lodged_score,
|
||||
_plan_stops_short_of_goal,
|
||||
|
|
@ -155,3 +159,55 @@ class TestPlanStopsShortOfGoal:
|
|||
|
||||
# Assert
|
||||
assert result is None
|
||||
|
||||
|
||||
class TestAlreadyMeetsGoalWithWorks:
|
||||
"""Costed works on a dwelling already in the goal band (#1652 / #1654).
|
||||
|
||||
Ranked HIGH: this is the signature of the Optimiser judging the goal against
|
||||
something other than the published band, and it bills real money — 630 homes
|
||||
in portfolio 796 published at band C were each sold ~1 SAP point of works
|
||||
toward a band they had already reached. It must not sit in the
|
||||
lower-severity bucket that gets waved through as stale-plan noise.
|
||||
"""
|
||||
|
||||
def test_fires_when_a_dwelling_already_at_goal_is_sold_works(self) -> None:
|
||||
# Arrange — published band C, scenario goal C, yet £678 of works.
|
||||
audit = _make_audit(scenario_goal_band="C", cost_of_works=678.0)
|
||||
audit = dataclasses.replace(audit, effective_band="C")
|
||||
|
||||
# Act
|
||||
result = _already_meets_goal_with_works(audit)
|
||||
|
||||
# Assert
|
||||
assert result is not None
|
||||
assert "678" in result
|
||||
|
||||
def test_silent_when_the_dwelling_is_below_the_goal_band(self) -> None:
|
||||
# Arrange — published band D against a goal of C: works are warranted.
|
||||
audit = _make_audit(scenario_goal_band="C", cost_of_works=678.0)
|
||||
audit = dataclasses.replace(audit, effective_band="D")
|
||||
|
||||
# Act
|
||||
result = _already_meets_goal_with_works(audit)
|
||||
|
||||
# Assert
|
||||
assert result is None
|
||||
|
||||
def test_silent_when_an_already_compliant_dwelling_is_sold_nothing(self) -> None:
|
||||
# Arrange — already band C and a £0 plan: the correct outcome.
|
||||
audit = _make_audit(scenario_goal_band="C", cost_of_works=0.0)
|
||||
audit = dataclasses.replace(audit, effective_band="C")
|
||||
|
||||
# Act
|
||||
result = _already_meets_goal_with_works(audit)
|
||||
|
||||
# Assert
|
||||
assert result is None
|
||||
|
||||
def test_is_registered_at_high_severity(self) -> None:
|
||||
# Act — the severity the runner reports it under.
|
||||
registered = {name: severity for name, severity, _ in _REGISTRY}
|
||||
|
||||
# Assert
|
||||
assert registered["already-meets-goal-with-works"] is Severity.HIGH
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue