From 70eb31414e4b8b8c58cb412ccaeff61ea6403970 Mon Sep 17 00:00:00 2001 From: ChethanUK Date: Thu, 2 Jun 2022 21:54:48 +0000 Subject: [PATCH] #22467 - - AIP-47 - Migrate Tableau DAGs to new design --- .../providers/tableau/example_dags/__init__.py | 16 ---------------- .../operators.rst | 2 +- .../system/providers/tableau}/example_tableau.py | 10 ++++++++++ .../tableau}/example_tableau_refresh_workbook.py | 12 +++++++++++- 4 files changed, 22 insertions(+), 18 deletions(-) delete mode 100644 airflow/providers/tableau/example_dags/__init__.py rename {airflow/providers/tableau/example_dags => tests/system/providers/tableau}/example_tableau.py (90%) rename {airflow/providers/tableau/example_dags => tests/system/providers/tableau}/example_tableau_refresh_workbook.py (89%) diff --git a/airflow/providers/tableau/example_dags/__init__.py b/airflow/providers/tableau/example_dags/__init__.py deleted file mode 100644 index 13a83393a9124b..00000000000000 --- a/airflow/providers/tableau/example_dags/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. diff --git a/docs/apache-airflow-providers-tableau/operators.rst b/docs/apache-airflow-providers-tableau/operators.rst index c7a818480a06a7..ba250e1be41fe7 100644 --- a/docs/apache-airflow-providers-tableau/operators.rst +++ b/docs/apache-airflow-providers-tableau/operators.rst @@ -68,7 +68,7 @@ Using the Operator An example usage of the TableauOperator is as follows: -.. exampleinclude:: /../../airflow/providers/tableau/example_dags/example_tableau.py +.. exampleinclude:: /../../tests/system/providers/tableau/example_tableau.py :language: python :start-after: [START howto_operator_tableau] :end-before: [END howto_operator_tableau] diff --git a/airflow/providers/tableau/example_dags/example_tableau.py b/tests/system/providers/tableau/example_tableau.py similarity index 90% rename from airflow/providers/tableau/example_dags/example_tableau.py rename to tests/system/providers/tableau/example_tableau.py index 53aba4c0748399..14f225164e915a 100644 --- a/airflow/providers/tableau/example_dags/example_tableau.py +++ b/tests/system/providers/tableau/example_tableau.py @@ -20,12 +20,16 @@ waits until it succeeds. The second does not wait since this is an asynchronous operation and we don't know when the operation actually finishes. That's why we have another task that checks only that. """ +import os from datetime import datetime, timedelta from airflow import DAG from airflow.providers.tableau.operators.tableau import TableauOperator from airflow.providers.tableau.sensors.tableau import TableauJobStatusSensor +ENV_ID = os.environ.get("SYSTEM_TESTS_ENV_ID") +DAG_ID = "example_tableau_refresh_workbook" + with DAG( dag_id='example_tableau', default_args={'site_id': 'my_site'}, @@ -62,3 +66,9 @@ # Task dependency created via XComArgs: # task_refresh_workbook_non_blocking >> task_check_job_status + + +from tests.system.utils import get_test_run # noqa: E402 + +# Needed to run the example DAG with pytest (see: tests/system/README.md#run_via_pytest) +test_run = get_test_run(dag) diff --git a/airflow/providers/tableau/example_dags/example_tableau_refresh_workbook.py b/tests/system/providers/tableau/example_tableau_refresh_workbook.py similarity index 89% rename from airflow/providers/tableau/example_dags/example_tableau_refresh_workbook.py rename to tests/system/providers/tableau/example_tableau_refresh_workbook.py index 31579003b80aa4..cc973792c51558 100644 --- a/airflow/providers/tableau/example_dags/example_tableau_refresh_workbook.py +++ b/tests/system/providers/tableau/example_tableau_refresh_workbook.py @@ -20,14 +20,18 @@ waits until it succeeds. The second does not wait since this is an asynchronous operation and we don't know when the operation actually finishes. That's why we have another task that checks only that. """ +import os from datetime import datetime, timedelta from airflow import DAG from airflow.providers.tableau.operators.tableau import TableauOperator from airflow.providers.tableau.sensors.tableau import TableauJobStatusSensor +ENV_ID = os.environ.get("SYSTEM_TESTS_ENV_ID") +DAG_ID = "example_tableau_refresh_workbook" + with DAG( - dag_id='example_tableau_refresh_workbook', + dag_id=DAG_ID, dagrun_timeout=timedelta(hours=2), schedule_interval=None, start_date=datetime(2021, 1, 1), @@ -60,3 +64,9 @@ # Task dependency created via XComArgs: # task_refresh_workbook_non_blocking >> task_check_job_status + + +from tests.system.utils import get_test_run # noqa: E402 + +# Needed to run the example DAG with pytest (see: tests/system/README.md#run_via_pytest) +test_run = get_test_run(dag)