@@ -34,7 +34,7 @@ class TestValidationResultSet:
34
34
35
35
def test_defaults (self ):
36
36
"""Check defaults."""
37
- df = result .ValidationResultSet (index = ["a" , "b" ])
37
+ df = result .ValidationResultSet (index = ["a" , "b" ], auto_format = True )
38
38
assert df .to_dict () == {
39
39
"is_valid" : {"a" : True , "b" : True },
40
40
"ret_code" : {"a" : 0 , "b" : 0 },
@@ -44,7 +44,7 @@ def test_defaults(self):
44
44
45
45
def test_defaults_with_extra_data (self ):
46
46
"""Check defaults with extra data."""
47
- df = result .ValidationResultSet ({"a" : [1 , 2 ], "b" : [3 , 4 ]})
47
+ df = result .ValidationResultSet ({"a" : [1 , 2 ], "b" : [3 , 4 ]}, auto_format = True )
48
48
assert df .to_dict () == {
49
49
"is_valid" : {0 : True , 1 : True },
50
50
"ret_code" : {0 : 0 , 1 : 0 },
@@ -56,7 +56,7 @@ def test_defaults_with_extra_data(self):
56
56
57
57
def test_default_ret_code (self ):
58
58
"""Check default return code."""
59
- df = result .ValidationResultSet ({"is_valid" : [True , False , True , False ]})
59
+ df = result .ValidationResultSet ({"is_valid" : [True , False , True , False ]}, auto_format = True )
60
60
assert df .to_dict () == {
61
61
"is_valid" : {0 : True , 1 : False , 2 : True , 3 : False },
62
62
"ret_code" : {0 : 0 , 1 : 1 , 2 : 0 , 3 : 1 },
@@ -67,7 +67,9 @@ def test_default_ret_code(self):
67
67
def test_output_columns (self ):
68
68
"""Check output_columns argument."""
69
69
df = result .ValidationResultSet (
70
- index = ["a" , "b" ], output_columns = {"col1" : "val1" , "col2" : "val2" }
70
+ index = ["a" , "b" ],
71
+ output_columns = {"col1" : "val1" , "col2" : "val2" },
72
+ auto_format = True ,
71
73
)
72
74
assert df .to_dict () == {
73
75
"is_valid" : {"a" : True , "b" : True },
@@ -84,6 +86,7 @@ def test_output_columns_with_existing_columns(self):
84
86
{"is_valid" : [True , False ], "col1" : ["test1" , "test2" ]},
85
87
index = ["a" , "b" ],
86
88
output_columns = {"col1" : "val1" , "col2" : "val2" },
89
+ auto_format = True ,
87
90
)
88
91
assert df .to_dict () == {
89
92
"is_valid" : {"a" : True , "b" : False },
@@ -126,9 +129,11 @@ def test_column_order(self):
126
129
{"is_valid" : [True , False ], "col1" : ["test1" , "test2" ]},
127
130
index = ["a" , "b" ],
128
131
output_columns = {"col1" : "val1" , "col2" : "val2" },
132
+ auto_format = True ,
129
133
)
130
134
df_order = result .ValidationResultSet (
131
- pd .DataFrame (df [["col2" , "comment" , "is_valid" , "col1" , "exception" , "ret_code" ]])
135
+ pd .DataFrame (df [["col2" , "comment" , "is_valid" , "col1" , "exception" , "ret_code" ]]),
136
+ auto_format = True ,
132
137
)
133
138
assert df_order .columns .tolist () == [
134
139
"is_valid" ,
@@ -153,7 +158,8 @@ def test_column_order(self):
153
158
"ret_code" ,
154
159
]
155
160
]
156
- )
161
+ ),
162
+ auto_format = True ,
157
163
)
158
164
assert df_order .columns .tolist () == [
159
165
"is_valid" ,
@@ -171,6 +177,7 @@ def test_pandas_method(self):
171
177
{"is_valid" : [True , False ], "col1" : ["test1" , "test2" ]},
172
178
index = ["a" , "b" ],
173
179
output_columns = {"col1" : "val1" , "col2" : "val2" },
180
+ auto_format = True ,
174
181
)
175
182
new_df = result .ValidationResultSet (df )
176
183
assert new_df .apply (lambda x : x .ret_code * 5 , axis = 1 ).to_dict () == {"a" : 0 , "b" : 5 }
0 commit comments