Skip to content

Commit a35f342

Browse files
authored
Migrate Google search_ads DAG to new design AIP-47 (#24298)
related: #22447, #22430
1 parent 55b1644 commit a35f342

File tree

4 files changed

+32
-49
lines changed

4 files changed

+32
-49
lines changed

docs/apache-airflow-providers-google/operators/marketing_platform/search_ads.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Inserting a report
3434
To insert a Search Ads report use the
3535
:class:`~airflow.providers.google.marketing_platform.operators.search_ads.GoogleSearchAdsInsertReportOperator`.
3636

37-
.. exampleinclude:: /../../airflow/providers/google/marketing_platform/example_dags/example_search_ads.py
37+
.. exampleinclude:: /../../tests/system/providers/google/marketing_platform/example_search_ads.py
3838
:language: python
3939
:dedent: 4
4040
: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
4646
.json`` file as this operator supports this template extension.
4747
The result is saved to :ref:`XCom <concepts:xcom>`, which allows it to be used by other operators:
4848

49-
.. exampleinclude:: /../../airflow/providers/google/marketing_platform/example_dags/example_search_ads.py
49+
.. exampleinclude:: /../../tests/system/providers/google/marketing_platform/example_search_ads.py
5050
:language: python
5151
:dedent: 4
5252
:start-after: [START howto_search_ads_get_report_id]
@@ -60,7 +60,7 @@ Awaiting for a report
6060
To wait for a report to be ready for download use
6161
:class:`~airflow.providers.google.marketing_platform.sensors.search_ads.GoogleSearchAdsReportSensor`.
6262

63-
.. exampleinclude:: /../../airflow/providers/google/marketing_platform/example_dags/example_search_ads.py
63+
.. exampleinclude:: /../../tests/system/providers/google/marketing_platform/example_search_ads.py
6464
:language: python
6565
:dedent: 4
6666
:start-after: [START howto_search_ads_get_report_operator]
@@ -78,7 +78,7 @@ Downloading a report
7878
To download a Search Ads report to Google Cloud Storage bucket use the
7979
:class:`~airflow.providers.google.marketing_platform.operators.search_ads.GoogleSearchAdsDownloadReportOperator`.
8080

81-
.. exampleinclude:: /../../airflow/providers/google/marketing_platform/example_dags/example_search_ads.py
81+
.. exampleinclude:: /../../tests/system/providers/google/marketing_platform/example_search_ads.py
8282
:language: python
8383
:dedent: 4
8484
:start-after: [START howto_search_ads_getfile_report_operator]

tests/providers/google/marketing_platform/operators/test_search_ads_system.py

Lines changed: 0 additions & 44 deletions
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.

airflow/providers/google/marketing_platform/example_dags/example_search_ads.py renamed to tests/system/providers/google/marketing_platform/example_search_ads.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
)
2929
from airflow.providers.google.marketing_platform.sensors.search_ads import GoogleSearchAdsReportSensor
3030

31+
ENV_ID = os.environ.get("SYSTEM_TESTS_ENV_ID")
32+
DAG_ID = "example_search_ads"
33+
3134
# [START howto_search_ads_env_variables]
3235
AGENCY_ID = os.environ.get("GMP_AGENCY_ID")
3336
ADVERTISER_ID = os.environ.get("GMP_ADVERTISER_ID")
@@ -45,10 +48,11 @@
4548
# [END howto_search_ads_env_variables]
4649

4750
with models.DAG(
48-
"example_search_ads",
51+
DAG_ID,
4952
schedule_interval='@once', # Override to match your needs,
5053
start_date=datetime(2021, 1, 1),
5154
catchup=False,
55+
tags=["example"],
5256
) as dag:
5357
# [START howto_search_ads_generate_report_operator]
5458
generate_report = GoogleSearchAdsInsertReportOperator(report=REPORT, task_id="generate_report")
@@ -73,3 +77,9 @@
7377
# Task dependencies created via `XComArgs`:
7478
# generate_report >> wait_for_report
7579
# generate_report >> download_report
80+
81+
82+
from tests.system.utils import get_test_run # noqa: E402
83+
84+
# Needed to run the example DAG with pytest (see: tests/system/README.md#run_via_pytest)
85+
test_run = get_test_run(dag)

0 commit comments

Comments
 (0)