Skip to content

Commit

Permalink
Add test for get_dataset collection caching
Browse files Browse the repository at this point in the history
Add a test to ensure that get_dataset will not throw a MissingCollectionError for datasets added since the last collection refresh.
  • Loading branch information
dhirving committed Dec 28, 2023
1 parent 270740f commit 76217ec
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/test_butler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1233,6 +1233,17 @@ def testButlerRewriteDataId(self) -> None:
new_metric = butler.get(datasetTypeName, dataId=dataId)
self.assertEqual(new_metric, metric)

def testGetDatasetCollectionCaching(self):
# Prior to DM-41117, there was a bug where get_dataset would throw
# MissingCollectionError if you tried to fetch a dataset that was added
# after the collection cache was last updated.
reader_butler, datasetType = self.create_butler(self.default_run, "int", "datasettypename")
writer_butler = Butler.from_config(self.tmpConfigFile, writeable=True, run="new_run")
dataId = {"instrument": "DummyCamComp", "visit": 423}
put_ref = writer_butler.put(123, datasetType, dataId)
get_ref = reader_butler.get_dataset(put_ref.id)
self.assertEqual(get_ref.id, put_ref.id)


class FileDatastoreButlerTests(ButlerTests):
"""Common tests and specialization of ButlerTests for butlers backed
Expand Down

0 comments on commit 76217ec

Please sign in to comment.