diff --git a/tap_google_ads/__init__.py b/tap_google_ads/__init__.py index 4830d9f..00f2c37 100644 --- a/tap_google_ads/__init__.py +++ b/tap_google_ads/__init__.py @@ -17,8 +17,7 @@ "refresh_token", "customer_ids", "developer_token", - "schemaless", - "version" + "schemaless" ] @@ -27,7 +26,7 @@ def main_impl(): resource_schema = create_resource_schema(args.config) state = {} - LOGGER.info(f"Sync Starting with google-ads api {args.config['version']} version.") + LOGGER.info(f"Sync Starting with google-ads api.") if args.state: state.update(args.state) if args.discover: diff --git a/tap_google_ads/streams.py b/tap_google_ads/streams.py index ca8a543..7b102f4 100644 --- a/tap_google_ads/streams.py +++ b/tap_google_ads/streams.py @@ -83,7 +83,9 @@ def get_selected_fields(stream_mdata): if mdata["breadcrumb"]: inclusion = mdata["metadata"].get("inclusion") selected = mdata["metadata"].get("selected") - if utils.should_sync_field(inclusion, selected) and mdata["breadcrumb"][1] != "_sdc_record_hash" and "tap-google-ads.api-field-names" in mdata["metadata"]: + if utils.should_sync_field(inclusion, selected) \ + and mdata["breadcrumb"][1] != "_sdc_record_hash" \ + and "tap-google-ads.api-field-names" in mdata["metadata"]: selected_fields.update(mdata["metadata"]["tap-google-ads.api-field-names"]) return selected_fields @@ -756,7 +758,6 @@ def sync(self, sdk_client, customer, stream, config, state, query_limit, schemal transformed_obj = self.transform_keys(json_message) record = transformer.transform(transformed_obj, stream["schema"]) record["_sdc_record_hash"] = generate_hash(record, stream_mdata) - singer.write_record(stream_name, record) else: singer.write_record(stream_name, json_message) diff --git a/tap_google_ads/sync.py b/tap_google_ads/sync.py index b32dd15..4a64fe0 100644 --- a/tap_google_ads/sync.py +++ b/tap_google_ads/sync.py @@ -72,6 +72,7 @@ def get_query_limit(config): def do_sync(config, catalog, resource_schema, state): # QA ADDED WORKAROUND [START] + try: customers = json.loads(config["customer_ids"]) except TypeError: # falling back to raw value diff --git a/tap_google_ads/tests/base.py b/tap_google_ads/tests/base.py index 30424bf..db512cd 100644 --- a/tap_google_ads/tests/base.py +++ b/tap_google_ads/tests/base.py @@ -46,14 +46,14 @@ def get_properties(self): 'end_date': '2018-04-15T00:00:00Z', 'conversion_window_days' : '-1', 'user_id': 'not used?', - 'customer_ids': os.getenv('TAP_ADWORDS_CUSTOMER_IDS')} + 'customer_ids': os.getenv('TAP_ADS_CUSTOMER_IDS')} @staticmethod def get_credentials(self): - return {'developer_token': os.getenv('TAP_ADWORDS_DEVELOPER_TOKEN'), - 'oauth_client_id': os.getenv('TAP_ADWORDS_OAUTH_CLIENT_ID'), - 'oauth_client_secret': os.getenv('TAP_ADWORDS_OAUTH_CLIENT_SECRET'), - 'refresh_token': os.getenv('TAP_ADWORDS_REFRESH_TOKEN')} + return {'developer_token': os.getenv('TAP_ADS_DEVELOPER_TOKEN'), + 'oauth_client_id': os.getenv('TAP_ADS_OAUTH_CLIENT_ID'), + 'oauth_client_secret': os.getenv('TAP_ADS_OAUTH_CLIENT_SECRET'), + 'refresh_token': os.getenv('TAP_ADS_REFRESH_TOKEN')} def expected_metadata(self): """The expected streams and metadata about the streams""" @@ -235,11 +235,11 @@ def expected_replication_method(self): def setUp(self): - missing_envs = [x for x in [os.getenv('TAP_ADWORDS_DEVELOPER_TOKEN'), - os.getenv('TAP_ADWORDS_OAUTH_CLIENT_ID'), - os.getenv('TAP_ADWORDS_OAUTH_CLIENT_SECRET'), - os.getenv('TAP_ADWORDS_REFRESH_TOKEN'), - os.getenv('TAP_ADWORDS_CUSTOMER_IDS')] if x == None] + missing_envs = [x for x in [os.getenv('TAP_ADS_DEVELOPER_TOKEN'), + os.getenv('TAP_ADS_OAUTH_CLIENT_ID'), + os.getenv('TAP_ADS_OAUTH_CLIENT_SECRET'), + os.getenv('TAP_ADS_REFRESH_TOKEN'), + os.getenv('TAP_ADS_CUSTOMER_IDS')] if x == None] if len(missing_envs) != 0: raise Exception("Missing environment variables: {}".format(missing_envs)) diff --git a/tests/base.py b/tests/base.py index 5bd8e5d..707e552 100644 --- a/tests/base.py +++ b/tests/base.py @@ -56,7 +56,7 @@ def get_properties(self, original: bool = True): 'query_limit': 2, # 'conversion_window_days': '30', 'login_customer_ids': [{"customerId": os.getenv('TAP_GOOGLE_ADS_CUSTOMER_ID'), - "loginCustomerId": os.getenv('TAP_GOOGLE_ADS_LOGIN_CUSTOMER_ID'),}], + "loginCustomerId": os.getenv('TAP_GOOGLE_ADS_LOGIN_CUSTOMER_ID')}], } if original: @@ -458,11 +458,11 @@ def expected_replication_method(self): def setUp(self): - missing_envs = [x for x in [os.getenv('TAP_ADWORDS_DEVELOPER_TOKEN'), - os.getenv('TAP_ADWORDS_OAUTH_CLIENT_ID'), - os.getenv('TAP_ADWORDS_OAUTH_CLIENT_SECRET'), - os.getenv('TAP_ADWORDS_REFRESH_TOKEN'), - os.getenv('TAP_ADWORDS_CUSTOMER_IDS')] if x == None] + missing_envs = [x for x in [os.getenv('TAP_ADS_DEVELOPER_TOKEN'), + os.getenv('TAP_ADS_OAUTH_CLIENT_ID'), + os.getenv('TAP_ADS_OAUTH_CLIENT_SECRET'), + os.getenv('TAP_ADS_REFRESH_TOKEN'), + os.getenv('TAP_ADS_CUSTOMER_IDS')] if x == None] if len(missing_envs) != 0: raise Exception("Missing environment variables: {}".format(missing_envs))