Skip to content

Commit

Permalink
Expand the test for reading FITS components
Browse files Browse the repository at this point in the history
Be explicit about whether we expect a None or a real entity.
  • Loading branch information
timj committed Apr 23, 2020
1 parent 6c062f6 commit f1de70e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion python/lsst/daf/butler/formatters/fitsExposureFormatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def readComponent(self, component, parameters=None):
'metadata': ('readMetadata', False),
'filter': ('readFilter', False),
'polygon': ('readValidPolygon', False),
'appCorrMap': ('readApCorrMap', False),
'apCorrMap': ('readApCorrMap', False),
'visitInfo': ('readVisitInfo', False),
'transmissionCurve': ('readTransmissionCurve', False),
'detector': ('readDetector', False),
Expand Down
31 changes: 21 additions & 10 deletions tests/test_datastoreFits.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,16 +177,27 @@ def testExposurePutGet(self):

# Get some components
# Could not test the following components as they were not known:
# bbox, xy0, filter, polygon, appCorrMap, detector,
# extras, and exposureInfo
# transmissionCurve returned None and which is fixed in DM-24347
for compName in ("wcs", "image", "mask", "coaddInputs", "psf",
"variance", "photoCalib", "metadata", "visitInfo"):
compRef = self.makeDatasetRef(ref.datasetType.componentTypeName(compName), dimensions,
storageClass.components[compName], dataId, id=ref.id)
component = datastore.get(compRef)
# This check is done also inside datastore
self.assertIsInstance(component, (compRef.datasetType.storageClass.pytype, type(None)))
# bbox, xy0, filter, polygon, detector, extras, and exposureInfo
for compName, isNone in (("wcs", False),
("image", False),
("mask", False),
("coaddInputs", False),
("psf", False),
("variance", False),
("photoCalib", False),
("metadata", False),
("visitInfo", False),
("apCorrMap", True),
("transmissionCurve", True),
("metadata", False)):
with self.subTest(component=compName):
compRef = self.makeDatasetRef(ref.datasetType.componentTypeName(compName), dimensions,
storageClass.components[compName], dataId, id=ref.id)
component = datastore.get(compRef)
if isNone:
self.assertIsNone(component)
else:
self.assertIsInstance(component, compRef.datasetType.storageClass.pytype)

# Get the WCS component to check it
wcsRef = self.makeDatasetRef(ref.datasetType.componentTypeName("wcs"), dimensions,
Expand Down

0 comments on commit f1de70e

Please sign in to comment.