mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
Upload gzip-compressed MagicPlan JSON to S3 🟩
This commit is contained in:
parent
7c9cb5b161
commit
14a064fdef
2 changed files with 11 additions and 1 deletions
|
|
@ -41,8 +41,16 @@ class MagicPlanService:
|
|||
raise ValueError(f"No MagicPlan found for address: {address!r}")
|
||||
|
||||
magic_plan: MagicPlanPlan = self._client.get_plan(matched.id)
|
||||
raw_bytes: bytes = self._client.get_plan_raw(matched.id)
|
||||
plan: Plan = map_plan(magic_plan)
|
||||
|
||||
compressed = gzip.compress(raw_bytes)
|
||||
if uprn is not None:
|
||||
s3_key = f"documents/uprn/{uprn}/magic_plan_{matched.id}.json.gz"
|
||||
else:
|
||||
s3_key = f"documents/hubspot_deal_id/{request.hubspot_deal_id}/magic_plan_{matched.id}.json.gz"
|
||||
save_data_to_s3(compressed, self._s3_bucket, s3_key)
|
||||
|
||||
with db_session() as session:
|
||||
save_plan(session, plan)
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,9 @@ def plan_summary() -> PlanSummary:
|
|||
|
||||
@pytest.fixture()
|
||||
def mock_client() -> MagicMock:
|
||||
return MagicMock(spec=MagicPlanClient)
|
||||
client = MagicMock(spec=MagicPlanClient)
|
||||
client.get_plan_raw.return_value = b"{}"
|
||||
return client
|
||||
|
||||
|
||||
def _make_service(mock_client: MagicMock) -> MagicPlanService:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue