Browse Source

Add test for raw metadata

zolfa-add_slices_loading
Ruben Verweij 8 years ago
parent
commit
1827fffbd8
2 changed files with 34 additions and 1 deletions
  1. +16
    -1
      tests/test_common.py
  2. +18
    -0
      tests/test_raw_metadata.py

+ 16
- 1
tests/test_common.py View File

@ -1,7 +1,7 @@
import unittest import unittest
import six 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): class TestCommon(unittest.TestCase):
@ -31,4 +31,19 @@ class TestCommon(unittest.TestCase):
result = parse_date(textinfo) result = parse_date(textinfo)
self.assertEqual(result.strftime(date_format), date) 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']})

+ 18
- 0
tests/test_raw_metadata.py View File

@ -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))

Loading…
Cancel
Save