Skip to content

Commit 30892b4

Browse files
committed
[test_validation.py] Add Test for YAML File Validation
1 parent 43b4941 commit 30892b4

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
@@ -252,3 +252,31 @@ def test_load_json(self):
252252
'Dtype of property "Location" currently is "string", but might fit dtype "2-tuple"!')
253253
self.assertError(validate(doc),
254254
'Dtype of property "Coos" currently is "string", but might fit dtype "3-tuple"!')
255+
256+
def test_load_yaml(self):
257+
258+
"""
259+
Test if loading yaml document raises validation errors. Errors are:
260+
261+
- Undefined Section type
262+
- Properties with undefined dtypes
263+
"""
264+
265+
doc = odml.load("./resources/integration.yaml", "YAML")
266+
267+
self.assertError(validate(doc), "Section type undefined")
268+
269+
self.assertError(validate(doc), 'Dtype of property "members" currently is "string", but might fit dtype "int"!')
270+
self.assertError(validate(doc),
271+
'Dtype of property "potential" currently is "string", but might fit dtype "float"!')
272+
self.assertError(validate(doc), 'Dtype of property "dates" currently is "string", but might fit dtype "date"!')
273+
self.assertError(validate(doc),
274+
'Dtype of property "datetimes" currently is "string", but might fit dtype "datetime"!')
275+
self.assertError(validate(doc), 'Dtype of property "times" currently is "string", but might fit dtype "time"!')
276+
self.assertError(validate(doc),
277+
'Dtype of property "sent" currently is "string", but might fit dtype "boolean"!')
278+
self.assertError(validate(doc), 'Dtype of property "texts" currently is "string", but might fit dtype "text"!')
279+
self.assertError(validate(doc),
280+
'Dtype of property "Location" currently is "string", but might fit dtype "2-tuple"!')
281+
self.assertError(validate(doc),
282+
'Dtype of property "Coos" currently is "string", but might fit dtype "3-tuple"!')

0 commit comments

Comments
 (0)