diff --git a/etl/hubspot/tests/test_scraper_handler.py b/etl/hubspot/tests/test_scraper_handler.py index ec0a90eae..33452bccf 100644 --- a/etl/hubspot/tests/test_scraper_handler.py +++ b/etl/hubspot/tests/test_scraper_handler.py @@ -12,6 +12,7 @@ DEAL_ID = "999" PASHUB_LINK = "https://pashub.example.com/deal/999" MAGICPLAN_QUEUE_URL = "https://sqs.eu-west-2.amazonaws.com/123/magic-plan-dev" PASHUB_QUEUE_URL = "https://sqs.test/pashub" +ABRI_QUEUE_URL = "https://sqs.test/abri" PROJECT = {"project_id": "proj-1", "name": "Project One"} @@ -59,6 +60,7 @@ def run_handler( mock_boto3.client.return_value = mock_sqs mock_settings.return_value.MAGICPLAN_SQS_URL = MAGICPLAN_QUEUE_URL mock_settings.return_value.PASHUB_TO_ARA_SQS_URL = PASHUB_QUEUE_URL + mock_settings.return_value.ABRI_SQS_URL = ABRI_QUEUE_URL handler.__wrapped__({"hubspot_deal_id": DEAL_ID}, "") @@ -229,6 +231,44 @@ def test_existing_deal_pashub_link_unchanged__no_pashub_sqs() -> None: mock_sqs.send_message.assert_not_called() +# ========================================== +# EXISTING DEAL PATH - Abri trigger +# ========================================== + + +def test_existing_abri_deal_first_survey_date__sends_abri_sqs() -> None: + # Arrange + db_deal = make_db_deal( + project_code="Abri Condition", confirmed_survey_date=None + ) + hubspot_deal = make_hubspot_deal( + project_code="Abri Condition", + confirmed_survey_date="2026-06-24", + confirmed_survey_time="14:30", + ) + listing = {"owner_property_id": "1007165", "national_uprn": UPRN} + + # Act + mock_sqs, _ = run_handler( + hubspot_deal=hubspot_deal, db_deal=db_deal, listing=listing + ) + + # Assert + mock_sqs.send_message.assert_called_once_with( + QueueUrl=ABRI_QUEUE_URL, + MessageBody=json.dumps( + { + "hubspot_deal_id": DEAL_ID, + "flows": ["log_job"], + "place_ref": "1007165", + "deal_name": DEAL_NAME, + "confirmed_survey_date": "2026-06-24", + "confirmed_survey_time": "14:30", + } + ), + ) + + # ==================================== # PROJECT upsert # ====================================