Fire Abri flows on a test project code via an override env var 🟥

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Daniel Roth 2026-07-08 10:24:54 +00:00
parent 9806f94c7f
commit 3ff99619ac

View file

@ -2,6 +2,8 @@ from datetime import datetime, timezone
from typing import Any, Dict
import uuid
import pytest
from backend.app.db.models.hubspot_deal_data import HubspotDealData
from etl.hubspot.hubspot_deal_differ import HubspotDealDiffer
@ -187,6 +189,31 @@ def test_no_message_for_a_non_abri_deal() -> None:
assert message is None
def test_the_test_override_env_var_fires_a_deal_on_its_own_project_code(
monkeypatch: pytest.MonkeyPatch,
) -> None:
# Arrange: a sandbox deal on its own project code, with the test override
# pointing the gate at that code so it fires like a production Abri deal.
monkeypatch.setenv("TEST_ABRI_PROJECT_CODE_OVERRIDE", "TEST-SANDBOX-CODE")
old_deal = make_old_deal(project_code="TEST-SANDBOX-CODE", confirmed_survey_date=None)
new_deal = make_new_deal(
project_code="TEST-SANDBOX-CODE", confirmed_survey_date="2026-06-24"
)
# Act
message = HubspotDealDiffer.check_abri_triggers_and_construct_message(
hubspot_deal_id=DEAL_ID,
new_deal=new_deal,
new_project=None,
new_listing=LISTING,
old_deal=old_deal,
)
# Assert
assert message is not None
assert message["flows"] == ["log_job"]
def test_a_deal_crossing_into_abandonment_builds_an_abandon_job_message() -> None:
# Arrange: attempts reach the threshold with a negative outcome, so the
# deal crosses into the abandoned state and the abandon flow fires.