diff --git a/bpx/schema.py b/bpx/schema.py index 228c356..612d87b 100644 --- a/bpx/schema.py +++ b/bpx/schema.py @@ -64,7 +64,8 @@ class Header(ExtraBaseModel): None, alias="Version", example="0.1.1", - description="BPX file version", ) + description="BPX file version", + ) class Cell(ExtraBaseModel): diff --git a/tests/test_schema.py b/tests/test_schema.py index 588ff73..1c686cd 100644 --- a/tests/test_schema.py +++ b/tests/test_schema.py @@ -10,6 +10,7 @@ class TestSchema(unittest.TestCase): def setUp(self): self.base = { "Header": { + "Version": "0.1.1", "BPX": 1.0, "Model": "DFN", }, @@ -216,6 +217,18 @@ def test_bad_model(self): with self.assertRaises(ValidationError): parse_obj_as(BPX, test) + def test_missing_version(self): + test = copy.copy(self.base) + del test["Header"]["Version"] + parsed_obj = parse_obj_as(BPX, test) + self.assertIsNone(parsed_obj.header.version) + + def test_invalid_version(self): + test = copy.copy(self.base) + test["Header"]["Version"] = 123 # Invalid type + with self.assertRaises(ValidationError): + parse_obj_as(BPX, test) + def test_bad_dfn(self): test = copy.copy(self.base_spm) test["Header"]["Model"] = "DFN"