differ handles missing timezone from hubspot 🟥

This commit is contained in:
Daniel Roth 2026-04-09 16:25:44 +00:00
parent 757c224113
commit 3123723e8b
3 changed files with 36 additions and 4 deletions

View file

@ -101,11 +101,11 @@ class HubspotDataToDb:
existing = session.exec(statement).first()
if existing:
self._handle_existing_photo_upload(existing, hubspot_client)
print(f"🔄 Updating existing deal (deal_id={deal_id})")
self._update_existing_deal(existing, deal_data, listing, company)
self._handle_existing_photo_upload(existing, hubspot_client)
session.add(existing)
session.commit()
session.refresh(existing)
@ -281,7 +281,7 @@ class HubspotDataToDb:
)
self._upload_photo_to_s3(existing_deal, fresh_photo_url, hubspot_client)
else:
logger.info(f"Hubspot iamge URL unchanged: {fresh_photo_url}")
logger.info(f"Hubspot image URL unchanged: {fresh_photo_url}")
def _handle_new_photo_upload(
self,

View file

@ -104,3 +104,10 @@ def handler(body: dict[str, Any], context: Any) -> None:
logger.info(
f"Not Triggering PasHub file fetcher for HubSpot deal ID {hubspot_deal_id}"
)
print("done")
if __name__ == "__main__":
handler({"hubspot_deal_id": "371470706915"}, "")
print("beep")

View file

@ -1,4 +1,4 @@
from datetime import datetime
from datetime import datetime, timezone
from typing import Any, Dict
import uuid
@ -352,6 +352,31 @@ def test_db_update_trigger__company_changed__returns_true() -> None:
assert result is True
def test_db_update_trigger__missing_hubspot_timezone__returns_false() -> None:
deal_id = uuid.uuid4()
old_deal = make_old_deal(
id=deal_id,
design_completion_date=datetime(2025, 11, 3, 0, 0, tzinfo=timezone.utc),
)
new_deal = make_new_deal(
deal_id,
design_completion_date=datetime(2025, 11, 3, 0, 0),
)
new_company = "new_company"
result = HubspotDealDiffer.check_for_db_update_trigger(
new_deal=new_deal,
new_company=new_company,
new_listing=None,
old_deal=old_deal,
)
assert result is False
def test_db_update_trigger__listing_changed__returns_true() -> None:
deal_id = uuid.uuid4()