Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

obs_base - add tests for composite bypass and std #52

Merged
merged 1 commit into from
Jul 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LDM-463 says method should look like std_<datasetType>(self, item) and this has one extra argument

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks. I fixed the document.

item.standardized = True
return item

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it have to be set inside a class method?

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