Taragolis commented on code in PR #38048:
URL: https://github.com/apache/airflow/pull/38048#discussion_r1524357596
##########
tests/providers/google/cloud/operators/test_vertex_ai.py:
##########
@@ -477,6 +478,31 @@ def test_execute(self, mock_hook):
metadata=METADATA,
)
+ @pytest.mark.db_test
+ def test_templating(self, create_task_instance_of_operator):
+ ti = create_task_instance_of_operator(
+ DeleteCustomTrainingJobOperator,
+ # Templated fields
+ training_pipeline_id="{{ 'training-pipeline-id' }}",
+ custom_job_id="{{ 'custom_job_id' }}",
+ region="{{ 'region' }}",
+ project_id="{{ 'project_id' }}",
+ impersonation_chain="{{ 'impersonation-chain' }}",
+ # Other parameters
+ dag_id="test_template_body_templating_dag",
+ task_id="test_template_body_templating_task",
+ execution_date=timezone.datetime(2024, 2, 1, tzinfo=timezone.utc),
+ )
+ ti.render_templates()
+ task: DeleteCustomTrainingJobOperator = ti.task
+ assert (
+ task.training_pipeline_id,
+ task.custom_job_id,
+ task.region,
+ task.project_id,
+ task.impersonation_chain,
+ ) == ("training-pipeline-id", "custom_job_id", "region", "project_id",
"impersonation-chain")
Review Comment:
```suggestion
assert task.training_pipeline_id == "training-pipeline-id"
assert task.custom_job_id == "custom_job_id"
assert task.region == "region"
assert task.project_id == "project_id"
assert task.impersonation_chain == "impersonation-chain"
# Deprecated aliases
with pytest.warns(AirflowProviderDeprecationWarning):
assert task.training_pipeline == "training-pipeline-id"
with pytest.warns(AirflowProviderDeprecationWarning):
assert task.custom_job == "custom_job_id"
```
1. Simplify assert - each field separate assert
2. Also check that deprecated aliases also rendered, do not forget to import
`AirflowProviderDeprecationWarning`
--
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]