mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
Merge branch 'main' into feature/magicplan-api-client
This commit is contained in:
commit
0ba0beed3f
4 changed files with 43 additions and 4 deletions
|
|
@ -11,3 +11,4 @@ pytz
|
|||
boto3==1.35.44
|
||||
pandas==2.2.2
|
||||
numpy<2.0
|
||||
pymupdf
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ payload = {
|
|||
{
|
||||
"pashub_link": "https://google.co.uk",
|
||||
"uprn": "123456",
|
||||
"hubspot_deal_id": "498926855369",
|
||||
"hubspot_deal_id": "1",
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,8 +95,12 @@ class HubspotDataToDb:
|
|||
with db_read_session() as session:
|
||||
deal_id = deal_data.get("hs_object_id")
|
||||
|
||||
self._sync_owner_to_db(deal_data.get("coordinator_user"), hubspot_client, session)
|
||||
self._sync_owner_to_db(deal_data.get("designer_user"), hubspot_client, session)
|
||||
self._sync_owner_to_db(
|
||||
deal_data.get("coordinator_user"), hubspot_client, session
|
||||
)
|
||||
self._sync_owner_to_db(
|
||||
deal_data.get("designer_user"), hubspot_client, session
|
||||
)
|
||||
|
||||
statement = select(HubspotDealData).where(
|
||||
HubspotDealData.deal_id == deal_id
|
||||
|
|
@ -256,7 +260,7 @@ class HubspotDataToDb:
|
|||
),
|
||||
"domna_survey_date": parse_hs_date(deal_data.get("osmosis_survey_date")),
|
||||
}.items():
|
||||
setattr(existing, attr, value or getattr(existing, attr))
|
||||
setattr(existing, attr, value)
|
||||
|
||||
def _build_new_deal(
|
||||
self,
|
||||
|
|
|
|||
34
etl/hubspot/tests/test_hubspot_data_to_db.py
Normal file
34
etl/hubspot/tests/test_hubspot_data_to_db.py
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
from etl.hubspot.hubspotDataTodB import HubspotDataToDb
|
||||
from backend.app.db.models.hubspot_deal_data import HubspotDealData
|
||||
|
||||
|
||||
def _make_instance() -> HubspotDataToDb:
|
||||
return HubspotDataToDb.__new__(HubspotDataToDb)
|
||||
|
||||
|
||||
def test_update_existing_deal__designer_cleared_to_none__overwrites_existing() -> None:
|
||||
existing = HubspotDealData(deal_id="MOCK_DEAL_ID", designer="Old Designer")
|
||||
deal_data = {"designer_user": None}
|
||||
|
||||
_make_instance()._update_existing_deal(
|
||||
existing=existing,
|
||||
deal_data=deal_data,
|
||||
listing=None,
|
||||
company=None,
|
||||
)
|
||||
|
||||
assert existing.designer is None
|
||||
|
||||
|
||||
def test_update_existing_deal__designer_set__overwrites_existing() -> None:
|
||||
existing = HubspotDealData(deal_id="MOCK_DEAL_ID", designer="Old Designer")
|
||||
deal_data = {"designer_user": "New Designer"}
|
||||
|
||||
_make_instance()._update_existing_deal(
|
||||
existing=existing,
|
||||
deal_data=deal_data,
|
||||
listing=None,
|
||||
company=None,
|
||||
)
|
||||
|
||||
assert existing.designer == "New Designer"
|
||||
Loading…
Add table
Reference in a new issue