mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-27 23:35:01 +00:00
Preserve SharePoint distribution when the site-note save fails loudly 🟥
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
62c0151469
commit
e31d2ad2d1
1 changed files with 31 additions and 0 deletions
|
|
@ -896,3 +896,34 @@ def test_run_fetches_summary_from_coordination_client_on_primary_auth_failure()
|
|||
coord_client.get_rdsap_summary_by_job_id.assert_called_once()
|
||||
saved: EpcPropertyData = mock_save.call_args[0][1]
|
||||
assert saved.energy_rating_current == 78
|
||||
|
||||
|
||||
def test_run_uploads_to_sharepoint_even_when_summary_fetch_fails() -> None:
|
||||
# Arrange — file distribution must survive a loud site-note save failure
|
||||
mock_client = _site_note_client()
|
||||
mock_client.get_rdsap_summary_by_job_id.side_effect = RuntimeError("summary down")
|
||||
|
||||
mock_sharepoint = MagicMock(spec=DomnaSharepointClient)
|
||||
mock_sharepoint.get_folders_in_path.return_value = {
|
||||
"value": [{"name": "123 Main St"}]
|
||||
}
|
||||
service = make_service(pashub_client=mock_client, sharepoint_client=mock_sharepoint)
|
||||
|
||||
# Act / Assert
|
||||
with (
|
||||
patch("backend.pashub_fetcher.pashub_service.upload_file_to_s3"),
|
||||
patch("backend.pashub_fetcher.pashub_service.db_session"),
|
||||
patch("backend.pashub_fetcher.pashub_service.os.remove"),
|
||||
):
|
||||
with pytest.raises(RuntimeError):
|
||||
service.run(
|
||||
make_request(
|
||||
uprn="12345",
|
||||
sharepoint_link="Retrofit/Properties",
|
||||
address="123 Main St | deal",
|
||||
)
|
||||
)
|
||||
|
||||
mock_sharepoint.upload_file.assert_any_call(
|
||||
RD_SAP_SITE_NOTE_PATH, "Retrofit/Properties/123 Main St", "RdSAP_SiteNote_001.pdf"
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue