gemini-code-assist[bot] commented on code in PR #37260:
URL: https://github.com/apache/beam/pull/37260#discussion_r2677746254


##########
sdks/python/apache_beam/yaml/yaml_transform_unit_test.py:
##########
@@ -1099,6 +1099,33 @@ def 
test_expand_pipeline_with_incorrect_pipelines_key_fails(self):
       with self.assertRaises(KeyError):
         expand_pipeline(p, spec, validate_schema=None)
 
+  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')
+
+  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')

Review Comment:
   ![high](https://www.gstatic.com/codereviewagent/high-priority.svg)
   
   These new tests depend on the `jsonschema` library, which is an optional 
dependency for Beam YAML features. If `jsonschema` is not installed, these 
tests will fail with an `AttributeError` because `jsonschema` will be `None`.
   
   To prevent this, you should add a decorator to skip these tests if 
`jsonschema` is not available, similar to how `MainTest` is decorated in this 
file.
   
   ```python
     @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')
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to