Coverage for tests/test_instrument.py : 51%

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 registry.insertDimensionData("instrument", dataId)
50 for f in ("dummy_g", "dummy_u"):
51 registry.insertDimensionData("physical_filter",
52 dict(dataId, physical_filter=f, abstract_filter=f[-1]))
53 for d in (1, 2):
54 registry.insertDimensionData("detector",
55 dict(dataId, id=d, full_name=str(d)))
57 def getRawFormatter(self, dataId):
58 # Docstring inherited fromt Instrument.getRawFormatter.
59 return None
61 def writeCuratedCalibrations(self, butler):
62 pass
64 def applyConfigOverrides(self, name, config):
65 pass
67 def makeDataIdTranslatorFactory(self) -> TranslatorFactory:
68 return TranslatorFactory()
71class InstrumentTestCase(InstrumentTests, unittest.TestCase):
72 """Test for Instrument.
73 """
75 instrument = DummyCam()
77 data = InstrumentTestData(name="DummyCam",
78 nDetectors=2,
79 firstDetectorName="1",
80 physical_filters={"dummy_g", "dummy_u"})
82 def test_getCamera(self):
83 """No camera defined in DummyCam"""
84 return
87if __name__ == "__main__": 87 ↛ 88line 87 didn't jump to line 88, because the condition on line 87 was never true
88 unittest.main()