Skip to content

Commit

Permalink
Add test for incompatible universe on load
Browse files Browse the repository at this point in the history
  • Loading branch information
timj committed Jul 13, 2022
1 parent da99a67 commit b388341
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions tests/test_quantumGraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class QuantumGraphTestCase(unittest.TestCase):
"""Tests the various functions of a quantum graph"""

def setUp(self):
config = Config(
self.config = Config(
{
"version": 1,
"namespace": "pipe_base_test",
Expand Down Expand Up @@ -158,7 +158,7 @@ def setUp(self):
"packers": {},
}
)
universe = DimensionUniverse(config=config)
universe = DimensionUniverse(config=self.config)
# need to make a mapping of TaskDef to set of quantum
quantumMap = {}
tasks = []
Expand Down Expand Up @@ -393,6 +393,22 @@ def testSaveLoad(self):
self.assertEqual(len(restoreSub), 1)
self.assertEqual(list(restoreSub)[0], restore.getQuantumNodeByNodeId(nodeId))

# Different universes.
tmpFile.seek(0)
different_config = self.config.copy()
different_config["version"] = 1_000_000
different_universe = DimensionUniverse(config=different_config)
with self.assertLogs("lsst.daf.butler", "INFO"):
QuantumGraph.load(tmpFile, different_universe)

different_config["namespace"] = "incompatible"
different_universe = DimensionUniverse(config=different_config)
print("Trying with uni ", different_universe)
tmpFile.seek(0)
with self.assertRaises(RuntimeError) as cm:
QuantumGraph.load(tmpFile, different_universe)
self.assertIn("not compatible with", str(cm.exception))

def testSaveLoadUri(self):
uri = None
try:
Expand Down

0 comments on commit b388341

Please sign in to comment.