Coverage for tests/test_getId.py : 42%

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#!/usr/bin/env python
3#
4# LSST Data Management System
5# Copyright 2008-2015 AURA/LSST.
6#
7# This product includes software developed by the
8# LSST Project (http://www.lsst.org/).
9#
10# This program is free software: you can redistribute it and/or modify
11# it under the terms of the GNU General Public License as published by
12# the Free Software Foundation, either version 3 of the License, or
13# (at your option) any later version.
14#
15# This program is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18# GNU General Public License for more details.
19#
20# You should have received a copy of the LSST License Statement and
21# the GNU General Public License along with this program. If not,
22# see <https://www.lsstcorp.org/LegalNotices/>.
23#
25import os
26import shutil
27import tempfile
28import unittest
29import lsst.utils.tests
31import lsst.daf.persistence as dafPersist
33ROOT = os.path.abspath(os.path.dirname(__file__))
36class GetIdTestCase(lsst.utils.tests.TestCase):
37 """Testing butler exposure id retrieval"""
39 def setUp(self):
40 self.testDir = tempfile.mkdtemp(dir=ROOT, prefix='GetIdTestCase-')
41 self.butler = dafPersist.Butler(
42 outputs={'root': self.testDir, 'mode': 'rw', 'mapper': 'lsst.obs.sdss.SdssMapper'})
44 def tearDown(self):
45 del self.butler
46 if os.path.exists(self.testDir):
47 shutil.rmtree(self.testDir)
49 def testId(self):
50 """Test retrieval of exposure ids"""
51 bits = self.butler.get("ccdExposureId_bits")
52 self.assertEqual(bits, 38)
53 id = self.butler.get("ccdExposureId", run=6537,
54 camcol=3, filter='r', field=514)
55 self.assertEqual(id, 6537230514)
56 id = self.butler.get("ccdExposureId", run=4933,
57 camcol=3, filter='g', field=748)
58 self.assertEqual(id, 4933130748)
60 dataId = dict(tract=1, patch='2,3', filter='z')
61 bits = self.butler.get("deepCoaddId_bits", dataId)
62 id = self.butler.get("deepCoaddId", dataId)
63 self.assertEqual(bits, 37)
64 self.assertEqual(id, ((((1 * 8192) + 2) * 8192) + 3)*8 + 4)
67class TestMemory(lsst.utils.tests.MemoryTestCase):
68 pass
71def setup_module(module):
72 lsst.utils.tests.init()
75if __name__ == "__main__": 75 ↛ 76line 75 didn't jump to line 76, because the condition on line 75 was never true
76 lsst.utils.tests.init()
77 unittest.main()