|
33 | 33 | from utils.common_query_filters import NotDeleted |
34 | 34 | from utils.constants.ssm import UPLOAD_PILOT_ODS_ALLOWED_LIST |
35 | 35 | from utils.dynamo_query_filter_builder import DynamoQueryFilterBuilder |
36 | | -from utils.exceptions import PatientNotFoundException |
| 36 | +from utils.exceptions import ( |
| 37 | + PatientNotFoundException, |
| 38 | + PdsHttpErrorException, |
| 39 | + PdsPatientValidationException, |
| 40 | +) |
37 | 41 | from utils.lambda_exceptions import DocumentRefException |
38 | 42 | from utils.lloyd_george_validator import LGInvalidFilesException |
39 | 43 | from utils.request_context import request_context |
@@ -305,7 +309,7 @@ def test_create_document_reference_failed_to_parse_pds_response( |
305 | 309 | mock_getting_patient_info_from_pds, |
306 | 310 | mock_fetch_available_document_references_by_type, |
307 | 311 | ): |
308 | | - mock_getting_patient_info_from_pds.side_effect = LGInvalidFilesException |
| 312 | + mock_getting_patient_info_from_pds.side_effect = PdsPatientValidationException |
309 | 313 |
|
310 | 314 | with pytest.raises(Exception) as exc_info: |
311 | 315 | mock_create_doc_ref_service.create_document_reference_request( |
@@ -344,6 +348,29 @@ def test_cdr_nhs_number_not_found_raises_search_patient_exception( |
344 | 348 | mock_create_document_reference.assert_not_called() |
345 | 349 |
|
346 | 350 |
|
| 351 | +def test_create_document_reference_pds_general_error_throws_exception( |
| 352 | + mock_fhir_doc_ref_base_service, |
| 353 | + mock_create_doc_ref_service, |
| 354 | + mock_create_document_reference, |
| 355 | + mock_getting_patient_info_from_pds, |
| 356 | + mock_fetch_available_document_references_by_type, |
| 357 | +): |
| 358 | + mock_getting_patient_info_from_pds.side_effect = PdsHttpErrorException |
| 359 | + |
| 360 | + with pytest.raises(Exception) as exc_info: |
| 361 | + mock_create_doc_ref_service.create_document_reference_request( |
| 362 | + TEST_NHS_NUMBER, |
| 363 | + LG_FILE_LIST, |
| 364 | + ) |
| 365 | + |
| 366 | + exception = exc_info.value |
| 367 | + assert isinstance(exception, DocumentRefException) |
| 368 | + assert exception.status_code == 400 |
| 369 | + assert exception.message == "Invalid files or id" |
| 370 | + |
| 371 | + mock_create_document_reference.assert_not_called() |
| 372 | + |
| 373 | + |
347 | 374 | def test_cdr_non_pdf_file_raises_exception( |
348 | 375 | mock_fhir_doc_ref_base_service, |
349 | 376 | mock_create_doc_ref_service, |
|
0 commit comments