Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mfisherlevine committed Jun 21, 2023
1 parent db372ba commit 7d510de
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/test_butlerUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
_assureDict,
getLatissDefaultCollections,
RECENT_DAY,
getExpRecord,
)
from lsst.summit.utils.butlerUtils import removeDataProduct # noqa: F401
import lsst.daf.butler as dafButler
Expand Down Expand Up @@ -392,6 +393,27 @@ def test_updateDataId(self):
self.assertTrue('detector' in dataId)
self.assertEqual(dataId['detector'], 321)

def test_getExpRecord(self):
expId = self.expIdOnly['exposure']
dayObs = self.dayObsSeqNumIdOnly['day_obs']
seqNum = self.dayObsSeqNumIdOnly['seq_num']

recordByExpId = getExpRecord(self.butler, 'LATISS', expId=expId)
self.assertIsInstance(recordByExpId, dafButler.dimensions.DimensionRecord)

recordByDayObsSeqNum = getExpRecord(self.butler, 'LATISS', dayObs=dayObs, seqNum=seqNum)
self.assertIsInstance(recordByDayObsSeqNum, dafButler.dimensions.DimensionRecord)
self.assertEqual(recordByExpId, recordByDayObsSeqNum)

with self.assertRaises(ValueError):
# because we need dayObs too, so immediate raise due to bad args
_ = getExpRecord(self.butler, 'LATISS', seqNum=seqNum)

with self.assertRaises(RuntimeError):
# (dayObs, seqNum) no longer matches the expId, so there are no
# results, which is a RuntimeError
_ = getExpRecord(self.butler, 'LATISS', expId=expId, dayObs=dayObs, seqNum=seqNum+1)


class ButlerInitTestCase(lsst.utils.tests.TestCase):
"""Separately test whether we can make a butler with the env var set
Expand Down

0 comments on commit 7d510de

Please sign in to comment.