|
46 | 46 | BulkUploadException, |
47 | 47 | DocumentInfectedException, |
48 | 48 | InvalidMessageException, |
| 49 | + PatientNotFoundException, |
49 | 50 | PatientRecordAlreadyExistException, |
50 | 51 | PdsTooManyRequestsException, |
51 | 52 | S3FileNotFoundException, |
@@ -1069,3 +1070,25 @@ def test_concatenate_acceptance_reason(repo_under_test): |
1069 | 1070 | actual_reason, another_test_reason |
1070 | 1071 | ) |
1071 | 1072 | assert another_actual_reason == test_reason + ", " + another_test_reason |
| 1073 | + |
| 1074 | + |
| 1075 | +def test_patient_not_found_is_caught_and_written_to_dynamo( |
| 1076 | + repo_under_test, mock_validate_files, mocker |
| 1077 | +): |
| 1078 | + expected_error_message = "Could not find the given patient on PDS" |
| 1079 | + mocker.patch( |
| 1080 | + "services.bulk_upload_service.getting_patient_info_from_pds", |
| 1081 | + side_effect=PatientNotFoundException(expected_error_message), |
| 1082 | + ) |
| 1083 | + |
| 1084 | + repo_under_test.handle_sqs_message(message=TEST_SQS_MESSAGE) |
| 1085 | + |
| 1086 | + repo_under_test.dynamo_repository.write_report_upload_to_dynamo.assert_called_once() |
| 1087 | + |
| 1088 | + call_metadata, call_status, call_reason, call_ods_code = ( |
| 1089 | + repo_under_test.dynamo_repository.write_report_upload_to_dynamo.call_args[0] |
| 1090 | + ) |
| 1091 | + |
| 1092 | + assert call_status == UploadStatus.FAILED |
| 1093 | + assert call_reason == expected_error_message |
| 1094 | + assert call_metadata == TEST_STAGING_METADATA |
0 commit comments