Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Source Amazon Ads: Fix unexpected column for SponsoredProductCampaigns and SponsoredBrandsKeywords #30679

Merged
merged 14 commits into from Sep 22, 2023
Expand Up @@ -13,5 +13,5 @@ ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]


LABEL io.airbyte.version=3.2.0
LABEL io.airbyte.version=3.2.1
lazebnyi marked this conversation as resolved.
Show resolved Hide resolved
LABEL io.airbyte.name=airbyte/source-amazon-ads
Expand Up @@ -61,5 +61,7 @@ acceptance_tests:
spec:
tests:
- spec_path: integration_tests/spec.json
backward_compatibility_tests_config:
davydov-d marked this conversation as resolved.
Show resolved Hide resolved
disable_for_version: "3.2.0"
connector_image: airbyte/source-amazon-ads:dev
test_strictness_level: high
Expand Up @@ -13,6 +13,7 @@
"client_id": {
"title": "Client ID",
"description": "The client ID of your Amazon Ads developer application. See the <a href=\"https://advertising.amazon.com/API/docs/en-us/get-started/generate-api-tokens#retrieve-your-client-id-and-client-secret\">docs</a> for more information.",
"airbyte_secret": true,
"order": 1,
"type": "string"
},
Expand Down Expand Up @@ -43,7 +44,9 @@
"description": "The Start date for collecting reports, should not be more than 60 days in the past. In YYYY-MM-DD format",
"examples": ["2022-10-10", "2022-10-22"],
"order": 5,
"type": "string"
"type": "string",
"pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$",
"format": "date"
},
"profiles": {
"title": "Profile IDs",
Expand Down
Expand Up @@ -8,7 +8,7 @@ data:
connectorSubtype: api
connectorType: source
definitionId: c6b0a29e-1da9-4512-9002-7bfd0cba2246
dockerImageTag: 3.2.0
dockerImageTag: 3.2.1
dockerRepository: airbyte/source-amazon-ads
githubIssueLabel: source-amazon-ads
icon: amazonads.svg
Expand Down
Expand Up @@ -52,3 +52,8 @@ class BrandsAdGroup(CatalogModel):
adGroupId: Decimal
name: str
bid: int
keywordId: Decimal
keywordText: str
nativeLanguageKeyword: str
matchType: str
state: str
Expand Up @@ -32,6 +32,7 @@ class ProductCampaign(CatalogModel):
endDate: str = None
premiumBidAdjustment: bool
bidding: Bidding
networks: str


class ProductAdGroups(CatalogModel):
Expand Down
Expand Up @@ -17,6 +17,7 @@ connectionSpecification:
for more information.
order: 1
type: string
airbyte_secret: true
client_secret:
title: Client Secret
description:
Expand Down Expand Up @@ -51,6 +52,8 @@ connectionSpecification:
description:
The Start date for collecting reports, should not be more than
60 days in the past. In YYYY-MM-DD format
pattern: "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"
format: date
examples:
- "2022-10-10"
- "2022-10-22"
Expand Down
Expand Up @@ -3,6 +3,7 @@
#


import pytest
import responses
from airbyte_cdk.models import AirbyteConnectionStatus, AirbyteMessage, ConnectorSpecification, Status, Type
from jsonschema import Draft4Validator
Expand Down Expand Up @@ -64,25 +65,23 @@ def test_check(config_gen):
assert command_check(source, config_gen(start_date=...)) == AirbyteConnectionStatus(status=Status.SUCCEEDED)
assert len(responses.calls) == 2

assert command_check(source, config_gen(start_date="")) == AirbyteConnectionStatus(status=Status.SUCCEEDED)
assert len(responses.calls) == 4
with pytest.raises(Exception):
command_check(source, config_gen(start_date=""))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't start date optional?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is optional. But we're adding it with the wrong template in that case, that's why the error rise.


assert source.check(None, config_gen(start_date="2022-02-20")) == AirbyteConnectionStatus(status=Status.SUCCEEDED)
assert len(responses.calls) == 6
assert len(responses.calls) == 4
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did the number of calls change? I couldn't find any related changes in the code

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we update case in line 67-68 and now we handle wrong pattern, so call qty reduced


assert command_check(source, config_gen(start_date="2022-20-02")) == AirbyteConnectionStatus(
status=Status.FAILED, message="'month must be in 1..12'"
)
assert len(responses.calls) == 6
assert len(responses.calls) == 4

assert command_check(source, config_gen(start_date="no date")) == AirbyteConnectionStatus(
status=Status.FAILED, message="'String does not match format YYYY-MM-DD'"
)
assert len(responses.calls) == 6
with pytest.raises(Exception):
command_check(source, config_gen(start_date="no date"))

assert command_check(source, config_gen(region=...)) == AirbyteConnectionStatus(status=Status.SUCCEEDED)
assert len(responses.calls) == 8
assert url_strip_query(responses.calls[7].request.url) == "https://advertising-api.amazon.com/v2/profiles"
assert len(responses.calls) == 6
assert url_strip_query(responses.calls[5].request.url) == "https://advertising-api.amazon.com/v2/profiles"

assert command_check(source, config_gen(look_back_window=...)) == AirbyteConnectionStatus(status=Status.SUCCEEDED)

Expand Down
20 changes: 0 additions & 20 deletions docs/integrations/sources/amazon-ads.inapp.md

This file was deleted.

1 change: 1 addition & 0 deletions docs/integrations/sources/amazon-ads.md
Expand Up @@ -109,6 +109,7 @@ Information about expected report generation waiting time you may find [here](ht

| Version | Date | Pull Request | Subject |
|:--------|:-----------|:---------------------------------------------------------|:----------------------------------------------------------------------------------------------------------------|
| 3.2.1 | 2023-09-22 | [30679](https://github.com/airbytehq/airbyte/pull/30679) | Fix unexpected column for SponsoredProductCampaigns and SponsoredBrandsKeywords |
| 3.2.0 | 2023-09-18 | [30517](https://github.com/airbytehq/airbyte/pull/30517) | Add suggested streams; fix unexpected column issue |
| 3.1.2 | 2023-08-16 | [29233](https://github.com/airbytehq/airbyte/pull/29233) | Add filter for Marketplace IDs |
| 3.1.1 | 2023-08-28 | [29900](https://github.com/airbytehq/airbyte/pull/29900) | Add 404 handling for no assotiated with bid ad groups |
Expand Down