Coverage for tests/test_calibType.py: 37%
36 statements
« prev ^ index » next coverage.py v6.5.0, created at 2024-03-20 01:16 -0700
« prev ^ index » next coverage.py v6.5.0, created at 2024-03-20 01:16 -0700
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 IsrCalibCases(lsst.utils.tests.TestCase):
30 """Test unified calibration type.
31 """
32 def setUp(self):
33 self.calib = IsrProvenance(detectorName='testCalibType Det00',
34 detectorId=0,
35 instrument="TestInst",
36 calibType="Test Calib")
37 self.calib.updateMetadata()
38 self.calib.fromDataIds([{'exposure': 1234, 'detector': 0, 'filter': 'G'},
39 {'exposure': 1235, 'detector': 0, 'filter': 'G'},
40 {'exposure': 1234, 'detector': 1, 'filter': 'G'},
41 {'exposure': 1235, 'detector': 1, 'filter': 'G'}])
43 def runText(self, textType):
44 filename = tempfile.mktemp()
45 usedFilename = self.calib.writeText(filename + textType)
46 fromText = IsrProvenance.readText(usedFilename)
47 self.assertEqual(self.calib, fromText)
49 # Test generic interface:
50 fromGeneric = IsrCalib.readText(usedFilename)
51 self.assertEqual(self.calib, fromGeneric)
53 def test_Text(self):
54 self.runText('.yaml')
55 self.runText('.ecsv')
57 def test_Fits(self):
58 filename = tempfile.mktemp()
59 usedFilename = self.calib.writeFits(filename + '.fits')
60 fromFits = IsrProvenance.readFits(usedFilename)
61 self.assertEqual(self.calib, fromFits)
63 fromFits.updateMetadata(setDate=True)
64 self.assertNotEqual(self.calib, fromFits)
66 # Test generic interface:
67 fromGeneric = IsrCalib.readFits(usedFilename)
68 self.assertEqual(self.calib, fromGeneric)
71class MemoryTester(lsst.utils.tests.MemoryTestCase):
72 pass
75def setup_module(module):
76 lsst.utils.tests.init()
79if __name__ == "__main__": 79 ↛ 80line 79 didn't jump to line 80, because the condition on line 79 was never true
80 import sys
81 setup_module(sys.modules[__name__])
82 unittest.main()