From 3ff99619ac8bf20ca7ced587396aee1e07cf1990 Mon Sep 17 00:00:00 2001 From: Daniel Roth Date: Wed, 8 Jul 2026 10:24:54 +0000 Subject: [PATCH] =?UTF-8?q?Fire=20Abri=20flows=20on=20a=20test=20project?= =?UTF-8?q?=20code=20via=20an=20override=20env=20var=20=F0=9F=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.8 --- etl/hubspot/tests/test_abri_flow_triggers.py | 27 ++++++++++++++++++++ 1 file changed, 27 insertions(+) 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.