11import os
2+ import copy
23import tempfile
34import urllib
45import urllib .parse
@@ -380,7 +381,13 @@ def test_duplicates_csv_to_sqs_metadata(mocker, bulk_upload_service):
380381
381382 actual = bulk_upload_service .csv_to_sqs_metadata ("fake/path.csv" )
382383
383- expected = EXPECTED_PARSED_METADATA_2
384+ expected = copy .deepcopy (EXPECTED_PARSED_METADATA_2 )
385+ for metadata in expected :
386+ for file in metadata .files :
387+ file .stored_file_name = (
388+ f"test_practice_directory/{ file .stored_file_name .lstrip ('/' )} "
389+ )
390+
384391 assert actual == expected
385392
386393
@@ -436,7 +443,7 @@ def test_clear_temp_storage(set_env, mocker, mock_tempfile, test_service):
436443def test_process_metadata_row_success (mocker , test_service ):
437444 patients = defaultdict (list )
438445 row = {
439- "FILEPATH" : "/ some/path/file.pdf" ,
446+ "FILEPATH" : "some/path/file.pdf" ,
440447 "GP-PRACTICE-CODE" : "Y12345" ,
441448 "NHS-NO" : "1234567890" ,
442449 "PAGE COUNT" : "5" ,
@@ -466,11 +473,11 @@ def test_process_metadata_row_success(mocker, test_service):
466473
467474 expected_sqs_metadata = BulkUploadQueueMetadata .model_validate (
468475 {
469- "file_path" : "/ some/path/file.pdf" ,
476+ "file_path" : "some/path/file.pdf" ,
470477 "nhs_number" : "1234567890" ,
471478 "gp_practice_code" : "Y12345" ,
472479 "scan_date" : "01/01/2023" ,
473- "stored_file_name" : "corrected.pdf" ,
480+ "stored_file_name" : "test_practice_directory/ corrected.pdf" ,
474481 }
475482 )
476483
@@ -485,7 +492,7 @@ def test_process_metadata_row_adds_to_existing_entry(mocker):
485492 "nhs_number" : "1234567890" ,
486493 "gp_practice_code" : "Y12345" ,
487494 "scan_date" : "01/01/2023" ,
488- "stored_file_name" : "/some/path/file1.pdf" ,
495+ "stored_file_name" : "test_practice_directory /some/path/file1.pdf" ,
489496 }
490497 )
491498 patients = {key : [mock_metadata_existing ]}
@@ -524,7 +531,7 @@ def test_process_metadata_row_adds_to_existing_entry(mocker):
524531 assert patients [key ][0 ] == mock_metadata_existing
525532 assert isinstance (patients [key ][1 ], BulkUploadQueueMetadata )
526533 assert patients [key ][1 ].file_path == "/some/path/file2.pdf"
527- assert patients [key ][1 ].stored_file_name == "/some/path/file2.pdf"
534+ assert patients [key ][1 ].stored_file_name == "test_practice_directory /some/path/file2.pdf"
528535
529536
530537def test_extract_patient_info (test_service , base_metadata_file ):
@@ -871,7 +878,7 @@ def test_remapping_mandatory_fields(
871878 file_path = "/path/1.pdf" ,
872879 gp_practice_code = "Y12345" ,
873880 scan_date = "02/01/2023" ,
874- stored_file_name = "/path/1.pdf" ,
881+ stored_file_name = "test_practice_directory /path/1.pdf" ,
875882 )
876883 ],
877884 retries = 0 ,
@@ -941,7 +948,7 @@ def test_no_remapping_logic(
941948 file_path = "/path/1.pdf" ,
942949 gp_practice_code = "Y12345" ,
943950 scan_date = "02/01/2023" ,
944- stored_file_name = "/path/1.pdf" ,
951+ stored_file_name = "test_practice_directory /path/1.pdf" ,
945952 )
946953 ],
947954 retries = 0 ,
0 commit comments