Skip to content

Commit dde6730

Browse files
committed
[test_validation.py] Adapt Test for String Dtype Validation Behavior
Show warning only if all values fit dtype.
1 parent f912971 commit dde6730

File tree

1 file changed

+41
-33
lines changed

1 file changed

+41
-33
lines changed

test/test_validation.py

Lines changed: 41 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -156,48 +156,56 @@ def test_standalone_property(self):
156156
assert not err.is_error
157157

158158
def test_prop_string_values(self):
159-
160159
"""
161-
Test if property values set as dtype string but could be of different dtype raise validation warning.
160+
Test if property values set as dtype string but could be of different dtype
161+
raise validation warning.
162162
"""
163163

164-
prop1 = odml.Property(name='members', dtype="string", values=['-13', '101', '-11', '0', '-8'])
165-
self.assertError(validate(prop1),
166-
'Dtype of property "members" currently is "string", but might fit dtype "int"!')
164+
prop1 = odml.Property(name='members', dtype="string",
165+
values=['-13', '101', '-11', '0', '-8'])
166+
self.assertError(validate(prop1), 'Dtype of property "members" currently is "string",'
167+
' but might fit dtype "int"!')
167168

168-
prop2 = odml.Property(name='potential', dtype="string", values=['-4.8', '10.0', '-11.9', '-10.0', '18.0'])
169-
self.assertError(validate(prop2),
170-
'Dtype of property "potential" currently is "string", but might fit dtype "float"!')
169+
prop2 = odml.Property(name='potential', dtype="string",
170+
values=['-4.8', '10.0', '-11.9', '-10.0', '18.0'])
171+
self.assertError(validate(prop2),'Dtype of property "potential" currently is "string", '
172+
'but might fit dtype "float"!')
171173

172-
prop3 = odml.Property(name='dates', dtype="string", values=['1997-12-14', '00-12-14', '8'])
173-
self.assertError(validate(prop3),
174-
'Dtype of property "dates" currently is "string", but might fit dtype "date"!')
174+
prop3 = odml.Property(name='dates', dtype="string",
175+
values=['1997-12-14', '00-12-14', '89-07-04'])
176+
self.assertError(validate(prop3), 'Dtype of property "dates" currently is "string", '
177+
'but might fit dtype "date"!')
175178

176179
prop4 = odml.Property(name='datetimes', dtype="string",
177-
values=['97-12-14 11:11:11', '97-12-14 12:12', '1997-12-14 03:03'])
178-
self.assertError(validate(prop4),
179-
'Dtype of property "datetimes" currently is "string", but might fit dtype "datetime"!')
180-
181-
prop5 = odml.Property(name='times', dtype="string", values=['11:11:11', '12:12:12', '03:03:03', '8'])
182-
self.assertError(validate(prop5),
183-
'Dtype of property "times" currently is "string", but might fit dtype "time"!')
184-
185-
prop6 = odml.Property(name='sent', dtype="string", values=['False', True, 'TRUE', '0', 't', '12', 'Ft'])
186-
self.assertError(validate(prop6),
187-
'Dtype of property "sent" currently is "string", but might fit dtype "boolean"!')
188-
189-
prop7 = odml.Property(name='texts', dtype="string", values=['line1\n line2', 'line3\n line4', '\nline5\n'])
190-
self.assertError(validate(prop7),
191-
'Dtype of property "texts" currently is "string", but might fit dtype "text"!')
192-
193-
prop8 = odml.Property(name="Location", dtype='string', values=['(39.12; 67.19)', '(39.12; 67.19)', '(39.12)'])
194-
self.assertError(validate(prop8),
195-
'Dtype of property "Location" currently is "string", but might fit dtype "2-tuple"!')
180+
values=['97-12-14 11:11:11', '97-12-14 12:12', '1997-12-14 03:03'])
181+
self.assertError(validate(prop4), 'Dtype of property "datetimes" currently is "string", '
182+
'but might fit dtype "datetime"!')
183+
184+
prop5 = odml.Property(name='times', dtype="string",
185+
values=['11:11:11', '12:12:12', '03:03:03'])
186+
self.assertError(validate(prop5), 'Dtype of property "times" currently is "string", '
187+
'but might fit dtype "time"!')
188+
189+
prop6 = odml.Property(name='sent', dtype="string",
190+
values=['False', True, 'TRUE', False, 't'])
191+
self.assertError(validate(prop6), 'Dtype of property "sent" currently is "string", '
192+
'but might fit dtype "boolean"!')
193+
194+
prop7 = odml.Property(name='texts', dtype="string",
195+
values=['line1\n line2', 'line3\n line4', '\nline5\nline6'])
196+
self.assertError(validate(prop7), 'Dtype of property "texts" currently is "string", '
197+
'but might fit dtype "text"!')
198+
199+
prop8 = odml.Property(name="Location", dtype='string',
200+
values=['(39.12; 67.19)', '(39.12; 67.19)', '(39.12; 67.18)'])
201+
self.assertError(validate(prop8), 'Dtype of property "Location" currently is "string", '
202+
'but might fit dtype "2-tuple"!')
196203

197204
prop9 = odml.Property(name="Coos", dtype='string',
198-
values=['(39.12; 89; 67.19)', '(39.12; 78; 67.19)', '(39.12)'])
199-
self.assertError(validate(prop9),
200-
'Dtype of property "Coos" currently is "string", but might fit dtype "3-tuple"!')
205+
values=['(39.12; 89; 67.19)', '(39.12; 78; 67.19)',
206+
'(39.12; 56; 67.18)'])
207+
self.assertError(validate(prop9), 'Dtype of property "Coos" currently is "string", '
208+
'but might fit dtype "3-tuple"!')
201209

202210
def test_load_xml(self):
203211

0 commit comments

Comments
 (0)