Coverage for tests/test_calibType.py: 37%
44 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-11 10:08 +0000
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-11 10:08 +0000
1# This file is part of ip_isr.
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/>.
21import unittest
22import tempfile
24import lsst.utils.tests
26from lsst.ip.isr import IsrProvenance, IsrCalib
29class FakeExposure():
30 def __init__(self, **kwargs):
31 self.metadata = kwargs
33 def getMetadata(self):
34 return self.metadata
37class IsrCalibCases(lsst.utils.tests.TestCase):
38 """Test unified calibration type.
39 """
40 def setUp(self):
41 self.calib = IsrProvenance(detectorName='testCalibType Det00',
42 detectorId=0,
43 instrument="TestInst",
44 calibType="Test Calib")
45 self.calib.updateMetadata()
46 self.calib.fromDataIds([{'exposure': 1234, 'detector': 0, 'filter': 'G'},
47 {'exposure': 1235, 'detector': 0, 'filter': 'G'},
48 {'exposure': 1234, 'detector': 1, 'filter': 'G'},
49 {'exposure': 1235, 'detector': 1, 'filter': 'G'}])
50 self.exposure1 = FakeExposure(SEQNAME='sequencer A', SEQFILE='my.seq', SEQCKSUM='abcdef')
51 self.exposure2 = FakeExposure(SEQNAME='sequencer B', SEQFILE='my.seq')
53 def runText(self, textType):
54 filename = tempfile.mktemp()
55 usedFilename = self.calib.writeText(filename + textType)
56 fromText = IsrProvenance.readText(usedFilename)
57 self.assertEqual(self.calib, fromText)
59 # Test generic interface:
60 fromGeneric = IsrCalib.readText(usedFilename)
61 self.assertEqual(self.calib, fromGeneric)
63 def test_Text(self):
64 self.runText('.yaml')
65 self.runText('.ecsv')
67 def test_Fits(self):
68 filename = tempfile.mktemp()
69 usedFilename = self.calib.writeFits(filename + '.fits')
70 fromFits = IsrProvenance.readFits(usedFilename)
71 self.assertEqual(self.calib, fromFits)
73 fromFits.updateMetadataFromExposures([self.exposure1, self.exposure2, None])
74 fromFits.updateMetadata(setDate=True)
75 self.assertNotEqual(self.calib, fromFits)
77 # Test generic interface:
78 fromGeneric = IsrCalib.readFits(usedFilename)
79 self.assertEqual(self.calib, fromGeneric)
82class MemoryTester(lsst.utils.tests.MemoryTestCase):
83 pass
86def setup_module(module):
87 lsst.utils.tests.init()
90if __name__ == "__main__": 90 ↛ 91line 90 didn't jump to line 91, because the condition on line 90 was never true
91 import sys
92 setup_module(sys.modules[__name__])
93 unittest.main()