Coverage for tests/test_defineVisits.py: 39%
40 statements
« prev ^ index » next coverage.py v7.2.1, created at 2023-03-12 21:03 -0700
« prev ^ index » next coverage.py v7.2.1, created at 2023-03-12 21:03 -0700
1# This file is part of obs_base.
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 <http://www.gnu.org/licenses/>.
22import os
23import pickle
24import shutil
25import tempfile
26import unittest
28import lsst.daf.butler as dafButler
29import lsst.daf.butler.tests as butlerTests
30from lsst.obs.base import DefineVisitsTask
32TESTDIR = os.path.dirname(__file__)
35class DefineVisitsTestCase(unittest.TestCase):
36 @classmethod
37 def setUpClass(cls):
38 """Create a new butler once only."""
39 cls.root = tempfile.mkdtemp(dir=TESTDIR)
41 dataIds = {
42 "instrument": ["DummyCam"],
43 "physical_filter": ["d-r"],
44 "exposure": [42, 43, 44],
45 "visit": [42, 43, 44],
46 }
48 cls.creatorButler = butlerTests.makeTestRepo(cls.root, dataIds)
50 # Create dataset types used by the tests
51 cls.storageClassFactory = dafButler.StorageClassFactory()
52 for datasetTypeName, storageClassName in (("raw", "ExposureF"),):
53 storageClass = cls.storageClassFactory.getStorageClass(storageClassName)
54 butlerTests.addDatasetType(
55 cls.creatorButler, datasetTypeName, {"instrument", "exposure"}, storageClass
56 )
58 @classmethod
59 def tearDownClass(cls):
60 if cls.root is not None:
61 shutil.rmtree(cls.root, ignore_errors=True)
63 def setUp(self):
64 self.butler = butlerTests.makeTestCollection(self.creatorButler)
66 self.config = DefineVisitsTask.ConfigClass()
67 self.config.computeVisitRegions.active.padding = 42 # non-default value
68 self.task = DefineVisitsTask(config=self.config, butler=self.butler)
70 def testPickleTask(self):
71 stream = pickle.dumps(self.task)
72 copy = pickle.loads(stream)
73 self.assertEqual(self.task.getFullName(), copy.getFullName())
74 self.assertEqual(self.task.log.name, copy.log.name)
75 self.assertEqual(self.task.config, copy.config)
76 self.assertEqual(self.task.butler._config, copy.butler._config)
77 self.assertEqual(self.task.butler.collections, copy.butler.collections)
78 self.assertEqual(self.task.butler.run, copy.butler.run)
79 self.assertEqual(self.task.universe, copy.universe)
82if __name__ == "__main__": 82 ↛ 83line 82 didn't jump to line 83, because the condition on line 82 was never true
83 unittest.main()