1
0
mirror of synced 2025-12-25 02:09:19 -05:00

[source-hubspot] - migrate deals_pipelinesto low code (#59195)

This commit is contained in:
Patrick Nilan
2025-05-07 15:37:00 -07:00
committed by GitHub
parent 1542c0f116
commit c7fe31a600
9 changed files with 189 additions and 139 deletions

View File

@@ -23,7 +23,7 @@ from .response_builder.streams import GenericResponseBuilder, HubspotStreamRespo
@freezegun.freeze_time("2024-03-03T14:42:00Z")
class HubspotTestCase:
DT_FORMAT = '%Y-%m-%dT%H:%M:%SZ'
DT_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
OBJECT_ID = "testID"
ACCESS_TOKEN = "new_access_token"
CURSOR_FIELD = "occurredAt"
@@ -51,36 +51,46 @@ class HubspotTestCase:
@classmethod
def oauth_config(cls, start_date: Optional[str] = None) -> Dict[str, Any]:
start_date = start_date or cls.dt_str(cls.start_date())
return ConfigBuilder().with_start_date(start_date).with_auth(
{
"credentials_title": "OAuth Credentials",
"redirect_uri": "https://airbyte.io",
"client_id": "client_id",
"client_secret": "client_secret",
"refresh_token": "refresh_token",
}
).build()
return (
ConfigBuilder()
.with_start_date(start_date)
.with_auth(
{
"credentials_title": "OAuth Credentials",
"redirect_uri": "https://airbyte.io",
"client_id": "client_id",
"client_secret": "client_secret",
"refresh_token": "refresh_token",
}
)
.build()
)
@classmethod
def private_token_config(cls, token: str, start_date: Optional[str] = None) -> Dict[str, Any]:
start_date = start_date or cls.dt_str(cls.start_date())
return ConfigBuilder().with_start_date(start_date).with_auth(
{
"credentials_title": "Private App Credentials",
"access_token": token,
}
).build()
return (
ConfigBuilder()
.with_start_date(start_date)
.with_auth(
{
"credentials_title": "Private App Credentials",
"access_token": token,
}
)
.build()
)
@classmethod
def mock_oauth(cls, http_mocker: HttpMocker, token: str):
creds = cls.oauth_config()["credentials"]
req = OAuthRequestBuilder().with_client_id(
creds["client_id"]
).with_client_secret(
creds["client_secret"]
).with_refresh_token(
creds["refresh_token"]
).build()
req = (
OAuthRequestBuilder()
.with_client_id(creds["client_id"])
.with_client_secret(creds["client_secret"])
.with_refresh_token(creds["refresh_token"])
.build()
)
response = GenericResponseBuilder().with_value("access_token", token).with_value("expires_in", 7200).build()
http_mocker.post(req, response)
@@ -92,7 +102,7 @@ class HubspotTestCase:
def mock_custom_objects(cls, http_mocker: HttpMocker):
http_mocker.get(
CustomObjectsRequestBuilder().build(),
HttpResponseBuilder({}, records_path=FieldPath("results"), pagination_strategy=None).build()
HttpResponseBuilder({}, records_path=FieldPath("results"), pagination_strategy=None).build(),
)
@classmethod
@@ -105,10 +115,7 @@ class HubspotTestCase:
record = record_builder().with_field(FieldPath("name"), name).with_field(FieldPath("type"), type)
response_builder = response_builder.with_record(record)
http_mocker.get(
PropertiesRequestBuilder().for_entity(object_type).build(),
response_builder.build()
)
http_mocker.get(PropertiesRequestBuilder().for_entity(object_type).build(), response_builder.build())
@classmethod
def mock_response(cls, http_mocker: HttpMocker, request, responses, method: str = "get"):

View File

@@ -16,7 +16,6 @@ from source_hubspot.streams import (
ContactsMergedAudit,
ContactsWebAnalytics,
CustomObject,
DealPipelines,
Deals,
DealsArchived,
DealSplits,
@@ -96,7 +95,7 @@ def test_updated_at_field_non_exist_handler(requests_mock, common_params, fake_p
(ContactsMergedAudit, "contact", {"updatedAt": "2022-02-25T16:43:11Z"}),
(Deals, "deal", {"updatedAt": "2022-02-25T16:43:11Z"}),
(DealsArchived, "deal", {"archivedAt": "2022-02-25T16:43:11Z"}),
(DealPipelines, "deal", {"updatedAt": 1675121674226}),
("deal_pipelines", "deal", {"updatedAt": 1675121674226}),
(DealSplits, "deal_split", {"updatedAt": "2022-02-25T16:43:11Z"}),
(EmailEvents, "", {"updatedAt": "2022-02-25T16:43:11Z"}),
("email_subscriptions", "", {"updatedAt": "2022-02-25T16:43:11Z"}),