|
| 1 | +from services.base.dynamo_service import DynamoDBService |
| 2 | +from tests.e2e.conftest import ( |
| 3 | + LG_METADATA_TABLE , |
| 4 | + LG_UNSTITCHED_TABLE, |
| 5 | + BULK_REPORT_TABLE, |
| 6 | +) |
| 7 | + |
| 8 | +dynamo_service = DynamoDBService() |
| 9 | + |
| 10 | +def test_bulk_upload_300_patients_with_3_files(): |
| 11 | + |
| 12 | + #assert bulk upload report table values |
| 13 | + bulk_upload_table = dynamo_service.scan_whole_table(BULK_REPORT_TABLE, "Reason, UploadStatus, NhsNumber") |
| 14 | + assert len(bulk_upload_table) == 868 |
| 15 | + |
| 16 | + complete_uploads = [] |
| 17 | + failed_uploads = [] |
| 18 | + name_mismatch_rejections = [] |
| 19 | + dob_mismatch_rejections = [] |
| 20 | + |
| 21 | + for item in bulk_upload_table: |
| 22 | + if item.get("UploadStatus") == "complete": |
| 23 | + complete_uploads.append(item) |
| 24 | + elif item.get("UploadStatus") == "failed": |
| 25 | + failed_uploads.append(item) |
| 26 | + if item.get("Reason") == "Patient name does not match our records": |
| 27 | + name_mismatch_rejections.append(item) |
| 28 | + elif item.get("Reason") == "Patient DoB does not match our records": |
| 29 | + dob_mismatch_rejections.append(item) |
| 30 | + |
| 31 | + assert len(complete_uploads) == 765 |
| 32 | + assert len(failed_uploads) == 103 |
| 33 | + assert len(name_mismatch_rejections) == 6 |
| 34 | + assert len(dob_mismatch_rejections) == 27 |
| 35 | + |
| 36 | + #assert lloyd george metadata values, this will also validate the files were stitched |
| 37 | + lg_metadata_table = dynamo_service.scan_whole_table(LG_METADATA_TABLE, "CurrentGpOds, NhsNumber") |
| 38 | + assert len(lg_metadata_table) == 255 |
| 39 | + |
| 40 | + dece_records = [] |
| 41 | + susp_records = [] |
| 42 | + rest_records = [] |
| 43 | + |
| 44 | + for item in lg_metadata_table: |
| 45 | + ods_code = item.get("CurrentGpOds") |
| 46 | + if ods_code == "DECE": |
| 47 | + dece_records.append(item) |
| 48 | + elif ods_code == "SUSP": |
| 49 | + susp_records.append(item) |
| 50 | + elif ods_code == "REST": |
| 51 | + rest_records.append(item) |
| 52 | + |
| 53 | + assert len(dece_records) == 4 |
| 54 | + assert len(susp_records) == 4 |
| 55 | + assert len(rest_records) == 9 |
| 56 | + |
| 57 | + #assert unstitched metadata contains original unstitched files |
| 58 | + lg_unstitched_metadata_table = dynamo_service.scan_whole_table(LG_UNSTITCHED_TABLE, "CurrentGpOds") |
| 59 | + assert len(lg_unstitched_metadata_table) == 765 |
0 commit comments