Skip to content

Commit

Permalink
Add support for different file versions and update tests (#63)
Browse files Browse the repository at this point in the history
* Add support for different file versions and update tests

* Add tests

* Missing version Test

---------

Co-authored-by: Robert Timms <43040151+rtimms@users.noreply.github.com>
Co-authored-by: Ubham16 <you@example.com>
  • Loading branch information
3 people authored Jul 9, 2024
1 parent 64c6470 commit 6e24e15
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions bpx/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ class Header(ExtraBaseModel):
description=('Model type ("SPM", "SPMe", "DFN")'),
)

version: str = Field(
None,
alias="Version",
example="0.1.1",
description="BPX file version",
)


class Cell(ExtraBaseModel):
"""
Expand Down
7 changes: 7 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,12 @@ 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_bad_dfn(self):
test = copy.copy(self.base_spm)
test["Header"]["Model"] = "DFN"
Expand Down

0 comments on commit 6e24e15

Please sign in to comment.