Coverage for tests/test_instrument.py : 50%

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 unittest
24from lsst.obs.base import Instrument, FilterDefinitionCollection
25from lsst.obs.base.gen2to3 import TranslatorFactory
26from lsst.obs.base.instrument_tests import InstrumentTests, InstrumentTestData
27from lsst.daf.butler.core.utils import getFullTypeName
29"""Tests of the Instrument class.
30"""
33class DummyCam(Instrument):
35 filterDefinitions = FilterDefinitionCollection()
37 @classmethod
38 def getName(cls):
39 return "DummyCam"
41 def getCamera(self):
42 return None
44 def register(self, registry):
45 """Insert Instrument, physical_filter, and detector entries into a
46 `Registry`.
47 """
48 dataId = {"instrument": self.getName(), "class_name": getFullTypeName(DummyCam)}
49 with registry.transaction():
50 registry.syncDimensionData("instrument", dataId)
51 for f in ("dummy_g", "dummy_u"):
52 registry.syncDimensionData("physical_filter",
53 dict(dataId, physical_filter=f, band=f[-1]))
54 for d in (1, 2):
55 registry.syncDimensionData("detector",
56 dict(dataId, id=d, full_name=str(d)))
58 def getRawFormatter(self, dataId):
59 # Docstring inherited fromt Instrument.getRawFormatter.
60 return None
62 def writeCuratedCalibrations(self, butler):
63 pass
65 def applyConfigOverrides(self, name, config):
66 pass
68 def makeDataIdTranslatorFactory(self) -> TranslatorFactory:
69 return TranslatorFactory()
72class InstrumentTestCase(InstrumentTests, unittest.TestCase):
73 """Test for Instrument.
74 """
76 instrument = DummyCam()
78 data = InstrumentTestData(name="DummyCam",
79 nDetectors=2,
80 firstDetectorName="1",
81 physical_filters={"dummy_g", "dummy_u"})
83 def test_getCamera(self):
84 """No camera defined in DummyCam"""
85 return
88if __name__ == "__main__": 88 ↛ 89line 88 didn't jump to line 89, because the condition on line 88 was never true
89 unittest.main()