@@ -1040,18 +1040,20 @@ def test_to_lower_case(self, input_list, expected_output):
10401040 assert actual_output == expected_output
10411041
10421042 @pytest .mark .parametrize (
1043- "dictionary, expected_result, unboxing_func, is_dict" ,
1043+ "dictionary, expected_result, unboxing_func, is_array, is_dict" ,
10441044 [
1045- ({}, {}, lambda x : int (x ), False ),
1046- ({"a" : 1 , "b" : 2 }, {"a" : 1 , "b" : 2 }, lambda x : int (x ), False ),
1047- ({"a" : "1" , "b" : "2" }, {"a" : "1" , "b" : "2" }, lambda x : str (x ), False ),
1048- ({"a" : "Test 1" , "b" : "Test 2" }, {}, lambda x : int (x ), False ),
1049- ({"a" : [1 , 2 ], "b" : [3 , 4 ]}, {"a" : [1 , 2 ], "b" : [3 , 4 ]}, lambda x : int (x ), False ),
1050- ({"a" : {"x" : 1 , "y" : 2 }, "b" : {"x" : 3 , "y" : 4 }}, {"a" : {"x" : 1 , "y" : 2 }, "b" : {"x" : 3 , "y" : 4 }}, lambda x : int (x ), True ),
1045+ ({}, {}, lambda x : int (x ), False , False ),
1046+ ({"a" : 1 , "b" : 2 }, {"a" : 1 , "b" : 2 }, lambda x : int (x ), False , False ),
1047+ ({"a" : "1" , "b" : "2" }, {"a" : "1" , "b" : "2" }, lambda x : str (x ), False , False ),
1048+ ({"a" : "Test 1" , "b" : "Test 2" }, {}, lambda x : int (x ), False , False ),
1049+ ({"a" : [1 , 2 ], "b" : [3 , 4 ]}, {"a" : [1 , 2 ], "b" : [3 , 4 ]}, lambda x : int (x ), True , False ),
1050+ ({"a" : {"x" : 1 , "y" : 2 }, "b" : {"x" : 3 , "y" : 4 }}, {"a" : {"x" : 1 , "y" : 2 }, "b" : {"x" : 3 , "y" : 4 }}, lambda x : int (x ), False , True ),
10511051 ],
10521052 )
1053- def test_get_additional_properties_success (self , dictionary , expected_result , unboxing_func , is_dict ):
1054- result = ApiHelper .get_additional_properties (dictionary , lambda x : ApiHelper .apply_unboxing_function (x , unboxing_func , is_dict ))
1053+ def test_get_additional_properties_success (self , dictionary , expected_result , unboxing_func , is_array , is_dict ):
1054+ result = ApiHelper .get_additional_properties (
1055+ dictionary , lambda x : ApiHelper .apply_unboxing_function (
1056+ x , unboxing_func , is_array , is_dict ))
10551057 assert result == expected_result
10561058
10571059 @pytest .mark .parametrize (
@@ -1063,4 +1065,30 @@ def test_get_additional_properties_success(self, dictionary, expected_result, un
10631065 )
10641066 def test_get_additional_properties_exception (self , dictionary ):
10651067 result = ApiHelper .get_additional_properties (dictionary , ApiHelper .apply_unboxing_function )
1066- assert result == {} # expected result when exception occurs
1068+ assert result == {} # expected result when exception occurs
1069+
1070+ @pytest .mark .parametrize (
1071+ "value, unboxing_function, is_array, is_dict, is_array_of_map, is_map_of_array, expected" ,
1072+ [
1073+ # Test case 1: Simple object
1074+ (5 , lambda x : x * 2 , False , False , False , False , 10 ),
1075+ # Test case 2: Array
1076+ ([1 , 2 , 3 ], lambda x : x * 2 , True , False , False , False , [2 , 4 , 6 ]),
1077+ # Test case 3: Dictionary
1078+ ({"a" : 1 , "b" : 2 }, lambda x : x * 2 , False , True , False , False , {"a" : 2 , "b" : 4 }),
1079+ # Test case 4: Array of maps
1080+ ([{"a" : 1 }, {"b" : 2 }], lambda x : x * 2 , True , False , True , False , [{"a" : 2 }, {"b" : 4 }]),
1081+ # Test case 5: Map of arrays
1082+ ({"a" : [1 , 2 ], "b" : [3 , 4 ]}, lambda x : x * 2 , False , True , False , True , {"a" : [2 , 4 ], "b" : [6 , 8 ]}),
1083+ ],
1084+ )
1085+ def test_apply_unboxing_function (self , value , unboxing_function , is_array , is_dict ,
1086+ is_array_of_map , is_map_of_array , expected ):
1087+ result = ApiHelper .apply_unboxing_function (
1088+ value ,
1089+ unboxing_function ,
1090+ is_array ,
1091+ is_dict ,
1092+ is_array_of_map ,
1093+ is_map_of_array )
1094+ assert result == expected
0 commit comments