Skip to content

Commit

Permalink
Add back composite tests for Butler server
Browse files Browse the repository at this point in the history
Add a way to optionally skip "predict mode" tests, so we can run the rest of the composite tests against Butler server.
  • Loading branch information
dhirving committed Feb 16, 2024
1 parent b765567 commit ec32860
Showing 1 changed file with 32 additions and 36 deletions.
68 changes: 32 additions & 36 deletions tests/test_butler.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,8 @@ class ButlerTests(ButlerPutGetTests):
registryStr: str | None
datastoreName: list[str] | None
datastoreStr: list[str]
predictionSupported = True
"""Does getURIs support 'prediction mode'?"""

def setUp(self) -> None:
"""Create a new butler root for each test."""
Expand Down Expand Up @@ -748,12 +750,13 @@ def testCompositePutGetConcrete(self) -> None:
self.assertIn("423", str(uri), f"Checking visit is in URI {uri}")

# Predicted dataset
dataId = {"instrument": "DummyCamComp", "visit": 424}
uri, components = butler.getURIs(datasets[0].datasetType, dataId=dataId, predict=True)
self.assertFalse(components)
self.assertIsInstance(uri, ResourcePath)
self.assertIn("424", str(uri), f"Checking visit is in URI {uri}")
self.assertEqual(uri.fragment, "predicted", f"Checking for fragment in {uri}")
if self.predictionSupported:
dataId = {"instrument": "DummyCamComp", "visit": 424}
uri, components = butler.getURIs(datasets[0].datasetType, dataId=dataId, predict=True)
self.assertFalse(components)
self.assertIsInstance(uri, ResourcePath)
self.assertIn("424", str(uri), f"Checking visit is in URI {uri}")
self.assertEqual(uri.fragment, "predicted", f"Checking for fragment in {uri}")

def testCompositePutGetVirtual(self) -> None:
storageClass = self.storageClassFactory.getStorageClass("StructuredCompositeReadComp")
Expand All @@ -778,23 +781,24 @@ def testCompositePutGetVirtual(self) -> None:
self.assertIn("423", str(compuri), f"Checking visit is in URI {compuri}")
self.assertEqual(compuri.fragment, "", f"Checking absence of fragment in {compuri}")

# Predicted dataset
dataId = {"instrument": "DummyCamComp", "visit": 424}
uri, components = butler.getURIs(datasets[0].datasetType, dataId=dataId, predict=True)

if butler._datastore.isEphemeral:
# Never disassembled
self.assertIsInstance(uri, ResourcePath)
self.assertFalse(components)
self.assertIn("424", str(uri), f"Checking visit is in URI {uri}")
self.assertEqual(uri.fragment, "predicted", f"Checking for fragment in {uri}")
else:
self.assertIsNone(uri)
self.assertEqual(set(components), set(storageClass.components))
for compuri in components.values():
self.assertIsInstance(compuri, ResourcePath)
self.assertIn("424", str(compuri), f"Checking visit is in URI {compuri}")
self.assertEqual(compuri.fragment, "predicted", f"Checking for fragment in {compuri}")
if self.predictionSupported:
# Predicted dataset
dataId = {"instrument": "DummyCamComp", "visit": 424}
uri, components = butler.getURIs(datasets[0].datasetType, dataId=dataId, predict=True)

if butler._datastore.isEphemeral:
# Never disassembled
self.assertIsInstance(uri, ResourcePath)
self.assertFalse(components)
self.assertIn("424", str(uri), f"Checking visit is in URI {uri}")
self.assertEqual(uri.fragment, "predicted", f"Checking for fragment in {uri}")
else:
self.assertIsNone(uri)
self.assertEqual(set(components), set(storageClass.components))
for compuri in components.values():
self.assertIsInstance(compuri, ResourcePath)
self.assertIn("424", str(compuri), f"Checking visit is in URI {compuri}")
self.assertEqual(compuri.fragment, "predicted", f"Checking for fragment in {compuri}")

def testStorageClassOverrideGet(self) -> None:
"""Test storage class conversion on get with override."""
Expand Down Expand Up @@ -2508,6 +2512,7 @@ class ButlerServerTests(ButlerTests, unittest.TestCase):
"""Test RemoteButler and Butler server."""

configFile = None
predictionSupported = False

def setUp(self):
self.server_instance = self.enterContext(create_test_server(TESTDIR))
Expand All @@ -2532,20 +2537,11 @@ def testDafButlerRepositories(self):
# Repository index is tested elsewhere.
pass

# Predict mode not implemented.
@unittest.expectedFailure
def testCompositePutGetConcrete(self) -> None:
return super().testCompositePutGetConcrete()

# Predict mode not implemented.
@unittest.expectedFailure
def testCompositePutGetVirtual(self) -> None:
return super().testCompositePutGetVirtual()

# Call to validateConfiguration is failing, not sure why.
@unittest.expectedFailure
def testGetDatasetTypes(self) -> None:
return super().testGetDatasetTypes()
# This is mostly a test of validateConfiguration, which is for
# validating Datastore configuration and thus isn't relevant to
# RemoteButler.
pass

def testMakeRepo(self) -> None:
# Only applies to DirectButler.
Expand Down

0 comments on commit ec32860

Please sign in to comment.