Coverage for tests/test_dataId.py: 37%
40 statements
« prev ^ index » next coverage.py v6.4.2, created at 2022-07-13 02:46 -0700
« prev ^ index » next coverage.py v6.4.2, created at 2022-07-13 02:46 -0700
1#
2# LSST Data Management System
3# Copyright 2016 LSST Corporation.
4#
5# This product includes software developed by the
6# LSST Project (http://www.lsst.org/).
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the LSST License Statement and
19# the GNU General Public License along with this program. If not,
20# see <http://www.lsstcorp.org/LegalNotices/>.
21#
24import unittest
26import lsst.utils.tests
27from lsst.daf.persistence import DataId
30class TestDataId(unittest.TestCase):
31 """A test case for the DataId class.
32 """
34 def test(self):
35 dataId = DataId()
36 self.assertEqual(dataId.tag, set())
37 self.assertEqual(dataId, {})
39 def testInputDictNoTags(self):
40 dataId = DataId({'a': 1, 'b': 2})
41 self.assertEqual(dataId, {'a': 1, 'b': 2})
42 self.assertEqual(dataId.tag, set())
44 def testInputDictWithTag(self):
45 # single tag
46 dataId = DataId({'a': 1, 'b': 2}, 'foo')
47 self.assertEqual(dataId, {'a': 1, 'b': 2})
48 self.assertEqual(dataId.tag, set(['foo']))
50 # tag list
51 dataId = DataId({'a': 1, 'b': 2}, ['foo', 'bar'])
52 self.assertEqual(dataId, {'a': 1, 'b': 2})
53 self.assertEqual(dataId.tag, set(['foo', 'bar']))
55 # tag tuple
56 dataId = DataId({'a': 1, 'b': 2}, ('foo', 'bar'))
57 self.assertEqual(dataId, {'a': 1, 'b': 2})
58 self.assertEqual(dataId.tag, set(['foo', 'bar']))
60 # tag set
61 dataId = DataId({'a': 1, 'b': 2}, set(['foo', 'bar']))
62 self.assertEqual(dataId, {'a': 1, 'b': 2})
63 self.assertEqual(dataId.tag, set(['foo', 'bar']))
65 def testInputDataId(self):
66 initDataId = DataId({'a': 1, 'b': 2}, ['foo', 'bar'])
67 dataId = DataId(initDataId)
68 self.assertEqual(dataId, {'a': 1, 'b': 2})
69 self.assertEqual(dataId.tag, set(['foo', 'bar']))
71 dataId = DataId(initDataId, 'baz')
72 self.assertEqual(dataId, {'a': 1, 'b': 2})
73 self.assertEqual(dataId.tag, set(['foo', 'bar', 'baz']))
76class MemoryTester(lsst.utils.tests.MemoryTestCase):
77 pass
80def setup_module(module):
81 lsst.utils.tests.init()
84if __name__ == '__main__': 84 ↛ 85line 84 didn't jump to line 85, because the condition on line 84 was never true
85 lsst.utils.tests.init()
86 unittest.main()