Skip to content

Commit 3e5aaa7

Browse files
committed
[test_validation.py] Add Test for JSON File Validation
1 parent d062f52 commit 3e5aaa7

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/test_validation.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,3 +224,31 @@ def test_load_xml(self):
224224
'Dtype of property "Location" currently is "string", but might fit dtype "2-tuple"!')
225225
self.assertError(validate(doc),
226226
'Dtype of property "Coos" currently is "string", but might fit dtype "3-tuple"!')
227+
228+
def test_load_json(self):
229+
230+
"""
231+
Test if loading json document raises validation errors. Errors are:
232+
233+
- Undefined Section type
234+
- Properties with undefined dtypes
235+
"""
236+
237+
doc = odml.load("./resources/integration.json", "JSON")
238+
239+
self.assertError(validate(doc), "Section type undefined")
240+
241+
self.assertError(validate(doc), 'Dtype of property "members" currently is "string", but might fit dtype "int"!')
242+
self.assertError(validate(doc),
243+
'Dtype of property "potential" currently is "string", but might fit dtype "float"!')
244+
self.assertError(validate(doc), 'Dtype of property "dates" currently is "string", but might fit dtype "date"!')
245+
self.assertError(validate(doc),
246+
'Dtype of property "datetimes" currently is "string", but might fit dtype "datetime"!')
247+
self.assertError(validate(doc), 'Dtype of property "times" currently is "string", but might fit dtype "time"!')
248+
self.assertError(validate(doc),
249+
'Dtype of property "sent" currently is "string", but might fit dtype "boolean"!')
250+
self.assertError(validate(doc), 'Dtype of property "texts" currently is "string", but might fit dtype "text"!')
251+
self.assertError(validate(doc),
252+
'Dtype of property "Location" currently is "string", but might fit dtype "2-tuple"!')
253+
self.assertError(validate(doc),
254+
'Dtype of property "Coos" currently is "string", but might fit dtype "3-tuple"!')

0 commit comments

Comments
 (0)