diff --git a/tests/repositories/hubspot_deals/test_deal_database_postgres_gateway.py b/tests/repositories/hubspot_deals/test_deal_database_postgres_gateway.py index 89d4cde38..aaa96733b 100644 --- a/tests/repositories/hubspot_deals/test_deal_database_postgres_gateway.py +++ b/tests/repositories/hubspot_deals/test_deal_database_postgres_gateway.py @@ -2,7 +2,7 @@ from collections.abc import Iterator import pytest from sqlalchemy import Engine -from sqlmodel import Session +from sqlmodel import Session, text from backend.app.db.models.hubspot_deal_data import HubspotDealData from repositories.hubspot_deals.deal_database_postgres_gateway import ( @@ -48,6 +48,30 @@ def test_record_job_no_for_an_unknown_deal_raises(session: Session) -> None: gateway.record_job_no(deal_id="0000000000", job_no="AD0226519") +def test_the_job_no_is_stored_in_the_client_booking_reference_column( + session: Session, +) -> None: + # The physical column matches the HubSpot property the job number is + # stored under (client_booking_reference); only the domain calls it + # job_no. The deployed table is migrated by the frontend repo, so the + # column name here must match what that migration created. + # Arrange + _insert_deal(session, DEAL_ID) + gateway = DealDatabasePostgresGateway(session=session) + + # Act + gateway.record_job_no(deal_id=DEAL_ID, job_no="AD0226519") + + # Assert + stored = session.exec( # type: ignore[reportCallOverload] + text( + "select client_booking_reference from hubspot_deal_data " + "where deal_id = :deal_id" + ).bindparams(deal_id=DEAL_ID) + ).one() + assert stored[0] == "AD0226519" + + def test_job_no_for_deal_returns_the_recorded_job_no(session: Session) -> None: # Arrange _insert_deal(session, DEAL_ID)