Copilot commented on code in PR #62840:
URL: https://github.com/apache/airflow/pull/62840#discussion_r2881472832


##########
providers/salesforce/tests/unit/salesforce/operators/test_bulk.py:
##########
@@ -29,6 +29,18 @@ class TestSalesforceBulkOperator:
     Test class for SalesforceBulkOperator
     """
 
+    def test_template_fields(self):
+        """
+        Test that template_fields are correctly defined.
+        """
+        operator = SalesforceBulkOperator(
+            task_id="test_template_fields",
+            operation="insert",
+            object_name="Account",
+            payload=[],
+        )
+        assert operator.template_fields == ("operation", "object_name", 
"payload", "external_id_field")
+

Review Comment:
   `test_template_fields` only asserts the tuple value, but doesn't verify that 
templating actually works (e.g., that `operation`, `object_name`, and nested 
values inside `payload` get rendered) nor that validation happens after 
rendering. Consider rendering the operator with `render_template_fields(...)` 
(or `operator.render_template_fields(...)`) using a simple Jinja expression and 
asserting the rendered attributes / that `execute()` succeeds with mocked 
Salesforce connection.
   ```suggestion
           Test that template_fields are correctly defined and rendered.
           """
           operator = SalesforceBulkOperator(
               task_id="test_template_fields",
               operation="{{ op }}",
               object_name="{{ obj }}",
               payload=[{"Name": "{{ name }}"}],
           )
           assert operator.template_fields == ("operation", "object_name", 
"payload", "external_id_field")
   
           # Verify that templating is applied to all template fields, 
including nested payload values.
           context = {"op": "insert", "obj": "Account", "name": "account1"}
           operator.render_template_fields(context=context)
   
           assert operator.operation == "insert"
           assert operator.object_name == "Account"
           assert operator.payload == [{"Name": "account1"}]
   ```



-- 
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