mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
PAS falls back to coordination client when file listing returns 401 🟥
This commit is contained in:
parent
e044638192
commit
d49bd3620e
1 changed files with 23 additions and 0 deletions
|
|
@ -257,6 +257,29 @@ def test_run_uses_coordination_client_when_pas_401_on_uprn_lookup() -> None:
|
|||
assert factory.call_count == 1
|
||||
|
||||
|
||||
def test_run_uses_coordination_client_when_pas_401_on_file_listing() -> None:
|
||||
pas_client = MagicMock(spec=PashubClient)
|
||||
pas_client.get_core_evidence_files_by_job_id.side_effect = UnauthorizedError()
|
||||
|
||||
coord_client = MagicMock(spec=PashubClient)
|
||||
coord_client.get_core_evidence_files_by_job_id.return_value = ["/tmp/a.pdf"]
|
||||
|
||||
factory = MagicMock(return_value=coord_client)
|
||||
|
||||
service = make_service(pashub_client=pas_client, coordination_client_factory=factory)
|
||||
|
||||
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"),
|
||||
):
|
||||
result = service.run(make_request(uprn="12345"))
|
||||
|
||||
assert result == ["/tmp/a.pdf"]
|
||||
coord_client.get_core_evidence_files_by_job_id.assert_called_once()
|
||||
pas_client.get_uprn_by_job_id.assert_not_called()
|
||||
|
||||
|
||||
def test_run_warns_and_continues_when_site_notes_parsing_fails() -> None:
|
||||
mock_client = MagicMock(spec=PashubClient)
|
||||
mock_client.get_uprn_by_job_id.return_value = None
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue