Map a HubSpot outcome to an abandonment reason code 🟥

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Daniel Roth 2026-07-07 15:38:10 +00:00
parent 007e561af5
commit 2512d428a1
2 changed files with 33 additions and 0 deletions

View file

@ -0,0 +1,13 @@
from typing import Optional
from domain.abri.models import AbandonReason
def abandon_reason_for_outcome(outcome: Optional[str]) -> AbandonReason:
"""The OpenHousing abandonment reason code for a HubSpot deal outcome.
The single mapping point from HubSpot's outcome to a coded reason. For now
every outcome maps to CARDED; the real outcome-to-code table is a follow-up
(needs Abri's code list), and swapping it in is a one-place change here.
"""
raise NotImplementedError

View file

@ -0,0 +1,20 @@
from typing import Optional
import pytest
from domain.abri.abandonment import abandon_reason_for_outcome
from domain.abri.models import AbandonReason
@pytest.mark.parametrize(
"outcome",
["no answer", "cancelled", "no show", "tenant refusal", "not viable", None],
)
def test_every_outcome_currently_maps_to_the_carded_reason(
outcome: Optional[str],
) -> None:
# Act
reason = abandon_reason_for_outcome(outcome)
# Assert
assert reason == AbandonReason.CARDED