@@ -617,7 +617,91 @@ def test_detect_required_serializations_fail_fast_binary_inconsistent(self):
617617 tox_runner .detect_required_serializations (fail_fast = True )
618618
619619 self .assertEqual (
620- str (error .exception ), "INCONSISTENT RESOURCE FOLDER BINARY CHECKSUMS"
620+ str (error .exception ), "INCONSISTENT RESOURCE FOLDER CHECKSUMS"
621+ )
622+
623+ def test_detect_required_serializations_fail_fast_source_inconsistent (self ):
624+ mock_resources_folders = {
625+ "custom" : {
626+ "serializer" : "custom" ,
627+ "source_path" : "custom" ,
628+ }
629+ }
630+
631+ with (
632+ mock .patch (
633+ f"{ self .MODULE_NAME } .RESOURCES_FOLDERS" ,
634+ mock_resources_folders ,
635+ ),
636+ mock .patch (
637+ f"{ self .MODULE_NAME } .fetch_resources_subfolder_files"
638+ ) as mock_resources_files ,
639+ mock .patch (self .COMPUTE_CHECKSUM_FUNCTION ) as mocked_checksum ,
640+ mock .patch (
641+ f"{ self .MODULE_NAME } .fetch_binary_files_for_folder"
642+ ) as mock_binary_files ,
643+ mock .patch (
644+ f"{ self .MODULE_NAME } .read_previous_folder_checksum"
645+ ) as mock_read_checksum ,
646+ ):
647+ mock_resources_files .return_value = [os .path .join ("custom" , "test.pyi" )]
648+ mock_binary_files .return_value = [os .path .join ("custom_protobuf" , "test.protobuf" )]
649+ mocked_checksum .side_effect = [
650+ "456" ,
651+ "123" ,
652+ ]
653+ mock_read_checksum .return_value = (
654+ "999" ,
655+ "123" ,
656+ )
657+
658+ with self .assertRaises (RuntimeError ) as error :
659+ tox_runner .detect_required_serializations (fail_fast = True )
660+
661+ self .assertEqual (
662+ str (error .exception ), "INCONSISTENT RESOURCE FOLDER CHECKSUMS"
663+ )
664+
665+ def test_detect_required_serializations_fail_fast_source_and_binary_inconsistent (self ):
666+ mock_resources_folders = {
667+ "custom" : {
668+ "serializer" : "custom" ,
669+ "source_path" : "custom" ,
670+ }
671+ }
672+
673+ with (
674+ mock .patch (
675+ f"{ self .MODULE_NAME } .RESOURCES_FOLDERS" ,
676+ mock_resources_folders ,
677+ ),
678+ mock .patch (
679+ f"{ self .MODULE_NAME } .fetch_resources_subfolder_files"
680+ ) as mock_resources_files ,
681+ mock .patch (self .COMPUTE_CHECKSUM_FUNCTION ) as mocked_checksum ,
682+ mock .patch (
683+ f"{ self .MODULE_NAME } .fetch_binary_files_for_folder"
684+ ) as mock_binary_files ,
685+ mock .patch (
686+ f"{ self .MODULE_NAME } .read_previous_folder_checksum"
687+ ) as mock_read_checksum ,
688+ ):
689+ mock_resources_files .return_value = [os .path .join ("custom" , "test.pyi" )]
690+ mock_binary_files .return_value = [os .path .join ("custom_protobuf" , "test.protobuf" )]
691+ mocked_checksum .side_effect = [
692+ "456" ,
693+ "789" ,
694+ ]
695+ mock_read_checksum .return_value = (
696+ "999" ,
697+ "123" ,
698+ )
699+
700+ with self .assertRaises (RuntimeError ) as error :
701+ tox_runner .detect_required_serializations (fail_fast = True )
702+
703+ self .assertEqual (
704+ str (error .exception ), "INCONSISTENT RESOURCE FOLDER CHECKSUMS"
621705 )
622706
623707 def test_detect_required_serializations_no_fail_fast_binary_inconsistent (self ):
@@ -665,8 +749,46 @@ def test_detect_required_serializations_no_fail_fast_binary_inconsistent(self):
665749 result = tox_runner .detect_required_serializations (fail_fast = False )
666750 self .assertEqual (result , ["custom" ])
667751
668- def test_main_fail_fast_resource_folder_binary_inconsistent (self ):
669- # Test main function fail-fast when resource folder has binary inconsistency
752+ def test_detect_required_serializations_no_fail_fast_source_and_binary_inconsistent (self ):
753+ mock_resources_folders = {
754+ "custom" : {
755+ "serializer" : "custom" ,
756+ "source_path" : "custom" ,
757+ }
758+ }
759+
760+ with (
761+ mock .patch (
762+ f"{ self .MODULE_NAME } .RESOURCES_FOLDERS" ,
763+ mock_resources_folders ,
764+ ),
765+ mock .patch (
766+ f"{ self .MODULE_NAME } .fetch_resources_subfolder_files"
767+ ) as mock_resources_files ,
768+ mock .patch (self .COMPUTE_CHECKSUM_FUNCTION ) as mocked_checksum ,
769+ mock .patch (
770+ f"{ self .MODULE_NAME } .fetch_binary_files_for_folder"
771+ ) as mock_binary_files ,
772+ mock .patch (
773+ f"{ self .MODULE_NAME } .read_previous_folder_checksum"
774+ ) as mock_read_checksum ,
775+ ):
776+ mock_resources_files .return_value = [os .path .join ("custom" , "test.pyi" )]
777+ mock_binary_files .return_value = [os .path .join ("custom_protobuf" , "test.protobuf" )]
778+ mocked_checksum .side_effect = [
779+ "456" ,
780+ "789" ,
781+ ]
782+ mock_read_checksum .return_value = (
783+ "999" ,
784+ "123" ,
785+ )
786+
787+ result = tox_runner .detect_required_serializations (fail_fast = False )
788+ self .assertEqual (result , ["custom" ])
789+
790+ def test_main_fail_fast_resource_folder_checksum_inconsistent (self ):
791+ # Test main function fail-fast when resource folder checksums are inconsistent
670792 source_checksum = "123"
671793
672794 with (
@@ -687,15 +809,15 @@ def test_main_fail_fast_resource_folder_binary_inconsistent(self):
687809
688810 # Resource folder check raises RuntimeError
689811 mock_check_changes .side_effect = RuntimeError (
690- "INCONSISTENT RESOURCE FOLDER BINARY CHECKSUMS"
812+ "INCONSISTENT RESOURCE FOLDER CHECKSUMS"
691813 )
692814
693815 # Should propagate the RuntimeError
694816 with self .assertRaises (RuntimeError ) as error :
695817 tox_runner .main (fail_fast = True )
696818
697819 self .assertEqual (
698- str (error .exception ), "INCONSISTENT RESOURCE FOLDER BINARY CHECKSUMS"
820+ str (error .exception ), "INCONSISTENT RESOURCE FOLDER CHECKSUMS"
699821 )
700822 # Should not call subprocess
701823 mocked_subprocess .run .assert_not_called ()
@@ -891,4 +1013,3 @@ def test_compute_and_compare_checksums_unchanged(self):
8911013
8921014 self .assertFalse (result )
8931015 mock_logger .info .assert_any_call ('BINARY FILES UNCHANGED in folder: importer - Computed over 2 files - Checksum: same_checksum' )
894-
0 commit comments