Example #1
0
 def test_execute(self, hook_mock):
     op = GoogleAnalyticsListAccountsOperator(
         api_version=API_VERSION, gcp_conn_id=GCP_CONN_ID, task_id="test_task"
     )
     op.execute(context=None)
     hook_mock.assert_called_once()
     hook_mock.return_value.list_accounts.assert_called_once()
Example #2
0
# "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.
"""
Example Airflow DAG that shows how to use Google Analytics 360.
"""

from airflow import models
from airflow.providers.google.marketing_platform.operators.analytics import (
    GoogleAnalyticsListAccountsOperator, )
from airflow.utils import dates

default_args = {"start_date": dates.days_ago(1)}

with models.DAG(
        "example_google_analytics",
        default_args=default_args,
        schedule_interval=None,  # Override to match your needs
) as dag:
    # [START howto_marketing_platform_list_accounts_operator]
    list_account = GoogleAnalyticsListAccountsOperator(task_id="list_account")
    # [END howto_marketing_platform_list_accounts_operator]