Skip to content

Commit f85ffe6

Browse files
committed
[test_validation.py] Add Test for YAML File Loading Sections
- Replace part of current YAML File Loading Test - Incorporate file at resources/validation_section.yaml
1 parent 976b10b commit f85ffe6

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

test/test_validation.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -369,25 +369,28 @@ def test_load_dtypes_json(self):
369369
self.assertError(validate(doc), 'Dtype of property "Coos_mislabelled" currently is '
370370
'"string", but might fit dtype "3-tuple"!')
371371

372-
373-
374-
375-
- Undefined Section type
376-
- Properties with undefined dtypes
372+
def test_load_section_yaml(self):
373+
"""
374+
Test if loading yaml document raises validation errors for Sections with undefined type.
377375
"""
378376

379-
dir_path = os.path.dirname(os.path.realpath(__file__))
380-
path = os.path.join(dir_path, "resources", "integration.yaml")
377+
path = os.path.join(self.dir_path, "resources", "validation_section.yaml")
381378
doc = odml.load(path, "YAML")
382379

383-
sec_test_1_err = False
384-
sec_test_2_err = False
380+
sec_type_undefined_err = False
381+
sec_type_empty_err = False
385382

386383
for err in validate(doc).errors:
387-
if err.msg == "Section type undefined" and err.obj.name == "sec_test_1":
388-
sec_test_1_err = True
389-
elif err.msg == "Section type undefined" and err.obj.name == "sec_test_2":
390-
sec_test_2_err = True
384+
if err.msg == "Section type undefined" and err.obj.name == "sec_type_undefined":
385+
sec_type_undefined_err = True
386+
elif err.msg == "Section type undefined" and err.obj.name == "sec_type_empty":
387+
sec_type_empty_err = True
388+
389+
assert sec_type_undefined_err
390+
assert sec_type_empty_err
391+
392+
393+
391394

392395
assert sec_test_1_err
393396
assert sec_test_2_err

0 commit comments

Comments
 (0)