@@ -224,3 +224,31 @@ def test_load_xml(self):
224
224
'Dtype of property "Location" currently is "string", but might fit dtype "2-tuple"!' )
225
225
self .assertError (validate (doc ),
226
226
'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