Coverage for tests/test_ingest.py : 36%

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 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 RawIngestTask
34TESTDIR = os.path.dirname(__file__)
37class RawIngestTestCase(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 }
49 cls.creatorButler = butlerTests.makeTestRepo(cls.root, dataIds)
51 # Create dataset types used by the tests
52 cls.storageClassFactory = dafButler.StorageClassFactory()
53 for datasetTypeName, storageClassName in (("raw", "ExposureF"),
54 ):
55 storageClass = cls.storageClassFactory.getStorageClass(storageClassName)
56 butlerTests.addDatasetType(cls.creatorButler,
57 datasetTypeName,
58 {"instrument", "exposure"},
59 storageClass)
61 @classmethod
62 def tearDownClass(cls):
63 if cls.root is not None:
64 shutil.rmtree(cls.root, ignore_errors=True)
66 def setUp(self):
67 self.butler = butlerTests.makeTestCollection(self.creatorButler)
69 self.config = RawIngestTask.ConfigClass()
70 self.config.transfer = "copy" # safe non-default value
71 self.task = RawIngestTask(config=self.config, butler=self.butler)
73 def testPickleTask(self):
74 stream = pickle.dumps(self.task)
75 copy = pickle.loads(stream)
76 self.assertEqual(self.task.getFullName(), copy.getFullName())
77 self.assertEqual(self.task.log.getName(), copy.log.getName())
78 self.assertEqual(self.task.config, copy.config)
79 self.assertEqual(self.task.butler._config, copy.butler._config)
80 self.assertEqual(self.task.butler.collections, copy.butler.collections)
81 self.assertEqual(self.task.butler.run, copy.butler.run)
82 self.assertEqual(self.task.universe, copy.universe)
83 self.assertEqual(self.task.datasetType, copy.datasetType)
86if __name__ == "__main__": 86 ↛ 87line 86 didn't jump to line 87, because the condition on line 86 was never true
87 unittest.main()