Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubham16 committed Jul 9, 2024
1 parent 44036a6 commit 0de8c3a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion bpx/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
13 changes: 13 additions & 0 deletions tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class TestSchema(unittest.TestCase):
def setUp(self):
self.base = {
"Header": {
"Version": "0.1.1",
"BPX": 1.0,
"Model": "DFN",
},
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 0de8c3a

Please sign in to comment.