Skip to content

Commit 719e6fb

Browse files
committed
[test_validation.py] Add Test for JSON File Loading Sections
- Replace part of current JSON File Loading Test - Incorporate file at resources/validation_section.json
1 parent 3c78947 commit 719e6fb

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

test/test_validation.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -290,28 +290,25 @@ def test_load_dtypes_xml(self):
290290
self.assertError(validate(doc), 'Dtype of property "Coos_mislabelled" currently is '
291291
'"string", but might fit dtype "3-tuple"!')
292292

293-
294-
295-
296-
- Undefined Section type
297-
- Properties with undefined dtypes
293+
def test_load_section_json(self):
294+
"""
295+
Test if loading json document raises validation errors for Sections with undefined type.
298296
"""
299297

300-
dir_path = os.path.dirname(os.path.realpath(__file__))
301-
path = os.path.join(dir_path, "resources", "integration.json")
298+
path = os.path.join(self.dir_path, "resources", "validation_section.json")
302299
doc = odml.load(path, "JSON")
303300

304-
sec_test_1_err = False
305-
sec_test_2_err = False
301+
sec_type_undefined_err = False
302+
sec_type_empty_err = False
306303

307304
for err in validate(doc).errors:
308-
if err.msg == "Section type undefined" and err.obj.name == "sec_test_1":
309-
sec_test_1_err = True
310-
elif err.msg == "Section type undefined" and err.obj.name == "sec_test_2":
311-
sec_test_2_err = True
305+
if err.msg == "Section type undefined" and err.obj.name == "sec_type_undefined":
306+
sec_type_undefined_err = True
307+
elif err.msg == "Section type undefined" and err.obj.name == "sec_type_empty":
308+
sec_type_empty_err = True
312309

313-
assert sec_test_1_err
314-
assert sec_test_2_err
310+
assert sec_type_undefined_err
311+
assert sec_type_empty_err
315312

316313
self.assertError(validate(doc), 'Dtype of property "members" currently is "string", but might fit dtype "int"!')
317314
self.assertError(validate(doc),

0 commit comments

Comments
 (0)