def testSerialization(self): # Test creating a pipeline, writing it to a file, reading the file pipeline_str = textwrap.dedent(""" description: Test Pipeline instrument: dummyCam imports: - location: $PIPE_BASE_DIR/tests/testPipeline1.yaml instrument: None tasks: modC: class: test.moduleC config: - propertyA: 6 propertyB: 7 dataId: {"visit": 6} - propertyA: 8 propertyB: 9 modD: test.moduleD contracts: - modA.foo == modB.bar subsets: subA: - modA - modC """) pipeline = PipelineIR.from_string(pipeline_str) # Create the temp file, write and read with tempfile.NamedTemporaryFile() as tf: pipeline.to_file(tf.name) loaded_pipeline = PipelineIR.from_file(tf.name) self.assertEqual(pipeline, loaded_pipeline)
def testReadContracts(self): # Verify that contracts are read in from a pipeline location = os.path.expandvars("$PIPE_BASE_DIR/tests/testPipeline1.yaml") pipeline = PipelineIR.from_file(location) self.assertEqual(pipeline.contracts[0].contract, "modA.b == modA.c") # Verify that a contract message is loaded pipeline_str = textwrap.dedent(""" description: Test Pipeline tasks: modA: test.modA modB: class: test.modB contracts: - contract: modA.foo == modB.Bar msg: "Test message" """) pipeline = PipelineIR.from_string(pipeline_str) self.assertEqual(pipeline.contracts[0].msg, "Test message")