This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new a35f342833 Migrate Google search_ads DAG to new design AIP-47 (#24298)
a35f342833 is described below
commit a35f3428333f9ee793fac9998d76784044e3d85c
Author: Chenglong Yan <[email protected]>
AuthorDate: Mon Jun 20 06:15:39 2022 +0800
Migrate Google search_ads DAG to new design AIP-47 (#24298)
related: #22447, #22430
---
.../operators/marketing_platform/search_ads.rst | 8 ++--
.../operators/test_search_ads_system.py | 44 ----------------------
.../google/marketing_platform/__init__.py | 17 +++++++++
.../marketing_platform}/example_search_ads.py | 12 +++++-
4 files changed, 32 insertions(+), 49 deletions(-)
diff --git
a/docs/apache-airflow-providers-google/operators/marketing_platform/search_ads.rst
b/docs/apache-airflow-providers-google/operators/marketing_platform/search_ads.rst
index 4832e491b6..e91023826e 100644
---
a/docs/apache-airflow-providers-google/operators/marketing_platform/search_ads.rst
+++
b/docs/apache-airflow-providers-google/operators/marketing_platform/search_ads.rst
@@ -34,7 +34,7 @@ Inserting a report
To insert a Search Ads report use the
:class:`~airflow.providers.google.marketing_platform.operators.search_ads.GoogleSearchAdsInsertReportOperator`.
-.. exampleinclude::
/../../airflow/providers/google/marketing_platform/example_dags/example_search_ads.py
+.. exampleinclude::
/../../tests/system/providers/google/marketing_platform/example_search_ads.py
:language: python
:dedent: 4
:start-after: [START howto_search_ads_generate_report_operator]
@@ -46,7 +46,7 @@ parameters which allows you to dynamically determine values.
You can provide rep
.json`` file as this operator supports this template extension.
The result is saved to :ref:`XCom <concepts:xcom>`, which allows it to be used
by other operators:
-.. exampleinclude::
/../../airflow/providers/google/marketing_platform/example_dags/example_search_ads.py
+.. exampleinclude::
/../../tests/system/providers/google/marketing_platform/example_search_ads.py
:language: python
:dedent: 4
:start-after: [START howto_search_ads_get_report_id]
@@ -60,7 +60,7 @@ Awaiting for a report
To wait for a report to be ready for download use
:class:`~airflow.providers.google.marketing_platform.sensors.search_ads.GoogleSearchAdsReportSensor`.
-.. exampleinclude::
/../../airflow/providers/google/marketing_platform/example_dags/example_search_ads.py
+.. exampleinclude::
/../../tests/system/providers/google/marketing_platform/example_search_ads.py
:language: python
:dedent: 4
:start-after: [START howto_search_ads_get_report_operator]
@@ -78,7 +78,7 @@ Downloading a report
To download a Search Ads report to Google Cloud Storage bucket use the
:class:`~airflow.providers.google.marketing_platform.operators.search_ads.GoogleSearchAdsDownloadReportOperator`.
-.. exampleinclude::
/../../airflow/providers/google/marketing_platform/example_dags/example_search_ads.py
+.. exampleinclude::
/../../tests/system/providers/google/marketing_platform/example_search_ads.py
:language: python
:dedent: 4
:start-after: [START howto_search_ads_getfile_report_operator]
diff --git
a/tests/providers/google/marketing_platform/operators/test_search_ads_system.py
b/tests/providers/google/marketing_platform/operators/test_search_ads_system.py
deleted file mode 100644
index 9c6dfe99b1..0000000000
---
a/tests/providers/google/marketing_platform/operators/test_search_ads_system.py
+++ /dev/null
@@ -1,44 +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.
-import pytest
-
-from
airflow.providers.google.marketing_platform.example_dags.example_search_ads
import GCS_BUCKET
-from tests.providers.google.cloud.utils.gcp_authenticator import GMP_KEY
-from tests.test_utils.gcp_system_helpers import MARKETING_DAG_FOLDER,
GoogleSystemTest, provide_gcp_context
-
-# Requires the following scope:
-SCOPES = [
- "https://www.googleapis.com/auth/doubleclicksearch",
- "https://www.googleapis.com/auth/cloud-platform",
-]
-
-
[email protected]("google.marketing_platform")
[email protected]_file(GMP_KEY)
-class SearchAdsSystemTest(GoogleSystemTest):
- def setUp(self):
- super().setUp()
- self.create_gcs_bucket(GCS_BUCKET)
-
- def tearDown(self):
- self.delete_gcs_bucket(GCS_BUCKET)
- super().tearDown()
-
- @provide_gcp_context(GMP_KEY, scopes=SCOPES)
- def test_run_example_dag(self):
- self.run_dag("example_search_ads", MARKETING_DAG_FOLDER)
diff --git a/tests/system/providers/google/marketing_platform/__init__.py
b/tests/system/providers/google/marketing_platform/__init__.py
new file mode 100644
index 0000000000..217e5db960
--- /dev/null
+++ b/tests/system/providers/google/marketing_platform/__init__.py
@@ -0,0 +1,17 @@
+#
+# 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/airflow/providers/google/marketing_platform/example_dags/example_search_ads.py
b/tests/system/providers/google/marketing_platform/example_search_ads.py
similarity index 90%
rename from
airflow/providers/google/marketing_platform/example_dags/example_search_ads.py
rename to tests/system/providers/google/marketing_platform/example_search_ads.py
index 0c0e4d5775..6693d5bc47 100644
---
a/airflow/providers/google/marketing_platform/example_dags/example_search_ads.py
+++ b/tests/system/providers/google/marketing_platform/example_search_ads.py
@@ -28,6 +28,9 @@ from
airflow.providers.google.marketing_platform.operators.search_ads import (
)
from airflow.providers.google.marketing_platform.sensors.search_ads import
GoogleSearchAdsReportSensor
+ENV_ID = os.environ.get("SYSTEM_TESTS_ENV_ID")
+DAG_ID = "example_search_ads"
+
# [START howto_search_ads_env_variables]
AGENCY_ID = os.environ.get("GMP_AGENCY_ID")
ADVERTISER_ID = os.environ.get("GMP_ADVERTISER_ID")
@@ -45,10 +48,11 @@ REPORT = {
# [END howto_search_ads_env_variables]
with models.DAG(
- "example_search_ads",
+ DAG_ID,
schedule_interval='@once', # Override to match your needs,
start_date=datetime(2021, 1, 1),
catchup=False,
+ tags=["example"],
) as dag:
# [START howto_search_ads_generate_report_operator]
generate_report = GoogleSearchAdsInsertReportOperator(report=REPORT,
task_id="generate_report")
@@ -73,3 +77,9 @@ with models.DAG(
# Task dependencies created via `XComArgs`:
# generate_report >> wait_for_report
# generate_report >> download_report
+
+
+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)