Coverage for tests/test_defineVisits.py: 39%
40 statements
« prev ^ index » next coverage.py v7.1.0, created at 2023-02-05 18:01 -0800
« prev ^ index » next coverage.py v7.1.0, created at 2023-02-05 18:01 -0800
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
31from lsst.obs.base import DefineVisitsTask
34TESTDIR = os.path.dirname(__file__)
37class DefineVisitsTestCase(unittest.TestCase):
38 @classmethod
39 def setUpClass(cls):
40 """Create a new butler once only."""
41 cls.root = tempfile.mkdtemp(dir=TESTDIR)
43 dataIds = {
44 "instrument": ["DummyCam"],
45 "physical_filter": ["d-r"],
46 "exposure": [42, 43, 44],
47 "visit": [42, 43, 44],
48 }
50 cls.creatorButler = butlerTests.makeTestRepo(cls.root, dataIds)
52 # Create dataset types used by the tests
53 cls.storageClassFactory = dafButler.StorageClassFactory()
54 for datasetTypeName, storageClassName in (("raw", "ExposureF"),
55 ):
56 storageClass = cls.storageClassFactory.getStorageClass(storageClassName)
57 butlerTests.addDatasetType(cls.creatorButler,
58 datasetTypeName,
59 {"instrument", "exposure"},
60 storageClass)
62 @classmethod
63 def tearDownClass(cls):
64 if cls.root is not None:
65 shutil.rmtree(cls.root, ignore_errors=True)
67 def setUp(self):
68 self.butler = butlerTests.makeTestCollection(self.creatorButler)
70 self.config = DefineVisitsTask.ConfigClass()
71 self.config.computeVisitRegions.active.padding = 42 # non-default value
72 self.task = DefineVisitsTask(config=self.config, butler=self.butler)
74 def testPickleTask(self):
75 stream = pickle.dumps(self.task)
76 copy = pickle.loads(stream)
77 self.assertEqual(self.task.getFullName(), copy.getFullName())
78 self.assertEqual(self.task.log.name, copy.log.name)
79 self.assertEqual(self.task.config, copy.config)
80 self.assertEqual(self.task.butler._config, copy.butler._config)
81 self.assertEqual(self.task.butler.collections, copy.butler.collections)
82 self.assertEqual(self.task.butler.run, copy.butler.run)
83 self.assertEqual(self.task.universe, copy.universe)
86if __name__ == "__main__": 86 ↛ 87line 86 didn't jump to line 87, because the condition on line 86 was never true
87 unittest.main()