diff --git a/tests/test_common.py b/tests/test_common.py index da2e2a8..b29a5c1 100644 --- a/tests/test_common.py +++ b/tests/test_common.py @@ -1,7 +1,7 @@ import unittest import six -from nd2reader.common import parse_version, parse_date +from nd2reader.common import parse_version, parse_date, _add_to_metadata class TestCommon(unittest.TestCase): @@ -31,4 +31,19 @@ class TestCommon(unittest.TestCase): result = parse_date(textinfo) self.assertEqual(result.strftime(date_format), date) + def test_add_to_meta_simple(self): + metadata = {} + _add_to_metadata(metadata, 'test', 'value') + self.assertDictEqual(metadata, {'test': 'value'}) + + def test_add_to_meta_new_list(self): + metadata = {'test': 'value1'} + _add_to_metadata(metadata, 'test', 'value2') + self.assertDictEqual(metadata, {'test': ['value1', 'value2']}) + + def test_add_to_meta_existing_list(self): + metadata = {'test': ['value1', 'value2']} + _add_to_metadata(metadata, 'test', 'value3') + self.assertDictEqual(metadata, {'test': ['value1', 'value2', 'value3']}) + diff --git a/tests/test_raw_metadata.py b/tests/test_raw_metadata.py new file mode 100644 index 0000000..9bb436b --- /dev/null +++ b/tests/test_raw_metadata.py @@ -0,0 +1,18 @@ +import unittest +from nd2reader.raw_metadata import RawMetadata + + +class TestRawMetadata(unittest.TestCase): + def setUp(self): + self.metadata = RawMetadata(None, None) + + def test_parse_roi_shape(self): + self.assertEqual(self.metadata._parse_roi_shape(3), 'rectangle') + self.assertEqual(self.metadata._parse_roi_shape(9), 'circle') + self.assertIsNone(self.metadata._parse_roi_shape(-1)) + + def test_parse_roi_type(self): + self.assertEqual(self.metadata._parse_roi_type(3), 'reference') + self.assertEqual(self.metadata._parse_roi_type(2), 'background') + self.assertEqual(self.metadata._parse_roi_type(4), 'stimulation') + self.assertIsNone(self.metadata._parse_roi_type(-1))