Skip to content

Commit

Permalink
Run IO utils tests in test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
rly committed Dec 14, 2022
1 parent 066e9dc commit e4d1186
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 28 deletions.
2 changes: 2 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ def run_integration_tests(verbose=True):
else:
logging.info('all classes have integration tests')

run_test_suite("tests/integration/utils", "integration utils tests", verbose=verbose)

# also test the validation script
run_test_suite("tests/validation", "validation tests", verbose=verbose)

Expand Down
28 changes: 0 additions & 28 deletions tests/integration/test_io_utils.py

This file was deleted.

Empty file.
30 changes: 30 additions & 0 deletions tests/integration/utils/test_io_utils.py
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)

0 comments on commit e4d1186

Please sign in to comment.