def test_execute(self, hook_mock): op = GoogleAnalyticsGetAdsLinkOperator( account_id=ACCOUNT_ID, web_property_id=WEB_PROPERTY_ID, web_property_ad_words_link_id=WEB_PROPERTY_AD_WORDS_LINK_ID, 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.get_ad_words_link.assert_called_once() hook_mock.assert_called_once_with( gcp_conn_id=GCP_CONN_ID, api_version=API_VERSION ) hook_mock.return_value.get_ad_words_link.assert_called_once_with( account_id=ACCOUNT_ID, web_property_id=WEB_PROPERTY_ID, web_property_ad_words_link_id=WEB_PROPERTY_AD_WORDS_LINK_ID, )
def test_execute(self, hook_mock): account_id = "the_knight_who_says_ni!" web_property_id = "42" web_property_ad_words_link_id = "holy_hand_grenade" op = GoogleAnalyticsGetAdsLinkOperator( account_id=account_id, web_property_id=web_property_id, web_property_ad_words_link_id=web_property_ad_words_link_id, api_version=API_VERSION, gcp_connection_id=GCP_CONN_ID, task_id="test_task", ) op.execute(context=None) hook_mock.assert_called_once() hook_mock.return_value.get_ad_words_link.assert_called_once() hook_mock.assert_called_once_with( gcp_connection_id=GCP_CONN_ID, api_version=API_VERSION ) hook_mock.return_value.get_ad_words_link.assert_called_once_with( account_id=account_id, web_property_id=web_property_id, web_property_ad_words_link_id=web_property_ad_words_link_id, )
WEB_PROPERTY_AD_WORDS_LINK_ID = os.environ.get("GA_WEB_PROPERTY_AD_WORDS_LINK_ID", "rQafFTPOQdmkx4U-fxUfhj") DATA_ID = "kjdDu3_tQa6n8Q1kXFtSmg" with models.DAG( "example_google_analytics", schedule_interval=None, # Override to match your needs, start_date=dates.days_ago(1), ) as dag: # [START howto_marketing_platform_list_accounts_operator] list_account = GoogleAnalyticsListAccountsOperator(task_id="list_account") # [END howto_marketing_platform_list_accounts_operator] # [START howto_marketing_platform_get_ads_link_operator] get_ad_words_link = GoogleAnalyticsGetAdsLinkOperator( web_property_ad_words_link_id=WEB_PROPERTY_AD_WORDS_LINK_ID, web_property_id=WEB_PROPERTY_ID, account_id=ACCOUNT_ID, task_id="get_ad_words_link", ) # [END howto_marketing_platform_get_ads_link_operator] # [START howto_marketing_platform_retrieve_ads_links_list_operator] list_ad_words_link = GoogleAnalyticsRetrieveAdsLinksListOperator( task_id="list_ad_link", account_id=ACCOUNT_ID, web_property_id=WEB_PROPERTY_ID ) # [END howto_marketing_platform_retrieve_ads_links_list_operator] upload = GoogleAnalyticsDataImportUploadOperator( task_id="upload", storage_bucket=BUCKET, storage_name_object=BUCKET_FILENAME, account_id=ACCOUNT_ID,