Skip to content

Commit 2488ceb

Browse files
committed
[test_validation.py] Add Test for JSON File Loading Property Dtypes
- Replace current JSON File Loading Test - Incorporate file at resources/validation_dtypes.json
1 parent 719e6fb commit 2488ceb

File tree

1 file changed

+59
-17
lines changed

1 file changed

+59
-17
lines changed

test/test_validation.py

Lines changed: 59 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -310,25 +310,67 @@ def test_load_section_json(self):
310310
assert sec_type_undefined_err
311311
assert sec_type_empty_err
312312

313-
self.assertError(validate(doc), 'Dtype of property "members" currently is "string", but might fit dtype "int"!')
314-
self.assertError(validate(doc),
315-
'Dtype of property "potential" currently is "string", but might fit dtype "float"!')
316-
self.assertError(validate(doc), 'Dtype of property "dates" currently is "string", but might fit dtype "date"!')
317-
self.assertError(validate(doc),
318-
'Dtype of property "datetimes" currently is "string", but might fit dtype "datetime"!')
319-
self.assertError(validate(doc), 'Dtype of property "times" currently is "string", but might fit dtype "time"!')
320-
self.assertError(validate(doc),
321-
'Dtype of property "sent" currently is "string", but might fit dtype "boolean"!')
322-
self.assertError(validate(doc), 'Dtype of property "texts" currently is "string", but might fit dtype "text"!')
323-
self.assertError(validate(doc),
324-
'Dtype of property "Location" currently is "string", but might fit dtype "2-tuple"!')
325-
self.assertError(validate(doc),
326-
'Dtype of property "Coos" currently is "string", but might fit dtype "3-tuple"!')
313+
def test_load_dtypes_json(self):
314+
"""
315+
Test if loading json document raises validation errors for Properties with undefined dtypes.
316+
"""
317+
318+
path = os.path.join(self.dir_path, "resources", "validation_dtypes.json")
319+
doc = odml.load(path, "JSON")
320+
321+
self.assertError(validate(doc), 'Dtype of property "members_no" currently is "string", '
322+
'but might fit dtype "int"!')
323+
324+
self.assertError(validate(doc), 'Dtype of property "potential_no" currently is "string", '
325+
'but might fit dtype "float"!')
326+
327+
self.assertError(validate(doc), 'Dtype of property "dates_no" currently is "string", '
328+
'but might fit dtype "date"!')
329+
330+
self.assertError(validate(doc), 'Dtype of property "datetimes_no" currently is "string", '
331+
'but might fit dtype "datetime"!')
332+
333+
self.assertError(validate(doc), 'Dtype of property "times_no" currently is "string", '
334+
'but might fit dtype "time"!')
335+
336+
self.assertError(validate(doc), 'Dtype of property "sent_no" currently is "string", '
337+
'but might fit dtype "boolean"!')
338+
339+
self.assertError(validate(doc), 'Dtype of property "Location_no" currently is "string", '
340+
'but might fit dtype "2-tuple"!')
341+
342+
self.assertError(validate(doc), 'Dtype of property "Coos_no" currently is "string", '
343+
'but might fit dtype "3-tuple"!')
344+
345+
self.assertError(validate(doc), 'Dtype of property "members_mislabelled" currently is '
346+
'"string", but might fit dtype "int"!')
347+
348+
self.assertError(validate(doc), 'Dtype of property "potential_mislabelled" currently is '
349+
'"string", but might fit dtype "float"!')
350+
351+
self.assertError(validate(doc), 'Dtype of property "dates_mislabelled" currently is '
352+
'"string", but might fit dtype "date"!')
353+
354+
self.assertError(validate(doc), 'Dtype of property "datetimes_mislabelled" currently is '
355+
'"string", but might fit dtype "datetime"!')
356+
357+
self.assertError(validate(doc), 'Dtype of property "times_mislabelled" currently is '
358+
'"string", but might fit dtype "time"!')
359+
360+
self.assertError(validate(doc), 'Dtype of property "sent_mislabelled" currently is '
361+
'"string", but might fit dtype "boolean"!')
362+
363+
self.assertError(validate(doc), 'Dtype of property "texts_mislabelled" currently is '
364+
'"string", but might fit dtype "text"!')
365+
366+
self.assertError(validate(doc), 'Dtype of property "Location_mislabelled" currently is '
367+
'"string", but might fit dtype "2-tuple"!')
368+
369+
self.assertError(validate(doc), 'Dtype of property "Coos_mislabelled" currently is '
370+
'"string", but might fit dtype "3-tuple"!')
371+
327372

328-
def test_load_yaml(self):
329373

330-
"""
331-
Test if loading yaml document raises validation errors. Errors are:
332374

333375
- Undefined Section type
334376
- Properties with undefined dtypes

0 commit comments

Comments
 (0)