Taragolis commented on code in PR #28403:
URL: https://github.com/apache/airflow/pull/28403#discussion_r1050626409


##########
tests/providers/amazon/aws/operators/test_glue.py:
##########
@@ -16,20 +16,62 @@
 # under the License.
 from __future__ import annotations
 
+import copy
 from unittest import mock
 
 import pytest
 
 from airflow.configuration import conf
+from airflow.models import DAG, DagRun, TaskInstance
 from airflow.providers.amazon.aws.hooks.glue import GlueJobHook
 from airflow.providers.amazon.aws.hooks.s3 import S3Hook
 from airflow.providers.amazon.aws.operators.glue import GlueJobOperator
+from airflow.utils import timezone
+
+TASK_ID = "test_glue_operator"
+DAG_ID = "test_dag_id"
+JOB_NAME = "test_job_name"
+DEFAULT_DATE = timezone.datetime(2017, 1, 1)
+
+BASE_LOCATION = "some-bucket/{{ task_instance_key_str }}"
+SCRIPT_LOCATION = f"s3://{BASE_LOCATION}/script-location.py"
+CREATE_JOB_KWARGS = {
+    "GlueVersion": "4.0",
+    "Command": {
+        "Name": "glueetl",
+        "ScriptLocation": SCRIPT_LOCATION,
+    },
+    "WorkerType": "G.1X",
+    "NumberOfWorkers": 2,
+}
+EXPECTED_BASE_LOCATION = f"some-bucket/{DAG_ID}__{TASK_ID}__20170101"
 
 
 class TestGlueJobOperator:
     def setup_method(self):
         conf.load_test_config()
 
+    def test_render_template(self):
+        args = {"owner": "airflow", "start_date": DEFAULT_DATE}
+
+        dag = DAG(DAG_ID, default_args=args)
+        mock_operator = GlueJobOperator(
+            task_id=TASK_ID, dag=dag, create_job_kwargs=CREATE_JOB_KWARGS, 
s3_bucket=BASE_LOCATION
+        )
+
+        dag_run = DagRun(dag_id=mock_operator.dag_id, 
execution_date=DEFAULT_DATE, run_id="test")
+        ti = TaskInstance(task=mock_operator)
+        ti.dag_run = dag_run

Review Comment:
   Sorry wrong fixture correct one: 
[`create_task_instance_of_operator`](https://github.com/apache/airflow/blob/4d0fa01f72ac4a947db2352e18f4721c2e2ec7a3/tests/conftest.py#L769-L770),
 we want to provide specific operator, rather than use EmptyOperator



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