forked from airbytehq/airbyte
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Source Bing Ads: added TaxCertificate field to accounts schema (air…
- Loading branch information
1 parent
3c02cdb
commit 7216e92
Showing
8 changed files
with
162 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ requires = [ "poetry-core>=1.0.0",] | |
build-backend = "poetry.core.masonry.api" | ||
|
||
[tool.poetry] | ||
version = "2.4.0" | ||
version = "2.5.0" | ||
name = "source-bing-ads" | ||
description = "Source implementation for Bing Ads." | ||
authors = [ "Airbyte <[email protected]>",] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...e-integrations/connectors/source-bing-ads/unit_tests/integrations/test_accounts_stream.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Copyright (c) 2023 Airbyte, Inc., all rights reserved. | ||
from typing import Any, Dict, Optional, Tuple | ||
from unittest.mock import MagicMock, patch | ||
|
||
from airbyte_cdk.models import SyncMode | ||
from airbyte_cdk.test.catalog_builder import CatalogBuilder | ||
from airbyte_cdk.test.entrypoint_wrapper import EntrypointOutput, read | ||
from airbyte_cdk.test.mock_http import HttpMocker | ||
from base_test import BaseTest | ||
from source_bing_ads.source import SourceBingAds | ||
from suds.transport.https import HttpAuthenticated | ||
from suds_response_mock import mock_http_authenticated_send | ||
|
||
|
||
class TestAccountsStream(BaseTest): | ||
stream_name = "accounts" | ||
|
||
def read_stream( | ||
self, | ||
stream_name: str, | ||
sync_mode: SyncMode, | ||
config: Dict[str, Any], | ||
state: Optional[Dict[str, Any]] = None, | ||
expecting_exception: bool = False, | ||
) -> Tuple[EntrypointOutput, MagicMock]: | ||
with patch.object(HttpAuthenticated, "send", mock_http_authenticated_send): | ||
catalog = CatalogBuilder().with_stream(stream_name, sync_mode).build() | ||
return read(SourceBingAds(), config, catalog, state, expecting_exception) | ||
|
||
@HttpMocker() | ||
def test_read_accounts_tax_certificate_data(self, http_mocker): | ||
# Our account doesn't have configured Tax certificate. | ||
self.auth_client(http_mocker) | ||
output = self.read_stream(self.stream_name, SyncMode.full_refresh, self._config) | ||
assert output.records[0].record.data["TaxCertificate"] == { | ||
"Status": "Active", | ||
"TaxCertificateBlobContainerName": "Test Container Name", | ||
"TaxCertificates": [{"key": "test_key", "value": "test_value"}], | ||
} |
75 changes: 75 additions & 0 deletions
75
airbyte-integrations/connectors/source-bing-ads/unit_tests/test_base_streams.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# | ||
# Copyright (c) 2023 Airbyte, Inc., all rights reserved. | ||
# | ||
|
||
from unittest.mock import patch | ||
|
||
import pytest | ||
import source_bing_ads | ||
from source_bing_ads.base_streams import Accounts | ||
|
||
|
||
@patch.object(source_bing_ads.source, "Client") | ||
@pytest.mark.parametrize( | ||
"record, expected", | ||
[ | ||
( | ||
{ | ||
"AccountId": 16253412, | ||
"TaxCertificate": { | ||
"TaxCertificates": {"KeyValuePairOfstringbase64Binary": [{"key": "test key", "value": "test value"}]}, | ||
"Status": "Active", | ||
"TaxCertificateBlobContainerName": "Test Container Name", | ||
}, | ||
}, | ||
{ | ||
"AccountId": 16253412, | ||
"TaxCertificate": { | ||
"TaxCertificates": [{"key": "test key", "value": "test value"}], | ||
"Status": "Active", | ||
"TaxCertificateBlobContainerName": "Test Container Name", | ||
}, | ||
}, | ||
), | ||
( | ||
{ | ||
"AccountId": 16253412, | ||
"TaxCertificate": { | ||
"TaxCertificates": [{"key": "test key", "value": "test value"}], | ||
"Status": "Active", | ||
"TaxCertificateBlobContainerName": "Test Container Name", | ||
}, | ||
}, | ||
{ | ||
"AccountId": 16253412, | ||
"TaxCertificate": { | ||
"TaxCertificates": [{"key": "test key", "value": "test value"}], | ||
"Status": "Active", | ||
"TaxCertificateBlobContainerName": "Test Container Name", | ||
}, | ||
}, | ||
), | ||
( | ||
{ | ||
"AccountId": 16253412, | ||
}, | ||
{ | ||
"AccountId": 16253412, | ||
}, | ||
), | ||
( | ||
{"AccountId": 16253412, "TaxCertificate": None}, | ||
{"AccountId": 16253412, "TaxCertificate": None}, | ||
), | ||
], | ||
ids=[ | ||
"record_with_KeyValuePairOfstringbase64Binary_field", | ||
"record_without_KeyValuePairOfstringbase64Binary_field", | ||
"record_without_TaxCertificate_field", | ||
"record_with_TaxCertificate_is_None", | ||
], | ||
) | ||
def test_accounts_transform_tax_fields(mocked_client, config, record, expected): | ||
stream = Accounts(mocked_client, config) | ||
actual = stream._transform_tax_fields(record) | ||
assert actual == expected |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters