Coverage for tests/test_tasks.py : 33%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# This file is part of faro.
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 os
23import unittest
24import astropy.units as u
26from lsst.utils import getPackageDir
27from lsst.afw.table import SimpleCatalog
29from lsst.faro.base import CatalogMeasurementBaseConfig, CatalogMeasurementBaseTask
30from lsst.faro.measurement import (VisitTableMeasurementConfig, VisitTableMeasurementTask,
31 DetectorTableMeasurementConfig, DetectorTableMeasurementTask,
32 VisitMeasurementConfig, VisitMeasurementTask,
33 DetectorMeasurementConfig, DetectorMeasurementTask)
35DATADIR = os.path.join(getPackageDir('faro'), 'tests', 'data')
38class TaskTest(unittest.TestCase):
40 def load_data(self, key):
41 cat_file = self.file_map[key]
42 catalog = SimpleCatalog.readFits(os.path.join(DATADIR, cat_file))
43 return catalog
45 def setUp(self):
46 """This is called immediately before calling each test method."""
47 self.file_map = {'CatalogMeasurementBaseTask':
48 'src_HSC_i_HSC-I_903986_0_31_HSC_runs_ci_hsc_20210407T021858Z.fits'}
50 def testCatalogMeasurementBaseTask(self):
51 """Test run method of CatalogMeasurementBaseTask."""
52 catalog = self.load_data('CatalogMeasurementBaseTask')
53 config = CatalogMeasurementBaseConfig()
54 t = CatalogMeasurementBaseTask(config)
55 outputs = t.run(catalog)
56 expected = 771 * u.count
57 self.assertEqual(outputs.measurement.quantity, expected)
59 def testVisitTableMeasurementTask(self):
60 """Test run method of VisitTableMeasurementTask."""
61 catalog = self.load_data('CatalogMeasurementBaseTask')
62 config = VisitTableMeasurementConfig()
63 t = VisitTableMeasurementTask(config)
64 outputs = t.run(catalog)
65 expected = 771 * u.count
66 self.assertEqual(outputs.measurement.quantity, expected)
68 def testDetectorTableMeasurementTask(self):
69 """Test run method of VisitTableMeasurementTask."""
70 catalog = self.load_data('CatalogMeasurementBaseTask')
71 config = DetectorTableMeasurementConfig()
72 t = DetectorTableMeasurementTask(config)
73 outputs = t.run(catalog)
74 expected = 771 * u.count
75 self.assertEqual(outputs.measurement.quantity, expected)
77 def testVisitMeasurementTask(self):
78 """Test run method of VisitMeasurementTask."""
79 catalog = self.load_data('CatalogMeasurementBaseTask')
80 config = VisitMeasurementConfig()
81 t = VisitMeasurementTask(config)
82 outputs = t.run(catalog)
83 expected = 771 * u.count
84 self.assertEqual(outputs.measurement.quantity, expected)
86 def testDetectorMeasurementTask(self):
87 """Test run method of DetectorMeasurementTask."""
88 catalog = self.load_data('CatalogMeasurementBaseTask')
89 config = DetectorMeasurementConfig()
90 t = DetectorMeasurementTask(config)
91 outputs = t.run(catalog)
92 expected = 771 * u.count
93 self.assertEqual(outputs.measurement.quantity, expected)
96if __name__ == "__main__": 96 ↛ 97line 96 didn't jump to line 97, because the condition on line 96 was never true
97 unittest.main()