diff --git a/etl/hubspot/tests/test_abri_flow_triggers.py b/etl/hubspot/tests/test_abri_flow_triggers.py index 0e7eb320b..e6f5631f6 100644 --- a/etl/hubspot/tests/test_abri_flow_triggers.py +++ b/etl/hubspot/tests/test_abri_flow_triggers.py @@ -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.