Skip to content

Commit

Permalink
add tests for composite bypass and std
Browse files Browse the repository at this point in the history
  • Loading branch information
n8pease committed Jul 11, 2017
1 parent cb2656a commit 669ccb8
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
7 changes: 7 additions & 0 deletions python/lsst/obs/base/test/compositeMapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,10 @@ def _makeCamera(self, policy, repositoryDir):
"""Normally this makes a camera. For composite testing, we don't need a camera.
"""
return None

def std_stdTestType(self, item, dataId):
item.standardized = True
return item

def bypass_bypassTestType(self, datasetType, pythonType, location, dataId):
return set(dataId.keys())
39 changes: 36 additions & 3 deletions tests/testComposite.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,23 @@ def setUp(self):
'a': {'datasetType': 'basicObject1'},
'b': {'datasetType': 'basicObject2'}
},
'assembler': 'lsst.daf.persistence.test.TestObjectPair.assembler',
'disassembler': 'lsst.daf.persistence.test.TestObjectPair.disassembler'

'assembler':
'lsst.daf.persistence.test.TestObjectPair.assembler',
'disassembler':
'lsst.daf.persistence.test.TestObjectPair.disassembler'},
'stdTestType': {
'python': 'lsst.daf.persistence.test.TestObjectPair',
'composite': {
'a': {'datasetType': 'basicObject1'},
'b': {'datasetType': 'basicObject2'}
}
},
'bypassTestType': {
'python': 'lsst.daf.persistence.test.TestObjectPair',
'composite': {
'a': {'datasetType': 'basicObject1'},
'b': {'datasetType': 'basicObject2'}
}
}
}})

Expand Down Expand Up @@ -151,6 +165,25 @@ def testDatasetDoesNotExist(self):
butler.put(self.objA, 'basicObject1', dataId={'id': 'foo'})
self.assertFalse(butler.datasetExists('basicPair', dataId={'id': 'foo', 'name': 'bar'}))

def testStd(self):
"""Verify that composite dataset types with a std_ function are passed to the std_ function after
being instantiated."""
secondRepoPath = os.path.join(self.testData, 'repo2')
repoArgs = dafPersist.RepositoryArgs(root=secondRepoPath, policy=self.policy)
butler = dafPersist.Butler(inputs=self.firstRepoPath, outputs=repoArgs)
objABPair = butler.get('stdTestType', dataId={'id': 'foo', 'name': 'bar'})
self.assertTrue(hasattr(objABPair, 'standardized'))
self.assertTrue(objABPair.standardized)

def testBypass(self):
"""Verify that composite dataset types with a bypass_ function are passed to the bypass function after
being instantiated."""
secondRepoPath = os.path.join(self.testData, 'repo2')
repoArgs = dafPersist.RepositoryArgs(root=secondRepoPath, policy=self.policy)
butler = dafPersist.Butler(inputs=self.firstRepoPath, outputs=repoArgs)
bypassObject = butler.get('bypassTestType', dataId={'id': 'foo', 'name': 'bar'})
self.assertEqual(bypassObject, set(['id', 'name'])


class TestGenericAssembler(unittest.TestCase):
"""A test case for the generic assembler feature of composite datasets."""
Expand Down

0 comments on commit 669ccb8

Please sign in to comment.