Coverage for tests/test_assembleCcd.py: 50%
30 statements
« prev ^ index » next coverage.py v6.5.0, created at 2023-03-05 10:29 +0000
« prev ^ index » next coverage.py v6.5.0, created at 2023-03-05 10:29 +0000
1#
2# LSST Data Management System
3# Copyright 2008-2017 AURA/LSST.
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 <https://www.lsstcorp.org/LegalNotices/>.
21#
23import unittest
25import lsst.utils.tests
26from lsst.ip.isr.assembleCcdTask import (AssembleCcdConfig, AssembleCcdTask)
27import lsst.ip.isr.isrMock as isrMock
30class AssembleCcdTestCases(lsst.utils.tests.TestCase):
32 def setUp(self):
33 self.outputExp = isrMock.TrimmedRawMock().run()
34 self.outputUntrimmedExp = isrMock.RawMock().run()
36 def runTest(self, inputExp=None, doTrim=False):
37 """Create an appropriate assembly configuration and task, returning
38 the results of AssembleCcdTask.assembleCcd().
40 Parameters
41 ----------
42 inputExp : `lsst.afw.image.Exposure`
43 Exposure to assemble.
44 doTrim : `bool`
45 To trim the input or not to trim.
47 Returns
48 -------
49 assembleOutput : `lsst.afw.image.Exposure`
50 Assembled exposure.
52 Raises
53 ------
54 TypeError
55 Raised if the inputExp is None.
56 """
57 self.config = AssembleCcdConfig(doTrim=doTrim,
58 keysToRemove=['SHEEP', 'MONKEYS', 'ZSHEEP'])
59 self.task = AssembleCcdTask(config=self.config)
61 return self.task.assembleCcd(inputExp)
63 def testAssembleCcdTask_exp_noTrim(self):
64 self.assertEqual(self.runTest(inputExp=isrMock.RawMock().run(), doTrim=False).getBBox(),
65 self.outputUntrimmedExp.getBBox())
67 def testAssembleCcdTask_exp_doTrim(self):
68 self.assertEqual(self.runTest(inputExp=isrMock.RawMock().run(), doTrim=True).getBBox(),
69 self.outputExp.getBBox())
71 def testAssembleCcdTask_expDict_noTrim(self):
72 self.assertEqual(self.runTest(inputExp=isrMock.RawDictMock().run(), doTrim=False).getBBox(),
73 self.outputUntrimmedExp.getBBox())
75 def testAssembleCcdTask_expDict_doTrim(self):
76 self.assertEqual(self.runTest(inputExp=isrMock.RawDictMock().run(), doTrim=True).getBBox(),
77 self.outputExp.getBBox())
79 def testAssembleCcdTask_fail(self):
80 """Assembly should fail if no exposure is supplied.
81 """
82 with self.assertRaises(TypeError):
83 self.runTest(inputExp=None, doTrim=False)
86class MemoryTester(lsst.utils.tests.MemoryTestCase):
87 pass
90def setup_module(module):
91 lsst.utils.tests.init()
94if __name__ == "__main__": 94 ↛ 95line 94 didn't jump to line 95, because the condition on line 94 was never true
95 lsst.utils.tests.init()
96 unittest.main()