Coverage for tests/test_squashMetadataTask.py: 54%
33 statements
« prev ^ index » next coverage.py v6.4.2, created at 2022-07-13 02:58 -0700
« prev ^ index » next coverage.py v6.4.2, created at 2022-07-13 02:58 -0700
1# This file is part of verify.
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/>.
22import unittest.mock
24import lsst.utils.tests
25from lsst.daf.persistence import ButlerDataRef
26from lsst.afw.cameraGeom import Camera
27from lsst.verify import Job
28from lsst.verify.gen2tasks import SquashMetadataTask
31def _makeMockDataref(dataId=None):
32 """A dataref-like object that returns a mock camera.
33 """
34 camera = unittest.mock.NonCallableMock(
35 Camera, autospec=True, **{"getName.return_value": "fancyCam"})
36 return unittest.mock.NonCallableMock(
37 ButlerDataRef, autospec=True, **{"get.return_value": camera},
38 dataId=dataId)
41class SquashMetadataTestSuite(lsst.utils.tests.TestCase):
43 def setUp(self):
44 self.testbed = SquashMetadataTask()
45 self.job = Job()
47 def _checkDataId(self, dataId):
48 dataref = _makeMockDataref(dataId)
49 self.testbed.run(self.job, dataref=dataref)
50 self.assertEqual(set(self.job.meta.keys()),
51 {"instrument", "butler_generation"} | dataId.keys())
52 self.assertEqual(self.job.meta["instrument"], "FANCYCAM")
53 for key, value in dataId.items():
54 self.assertEqual(self.job.meta[key], value)
56 def testCcdVisit(self):
57 self._checkDataId(dict(visit=42, ccd=27))
59 def testTractPatch(self):
60 self._checkDataId(dict(tract=76, patch="2,3"))
62 def testEmptyId(self):
63 self._checkDataId({})
66class MemoryTester(lsst.utils.tests.MemoryTestCase):
67 pass
70def setup_module(module):
71 lsst.utils.tests.init()
74if __name__ == "__main__": 74 ↛ 75line 74 didn't jump to line 75, because the condition on line 74 was never true
75 lsst.utils.tests.init()
76 unittest.main()