-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Source Hubspot: fix 401 for associations (#15156)
* Revert "Source Hubspot: revert v0.1.78 (#15144)" This reverts commit cbdb897. * #379 source hubspot: fix 401 when reading associations * #379 source hubspot: fix 401 when reading associations * #379 source hubspot: upd changelog * auto-bump connector version [ci skip] Co-authored-by: Octavia Squidington III <[email protected]>
- Loading branch information
1 parent
9dd045d
commit 09d6901
Showing
9 changed files
with
161 additions
and
18 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
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
19 changes: 19 additions & 0 deletions
19
airbyte-integrations/connectors/source-hubspot/integration_tests/conftest.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,19 @@ | ||
# | ||
# Copyright (c) 2022 Airbyte, Inc., all rights reserved. | ||
# | ||
|
||
import json | ||
|
||
import pytest | ||
|
||
|
||
@pytest.fixture(scope="session", name="config") | ||
def config_fixture(): | ||
with open("secrets/config.json", "r") as config_file: | ||
return json.load(config_file) | ||
|
||
|
||
@pytest.fixture(scope="session", name="oauth_config") | ||
def oauth_config_fixture(): | ||
with open("secrets/config_oauth.json", "r") as config_file: | ||
return json.load(config_file) |
57 changes: 57 additions & 0 deletions
57
airbyte-integrations/connectors/source-hubspot/integration_tests/test_associations.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,57 @@ | ||
# | ||
# Copyright (c) 2022 Airbyte, Inc., all rights reserved. | ||
# | ||
|
||
import logging | ||
|
||
import pytest | ||
from airbyte_cdk.models import ConfiguredAirbyteCatalog, Type | ||
from source_hubspot.source import SourceHubspot | ||
|
||
|
||
@pytest.fixture | ||
def source(): | ||
return SourceHubspot() | ||
|
||
|
||
@pytest.fixture | ||
def associations(config, source): | ||
streams = source.streams(config) | ||
return {stream.name: getattr(stream, "associations", []) for stream in streams} | ||
|
||
|
||
@pytest.fixture | ||
def configured_catalog(config, source): | ||
streams = source.streams(config) | ||
return { | ||
"streams": [ | ||
{ | ||
"stream": stream.as_airbyte_stream(), | ||
"sync_mode": "incremental", | ||
"cursor_field": [stream.cursor_field], | ||
"destination_sync_mode": "append", | ||
} | ||
for stream in streams | ||
if stream.supports_incremental and getattr(stream, "associations", []) | ||
] | ||
} | ||
|
||
|
||
@pytest.mark.parametrize("auth", ("api_key", "oauth")) | ||
def test_incremental_read_fetches_associations(auth, config, oauth_config, configured_catalog, source, associations): | ||
configuration = oauth_config if auth == "oauth" else config | ||
messages = source.read(logging.getLogger("airbyte"), configuration, ConfiguredAirbyteCatalog.parse_obj(configured_catalog), {}) | ||
|
||
association_found = False | ||
for message in messages: | ||
if message and message.type != Type.RECORD: | ||
continue | ||
record = message.record | ||
stream, data = record.stream, record.data | ||
# assume at least one association id is present | ||
stream_associations = associations[stream] | ||
for association in stream_associations: | ||
if data.get(association): | ||
association_found = True | ||
break | ||
assert association_found |
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
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