mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
'Cancelled' and 'no show' were separate strings in the outcome vocabulary, but HubSpot only ever emits the one dropdown value 'Cancelled / No Show' - so neither phantom string could ever match. Replace both with the real value (mapped to NOACCESS, best-guess pending client), which also fixes the long-standing differ mismatch: the abandonment trigger now actually fires on Cancelled / No Show. Drops the now-unused REQT enum member. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
55 lines
1.6 KiB
Python
55 lines
1.6 KiB
Python
from datetime import date
|
|
from typing import Optional
|
|
|
|
import pytest
|
|
|
|
from domain.abri.abandonment import (
|
|
UnmappableOutcomeError,
|
|
abandon_reason_for_outcome,
|
|
abandonment_date,
|
|
)
|
|
from domain.abri.models import AbandonReason
|
|
|
|
CONFIRMED = date(2026, 6, 24)
|
|
SUBMITTED = date(2026, 7, 1)
|
|
|
|
|
|
def test_the_confirmed_survey_date_dates_the_abandonment() -> None:
|
|
assert abandonment_date(CONFIRMED, SUBMITTED) == CONFIRMED
|
|
|
|
|
|
def test_the_last_submission_date_stands_in_without_a_confirmed_survey_date() -> None:
|
|
assert abandonment_date(None, SUBMITTED) == SUBMITTED
|
|
|
|
|
|
def test_neither_date_leaves_the_abandonment_undated() -> None:
|
|
assert abandonment_date(None, None) is None
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
("outcome", "expected"),
|
|
[
|
|
("No Answer", AbandonReason.CARDED),
|
|
("NO ANSWER", AbandonReason.CARDED),
|
|
(" no answer ", AbandonReason.CARDED),
|
|
("Cancelled / No Show", AbandonReason.NOACCESS),
|
|
("cancelled / no show", AbandonReason.NOACCESS),
|
|
("Tenant Refusal", AbandonReason.CRA),
|
|
(" tenant refusal ", AbandonReason.CRA),
|
|
("Not Viable", AbandonReason.NOACCESS),
|
|
("not viable", AbandonReason.NOACCESS),
|
|
],
|
|
)
|
|
def test_a_triggering_outcome_maps_to_its_reason_code(
|
|
outcome: str, expected: AbandonReason
|
|
) -> None:
|
|
assert abandon_reason_for_outcome(outcome) == expected
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"outcome",
|
|
[None, "", " ", "surveyed", "epc completed", "not attempted", "cancelled"],
|
|
)
|
|
def test_an_unmappable_outcome_raises(outcome: Optional[str]) -> None:
|
|
with pytest.raises(UnmappableOutcomeError):
|
|
abandon_reason_for_outcome(outcome)
|