Coverage for tests/test_rewrite_qe.py: 34%
38 statements
« prev ^ index » next coverage.py v6.5.0, created at 2023-03-08 02:31 -0800
« prev ^ index » next coverage.py v6.5.0, created at 2023-03-08 02:31 -0800
1# This file is part of obs_lsst.
2#
3# Developed for the LSST Data Management System.
4# This product includes software developed by the LSST Project
5# (http://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 <http://www.gnu.org/licenses/>.
22"""Test the rewrite_ts8_qe_files.py script in bin.src."""
24import unittest
25import os
26import shutil
27import tempfile
28import glob
30import lsst.utils
31from lsst.obs.lsst.script.rewrite_ts8_qe_files import rewrite_ts8_files
32from lsst.ip.isr import IntermediateSensorTransmissionCurve
34TESTDIR = os.path.abspath(os.path.dirname(__file__))
35DATADIR = lsst.utils.getPackageDir('obs_lsst_data')
38class RewriteQeTestCase(lsst.utils.tests.ExecutablesTestCase):
39 """Test the rewrite_ts8_qe_files.py utility script."""
41 def testRewriteQe(self):
42 failed = False
43 root = tempfile.mkdtemp(dir=TESTDIR)
44 try:
45 rewrite_ts8_files(os.path.join(TESTDIR, 'data/qe_test/RaftRun10517.p'),
46 root, '1970-01-01T00:00:00')
47 files = glob.glob(os.path.join(root, '*', '19700101T000000.ecsv'))
48 self.assertEqual(len(files), 9)
49 for f in files:
50 curve1 = IntermediateSensorTransmissionCurve.readText(f)
51 expect_file = os.path.join(DATADIR, 'ts8', 'transmission_sensor', os.path.relpath(f, root))
52 curve2 = IntermediateSensorTransmissionCurve.readText(expect_file)
54 # These fields are created every time, and therefore
55 # differ between the test data and the references.
56 curve1.getMetadata().pop('DATE')
57 curve1.getMetadata().pop('CALIB_CREATION_DATE')
58 curve1.getMetadata().pop('CALIB_CREATION_TIME')
60 curve2.getMetadata().pop('DATE')
61 curve2.getMetadata().pop('CALIB_CREATION_DATE')
62 curve2.getMetadata().pop('CALIB_CREATION_TIME')
64 self.assertEqual(curve1, curve2)
65 except Exception:
66 failed = True
67 raise
68 finally:
69 if failed:
70 print(f"Output test data located in {root}")
71 else:
72 shutil.rmtree(root, ignore_errors=True)
75if __name__ == "__main__": 75 ↛ 76line 75 didn't jump to line 76, because the condition on line 75 was never true
76 unittest.main()