Skip to content

Commit

Permalink
Add a test for observationInfo2visitInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
timj committed Jun 12, 2019
1 parent 2eadf17 commit f5c29b5
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions tests/test_makeRawVisitInfoViaObsInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
from astropy.time import Time
import astropy.units as u

from astro_metadata_translator import FitsTranslator, StubTranslator
import lsst.log
from astro_metadata_translator import FitsTranslator, StubTranslator, ObservationInfo
from lsst.daf.base import DateTime

from lsst.obs.base import MakeRawVisitInfoViaObsInfo
Expand Down Expand Up @@ -77,14 +78,28 @@ def testMakeRawVisitInfoViaObsInfo(self):
# Capture the warnings from StubTranslator since they are
# confusing to people but irrelevant for the test.
with self.assertWarns(UserWarning):
visitInfo = maker(self.header)
with lsst.log.UsePythonLogging():
with self.assertLogs(level="WARNING"):
visitInfo = maker(self.header)

self.assertAlmostEqual(visitInfo.getExposureTime(), self.exposure_time.to_value("s"))
self.assertEqual(visitInfo.getExposureId(), self.exposure_id)
self.assertEqual(visitInfo.getDate(), DateTime("2001-01-02T03:04:06.123456789Z", DateTime.UTC))
self.assertNotIn("EXPTIME", self.header)
self.assertEqual(len(self.header), 2)

def testObservationInfo2VisitInfo(self):

with self.assertWarns(UserWarning):
obsInfo = ObservationInfo(self.header, translator_class=NewTranslator)

# No log specified so no log message should appear
visitInfo = MakeRawVisitInfoViaObsInfo.observationInfo2visitInfo(obsInfo)
self.assertIsInstance(visitInfo, lsst.afw.image.VisitInfo)
self.assertAlmostEqual(visitInfo.getExposureTime(), self.exposure_time.to_value("s"))
self.assertEqual(visitInfo.getExposureId(), self.exposure_id)
self.assertEqual(visitInfo.getDate(), DateTime("2001-01-02T03:04:06.123456789Z", DateTime.UTC))


if __name__ == "__main__":
unittest.main()

0 comments on commit f5c29b5

Please sign in to comment.