-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[source-hubspot] bump cdk, implement rfr for contacts_form_submission…
…s, contact_list_memberships, contact_merged_audit, and mock server tests
- Loading branch information
Showing
16 changed files
with
1,242 additions
and
109 deletions.
There are no files selected for viewing
353 changes: 318 additions & 35 deletions
353
airbyte-integrations/connectors/source-hubspot/poetry.lock
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
60 changes: 60 additions & 0 deletions
60
...tions/connectors/source-hubspot/unit_tests/integrations/test_contacts_form_submissions.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,60 @@ | ||
# Copyright (c) 2024 Airbyte, Inc., all rights reserved. | ||
|
||
import freezegun | ||
from airbyte_cdk.test.mock_http import HttpMocker | ||
from airbyte_protocol.models import AirbyteStateBlob, AirbyteStateMessage, AirbyteStateType, AirbyteStreamState, StreamDescriptor, SyncMode | ||
|
||
from . import HubspotContactsTestCase | ||
from .request_builders.streams import ContactsStreamRequestBuilder | ||
|
||
|
||
@freezegun.freeze_time("2024-05-04T00:00:00Z") | ||
class TestContactsFormSubmissionsStream(HubspotContactsTestCase): | ||
SCOPES = ["crm.objects.contacts.read"] | ||
STREAM_NAME = "contacts_form_submissions" | ||
|
||
@HttpMocker() | ||
def test_read_multiple_contact_pages(self, http_mocker: HttpMocker): | ||
self.mock_oauth(http_mocker, self.ACCESS_TOKEN) | ||
self.mock_scopes(http_mocker, self.ACCESS_TOKEN, self.SCOPES) | ||
self.mock_custom_objects(http_mocker) | ||
|
||
self.mock_response(http_mocker, ContactsStreamRequestBuilder().with_filter("formSubmissionMode", "all").build(), self.response(stream_name=self.STREAM_NAME, with_pagination=True).build()) | ||
self.mock_response(http_mocker, ContactsStreamRequestBuilder().with_filter("formSubmissionMode", "all").with_vid_offset("5331889818").build(), self.response(stream_name=self.STREAM_NAME).build()) | ||
|
||
output = self.read_from_stream(self.oauth_config(), self.STREAM_NAME, SyncMode.full_refresh) | ||
|
||
assert len(output.records) == 16 | ||
assert output.state_messages[0].state.stream.stream_state.dict() == {"vidOffset": "5331889818"} | ||
assert output.state_messages[0].state.stream.stream_descriptor.name == self.STREAM_NAME | ||
assert output.state_messages[0].state.sourceStats.recordCount == 8 | ||
assert output.state_messages[1].state.stream.stream_state.dict() == {} | ||
assert output.state_messages[1].state.stream.stream_descriptor.name == self.STREAM_NAME | ||
assert output.state_messages[1].state.sourceStats.recordCount == 8 | ||
|
||
@HttpMocker() | ||
def test_read_from_incoming_state(self, http_mocker: HttpMocker): | ||
state = [ | ||
AirbyteStateMessage( | ||
type=AirbyteStateType.STREAM, | ||
stream=AirbyteStreamState( | ||
stream_descriptor=StreamDescriptor(name=self.STREAM_NAME), | ||
stream_state=AirbyteStateBlob(**{"vidOffset": "5331889818"}) | ||
) | ||
) | ||
] | ||
|
||
self.mock_oauth(http_mocker, self.ACCESS_TOKEN) | ||
self.mock_scopes(http_mocker, self.ACCESS_TOKEN, self.SCOPES) | ||
self.mock_custom_objects(http_mocker) | ||
|
||
# Even though we only care about the request with a vidOffset parameter, we mock this in order to pass the availability check | ||
self.mock_response(http_mocker, ContactsStreamRequestBuilder().with_filter("formSubmissionMode", "all").build(), self.response(stream_name=self.STREAM_NAME, with_pagination=True).build()) | ||
self.mock_response(http_mocker, ContactsStreamRequestBuilder().with_filter("formSubmissionMode", "all").with_vid_offset("5331889818").build(), self.response(stream_name=self.STREAM_NAME).build()) | ||
|
||
output = self.read_from_stream(cfg=self.oauth_config(), stream=self.STREAM_NAME, sync_mode=SyncMode.full_refresh, state=state) | ||
|
||
assert len(output.records) == 8 | ||
assert output.state_messages[0].state.stream.stream_state.dict() == {} | ||
assert output.state_messages[0].state.stream.stream_descriptor.name == self.STREAM_NAME | ||
assert output.state_messages[0].state.sourceStats.recordCount == 8 |
Oops, something went wrong.