Skip to content

Commit

Permalink
add test for base hdmfio
Browse files Browse the repository at this point in the history
  • Loading branch information
stephprince committed Nov 1, 2024
1 parent 03c9f8f commit 01f8f8f
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/unit/test_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from hdmf.utils import docval
from hdmf.common import DynamicTable, VectorData, DynamicTableRegion
from hdmf.backends.hdf5.h5tools import HDF5IO
from hdmf.backends.io import HDMFIO


class Subcontainer(Container):
Expand Down Expand Up @@ -513,6 +514,42 @@ def test_repr_html_hdf5_dataset(self):

os.remove('array_data.h5')

def test_repr_html_hdmf_io(self):
with HDF5IO('array_data.h5', mode='w') as io:
dataset = io._file.create_dataset(name='my_dataset', data=np.array([1, 2, 3, 4], dtype=np.int64))
obj = self.ContainerWithData(data=dataset, str="hello")

class OtherIO(HDMFIO):

@staticmethod
def can_read(path):
pass

def read_builder(self):
pass

def write_builder(self, **kwargs):
pass

def open(self):
pass

def close(self):
pass

obj.read_io = OtherIO()

expected_html_table = (
'class="container-fields"><table class="data-info"><tbody><tr><th style="text-align: '
'left">Data type</th><td style="text-align: left">int64</td></tr><tr><th style="text-align: left">'
'Shape</th><td style="text-align: left">(4,)</td></tr><tr><th style="text-align: left">Array size'
'</th><td style="text-align: left">32.00 bytes</td></tr></tbody></table><br>[1 2 3 4]'
)

self.assertIn(expected_html_table, obj._repr_html_())

os.remove('array_data.h5')

class TestData(TestCase):

def test_constructor_scalar(self):
Expand Down

0 comments on commit 01f8f8f

Please sign in to comment.