diff --git a/sdks/python/apache_beam/yaml/yaml_transform_unit_test.py b/sdks/python/apache_beam/yaml/yaml_transform_unit_test.py index 59b1619b6512..f83697732598 100644 --- a/sdks/python/apache_beam/yaml/yaml_transform_unit_test.py +++ b/sdks/python/apache_beam/yaml/yaml_transform_unit_test.py @@ -1099,6 +1099,35 @@ def test_expand_pipeline_with_incorrect_pipelines_key_fails(self): with self.assertRaises(KeyError): expand_pipeline(p, spec, validate_schema=None) + @unittest.skipIf(jsonschema is None, "Yaml dependencies not installed") + def test_expand_pipeline_with_valid_schema(self): + spec = ''' + pipeline: + type: chain + transforms: + - type: Create + config: + elements: [1,2,3] + - type: LogForTesting + ''' + with new_pipeline() as p: + expand_pipeline(p, spec, validate_schema='generic') + + @unittest.skipIf(jsonschema is None, "Yaml dependencies not installed") + def test_expand_pipeline_with_invalid_schema(self): + spec = ''' + pipeline: + type: chain + transforms: + - name: Create + config: + elements: [1,2,3] + - type: LogForTesting + ''' + with new_pipeline() as p: + with self.assertRaises(jsonschema.ValidationError): + expand_pipeline(p, spec, validate_schema='generic') + if __name__ == '__main__': logging.getLogger().setLevel(logging.INFO)