@@ -243,7 +243,7 @@ def test_resolve_schema_information_case_1(
243243 )
244244 self .assertEqual (dict (), docdb_fields_to_update )
245245 mock_write_file_with_record_info .assert_called_once_with (
246- docdb_record = self .example_md_record .get ("subject" ),
246+ docdb_record_contents = self .example_md_record .get ("subject" ),
247247 s3_client = mock_s3_client ,
248248 prefix = "ecephys_642478_2023-01-17_13-56-29" ,
249249 core_schema_file_name = "subject.json" ,
@@ -316,7 +316,7 @@ def test_resolve_schema_information_case_2(
316316 ),
317317 )
318318 mock_write_file_with_record_info .assert_called_once_with (
319- docdb_record = self .example_md_record .get ("subject" ),
319+ docdb_record_contents = self .example_md_record .get ("subject" ),
320320 s3_client = mock_s3_client ,
321321 prefix = "ecephys_642478_2023-01-17_13-56-29" ,
322322 core_schema_file_name = "subject.json" ,
@@ -373,7 +373,7 @@ def test_resolve_schema_information_case_3(
373373 self .assertEqual (dict (), docdb_fields_to_update )
374374 mock_copy_file_to_subdir .assert_not_called ()
375375 mock_write_file_with_record_info .assert_called_once_with (
376- docdb_record = self .example_md_record .get ("subject" ),
376+ docdb_record_contents = self .example_md_record .get ("subject" ),
377377 s3_client = mock_s3_client ,
378378 prefix = "ecephys_642478_2023-01-17_13-56-29" ,
379379 core_schema_file_name = "subject.json" ,
@@ -400,12 +400,14 @@ def test_resolve_schema_information_case_3(
400400 "aind_data_asset_indexer.aind_bucket_indexer.AindIndexBucketJob."
401401 "_write_root_file_with_record_info"
402402 )
403+ @patch ("aind_data_asset_indexer.aind_bucket_indexer.get_dict_of_file_info" )
403404 @patch (
404405 "aind_data_asset_indexer.aind_bucket_indexer.core_schema_file_names" ,
405406 ["subject.json" ],
406407 ) # Mocking this to limit for loop to one iteration
407408 def test_resolve_schema_information_case_4 (
408409 self ,
410+ mock_get_dict_of_file_info : MagicMock ,
409411 mock_write_file_with_record_info : MagicMock ,
410412 mock_copy_file_to_subdir : MagicMock ,
411413 mock_download_json_file : MagicMock ,
@@ -420,6 +422,18 @@ def test_resolve_schema_information_case_4(
420422 """
421423
422424 core_schema_info_in_root = dict ()
425+ core_schema_info_in_root_after_copy = {
426+ "ecephys_642478_2023-01-17_13-56-29/subject.json" : {
427+ "last_modified" : datetime (
428+ 2024 , 5 , 15 , 17 , 41 , 28 , tzinfo = timezone .utc
429+ ),
430+ "e_tag" : '"7ce612b2f26be2efe806990cb4eb4266"' ,
431+ "version_id" : "version_id" ,
432+ }
433+ }
434+ mock_get_dict_of_file_info .return_value = (
435+ core_schema_info_in_root_after_copy
436+ )
423437 docdb_fields_to_update = self .basic_job ._resolve_schema_information (
424438 prefix = "ecephys_642478_2023-01-17_13-56-29" ,
425439 s3_client = mock_s3_client ,
@@ -429,20 +443,25 @@ def test_resolve_schema_information_case_4(
429443 )
430444 self .assertEqual (dict (), docdb_fields_to_update )
431445 mock_write_file_with_record_info .assert_called_once_with (
432- docdb_record = self .example_md_record .get ("subject" ),
446+ docdb_record_contents = self .example_md_record .get ("subject" ),
433447 s3_client = mock_s3_client ,
434448 prefix = "ecephys_642478_2023-01-17_13-56-29" ,
435449 core_schema_file_name = "subject.json" ,
436450 core_schema_info_in_root = core_schema_info_in_root .get (
437451 "subject.json"
438452 ),
439453 )
454+ mock_get_dict_of_file_info .assert_called_once_with (
455+ s3_client = mock_s3_client ,
456+ bucket = self .basic_job .job_settings .s3_bucket ,
457+ keys = ["ecephys_642478_2023-01-17_13-56-29/subject.json" ],
458+ )
440459 mock_copy_file_to_subdir .assert_called_once_with (
441460 s3_client = mock_s3_client ,
442461 prefix = "ecephys_642478_2023-01-17_13-56-29" ,
443462 core_schema_file_name = "subject.json" ,
444- core_schema_info_in_root = core_schema_info_in_root .get (
445- "subject.json"
463+ core_schema_info_in_root = core_schema_info_in_root_after_copy .get (
464+ "ecephys_642478_2023-01-17_13-56-29/ subject.json"
446465 ),
447466 )
448467 mock_download_json_file .assert_not_called ()
@@ -643,13 +662,17 @@ def test_resolve_schema_information_case_6_corrupt_download(
643662 "subject.json"
644663 ),
645664 )
646- mock_log_debug .assert_not_called ()
647665 mock_log_info .assert_not_called ()
648666 mock_log_warn .assert_called_once_with (
649667 "Something went wrong downloading or parsing "
650668 "s3://aind-ephys-data-dev-u5u0i5/"
651669 "ecephys_642478_2023-01-17_13-56-29/subject.json"
652670 )
671+ mock_s3_client .delete_object .assert_called_once_with (
672+ Bucket = "aind-ephys-data-dev-u5u0i5" ,
673+ Key = "ecephys_642478_2023-01-17_13-56-29/subject.json" ,
674+ )
675+ mock_log_debug .assert_called_once ()
653676
654677 @patch ("boto3.client" )
655678 @patch ("logging.debug" )
0 commit comments