Skip to content

Commit

Permalink
Fixed getInstrumentFromButlerName test, and added ComCam policy file.
Browse files Browse the repository at this point in the history
  • Loading branch information
jfcrenshaw committed Dec 15, 2023
1 parent 752cb1c commit 17efca5
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions tests/utils/test_taskUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

import inspect
import unittest

import lsst.obs.lsst as obs_lsst
Expand Down Expand Up @@ -126,15 +127,29 @@ def testGetCameraFromButlerName(self):
self.assertEqual(str(context.exception), errMsg)

def testGetInstrumentFromButlerName(self):
self.assertEqual(getInstrumentFromButlerName("LSSTCam"), Instrument())
self.assertEqual(
# def a function to compare two instruments
def assertInstEqual(inst1, inst2):
# Get the attributes to test
sig = inspect.signature(Instrument)
attributes = list(sig.parameters.keys())
attributes.remove("configFile")

# Loop over the attributes
for attr in attributes:
val1 = getattr(inst1, attr)
val2 = getattr(inst2, attr)
self.assertEqual(val1, val2)

assertInstEqual(getInstrumentFromButlerName("LSSTCam"), Instrument())
assertInstEqual(
getInstrumentFromButlerName("LSSTComCam"),
Instrument(configFile="policy/instruments/ComCam.yaml"),
)
self.assertEqual(
assertInstEqual(
getInstrumentFromButlerName("LATISS"),
Instrument(configFile="policy/instruments/AuxTel.yaml"),
)

with self.assertRaises(ValueError):
getCameraFromButlerName("fake")

Expand Down

0 comments on commit 17efca5

Please sign in to comment.