-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
32 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"""Tests related to pynwb.io.utils.""" | ||
import pytest | ||
|
||
from hdmf.build import GroupBuilder | ||
from pynwb.io.utils import get_nwb_version | ||
from pynwb.testing import TestCase | ||
|
||
|
||
class TestGetNWBVersion(TestCase): | ||
|
||
def test_get_nwb_version(self): | ||
"""Get the NWB version from a builder.""" | ||
builder1 = GroupBuilder(name="root") | ||
builder1.set_attribute(name="nwb_version", value="2.0.0") | ||
builder2 = GroupBuilder(name="another") | ||
builder1.set_group(builder2) | ||
assert get_nwb_version(builder1) == (2, 0, 0) | ||
assert get_nwb_version(builder2) == (2, 0, 0) | ||
|
||
def test_get_nwb_version_missing(self): | ||
"""Get the NWB version from a builder where the root builder does not have an nwb_version attribute.""" | ||
builder1 = GroupBuilder(name="root") | ||
builder2 = GroupBuilder(name="another") | ||
builder1.set_group(builder2) | ||
|
||
with pytest.raises(ValueError, match="'nwb_version' attribute is missing from the root of the NWB file."): | ||
get_nwb_version(builder1) | ||
|
||
with pytest.raises(ValueError, match="'nwb_version' attribute is missing from the root of the NWB file."): | ||
get_nwb_version(builder1) |