@@ -22,26 +22,85 @@ def test_model_fix_json_nested(self, list_operation_for_response_test):
2222 ]
2323
2424 def test_attr_get_value (self , list_operation_for_response_test ):
25- model = {"foo" : {"bar" : "cool" }}
25+ model = {"data" : { " foo" : {"bar" : "cool" } }}
2626 attr = list_operation_for_response_test .response_model .attrs [0 ]
2727
2828 result = attr ._get_value (model )
2929
3030 assert result == "cool"
3131
3232 def test_attr_get_string (self , list_operation_for_response_test ):
33- model = {"foo" : {"bar" : ["cool1" , "cool2" ]}}
33+ model = {"data" : { " foo" : {"bar" : ["cool1" , "cool2" ]} }}
3434 attr = list_operation_for_response_test .response_model .attrs [0 ]
3535
3636 result = attr .get_string (model )
3737
3838 assert result == "cool1 cool2"
3939
4040 def test_attr_render_value (self , list_operation_for_response_test ):
41- model = {"foo" : {"bar" : ["cool1" , "cool2" ]}}
41+ model = {"data" : { " foo" : {"bar" : ["cool1" , "cool2" ]} }}
4242 attr = list_operation_for_response_test .response_model .attrs [0 ]
4343 attr .color_map = {"default_" : "yellow" }
4444
4545 result = attr .render_value (model )
4646
4747 assert result == "[yellow]cool1, cool2[/]"
48+
49+ def test_fix_json_string_type (self , list_operation_for_response_test ):
50+ model = list_operation_for_response_test .response_model
51+ model .rows = ["foo.bar" , "type" ]
52+
53+ input_json = {"foo" : {"bar" : "string_value" }, "type" : "example_type" }
54+ result = model .fix_json (input_json )
55+
56+ assert result == ["string_value" , "example_type" ]
57+
58+ def test_fix_json_integer_type (self , list_operation_for_response_test ):
59+ model = list_operation_for_response_test .response_model
60+ model .rows = ["size" , "id" ]
61+
62+ input_json = {"size" : 42 , "id" : 123 }
63+ result = model .fix_json (input_json )
64+
65+ assert result == [42 , 123 ]
66+
67+ def test_dictionary_like_property (self , list_operation_for_response_test ):
68+ model = list_operation_for_response_test .response_model
69+
70+ model .rows = ["dictLike" ]
71+
72+ input_data = {"dictLike" : {"keyA" : "valueA" , "keyB" : "valueB" }}
73+
74+ result = model .fix_json (input_data )
75+ assert result == [{"keyA" : "valueA" , "keyB" : "valueB" }]
76+
77+ def test_standard_object_property (self , list_operation_for_response_test ):
78+ model = list_operation_for_response_test .response_model
79+
80+ # Set rows to include the standard object
81+ model .rows = ["standard" ]
82+
83+ # Simulate input data
84+ input_data = {"standard" : {"key1" : "test" , "key2" : 42 }}
85+
86+ result = model .fix_json (input_data )
87+ assert result == [{"key1" : "test" , "key2" : 42 }]
88+
89+ def test_array_of_objects_property (self , list_operation_for_response_test ):
90+ model = list_operation_for_response_test .response_model
91+
92+ model .rows = ["objectArray" ]
93+
94+ # Simulate input data
95+ input_data = {
96+ "objectArray" : [
97+ {"subkey1" : "item1" , "subkey2" : True },
98+ {"subkey1" : "item2" , "subkey2" : False },
99+ ]
100+ }
101+
102+ result = model .fix_json (input_data )
103+ assert result == [
104+ {"subkey1" : "item1" , "subkey2" : True },
105+ {"subkey1" : "item2" , "subkey2" : False },
106+ ]
0 commit comments