Coverage for tests/test_dataIdContainer.py: 57%
Shortcuts on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# This file is part of pipe_base.
2#
3# Developed for the LSST Data Management System.
4# This product includes software developed by the LSST Project
5# (https://www.lsst.org).
6# See the COPYRIGHT file at the top-level directory of this distribution
7# for details of code ownership.
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program. If not, see <https://www.gnu.org/licenses/>.
22"""Tests of the DataIdContainer class."""
24import unittest
25import unittest.mock
27import lsst.daf.persistence
28import lsst.pipe.base as pipeBase
29import lsst.utils.tests
32class DataIdContainerTestCase(lsst.utils.tests.TestCase):
33 def setUp(self):
34 self.container = pipeBase.DataIdContainer()
35 self.butler = unittest.mock.MagicMock(spec=lsst.daf.persistence.Butler)
37 def test_castDataIdsNoneDatasetType(self):
38 """Raise RuntimeError if we haven't set container.datasetType."""
39 with self.assertRaises(RuntimeError):
40 self.container.castDataIds(self.butler)
42 def test_makeDataRefListNoneDatasetType(self):
43 """Raise RuntimeError if we haven't set container.datasetType."""
44 with self.assertRaises(RuntimeError):
45 self.container.makeDataRefList(self.butler)
47 def test_castDataIdsRaiseKeyError(self):
48 """Test that castDataIds re-raises a butler.getKeys() exception."""
49 self.container.setDatasetType("nonsense!")
50 self.butler.getKeys.side_effect = KeyError
51 with self.assertRaises(KeyError) as cm:
52 self.container.castDataIds(self.butler)
53 self.assertIsInstance(cm.exception.__cause__, KeyError)
56class MyMemoryTestCase(lsst.utils.tests.MemoryTestCase):
57 pass
60def setup_module(module):
61 lsst.utils.tests.init()
64if __name__ == "__main__": 64 ↛ 65line 64 didn't jump to line 65, because the condition on line 64 was never true
65 lsst.utils.tests.init()
66 unittest.main()