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

🎉 Source Iterable: Add email validation to list_users stream method execution (#8380)

* Update iterable.md docs.

* Update `Events` stream to use `export/userEvents` endpoint.
Update `events` stream schema.
Add `test_events_parse_response` unit test.

* Update events parse_response data collection.
Update events stream unit tests.
Update events stream schema.

* Bump docker version
This commit is contained in:
Vadym
2021-12-06 21:07:51 +02:00
committed by GitHub
parent 1bde075f14
commit 17504e978e
9 changed files with 256 additions and 18 deletions

View File

@@ -0,0 +1,201 @@
#
# Copyright (c) 2021 Airbyte, Inc., all rights reserved.
#
import json
import pytest
import requests
import responses
from source_iterable.api import Events
@responses.activate
@pytest.mark.parametrize(
"response_objects,expected_objects,jsonl_body",
[
(
[
{
"createdAt": "2021",
"signupSource": "str",
"emailListIds": [1],
"itblInternal": {"documentUpdatedAt": "2021", "documentCreatedAt": "202"},
"_type": "str",
"messageTypeIds": [],
"channelIds": [],
"email": "test@mail.com",
"profileUpdatedAt": "2021",
},
{
"productRecommendationCount": 1,
"campaignId": 1,
"itblInternal": {"documentUpdatedAt": "2021", "documentCreatedAt": "2021"},
"contentId": 1,
"_type": "1",
"messageId": "1",
"messageBusId": "1",
"templateId": 1,
"createdAt": "2021",
"messageTypeId": 1,
"catalogCollectionCount": 1,
"catalogLookupCount": 0,
"email": "test@mail.com",
"channelId": 1,
},
{
"createdAt": "2021",
"campaignId": 1,
"itblInternal": {"documentUpdatedAt": "2021", "documentCreatedAt": "2021"},
"_type": "str",
"messageId": "1",
"templateId": 1,
"recipientState": "str",
"email": "test@mail.com",
},
{
"unsubSource": "str",
"createdAt": "2021",
"emailListIds": [],
"itblInternal": {"documentUpdatedAt": "2021", "documentCreatedAt": "2021"},
"_type": "str",
"messageId": "1",
"messageTypeIds": [],
"channelIds": [1],
"templateId": 1,
"recipientState": "str",
"email": "test@mail.com",
},
],
[],
False,
),
(
[
{
"createdAt": "2021",
"signupSource": "str",
"emailListIds": [1],
"itblInternal": {"documentUpdatedAt": "2021", "documentCreatedAt": "202"},
"_type": "str",
"messageTypeIds": [],
"channelIds": [],
"email": "test@mail.com",
"profileUpdatedAt": "2021",
}
],
[],
False,
),
(
[
{
"createdAt": "2021",
"signupSource": "str",
"emailListIds": [1],
"itblInternal": {"documentUpdatedAt": "2021", "documentCreatedAt": "202"},
"_type": "str",
"messageTypeIds": [],
"channelIds": [],
"email": "test@mail.com",
"profileUpdatedAt": "2021",
},
{
"productRecommendationCount": 1,
"campaignId": 1,
"itblInternal": {"documentUpdatedAt": "2021", "documentCreatedAt": "2021"},
"contentId": 1,
"_type": "1",
"messageId": "1",
"messageBusId": "1",
"templateId": 1,
"createdAt": "2021",
"messageTypeId": 1,
"catalogCollectionCount": 1,
"catalogLookupCount": 0,
"email": "test@mail.com",
"channelId": 1,
},
],
[
{
"itblInternal": {"documentUpdatedAt": "2021", "documentCreatedAt": "202"},
"_type": "str",
"createdAt": "2021",
"email": "test@mail.com",
"data": {
"signupSource": "str",
"emailListIds": [1],
"messageTypeIds": [],
"channelIds": [],
"profileUpdatedAt": "2021",
},
},
{
"itblInternal": {"documentUpdatedAt": "2021", "documentCreatedAt": "2021"},
"_type": "1",
"createdAt": "2021",
"email": "test@mail.com",
"data": {
"productRecommendationCount": 1,
"campaignId": 1,
"contentId": 1,
"messageId": "1",
"messageBusId": "1",
"templateId": 1,
"messageTypeId": 1,
"catalogCollectionCount": 1,
"catalogLookupCount": 0,
"channelId": 1,
},
},
],
True,
),
(
[
{
"createdAt": "2021",
"signupSource": "str",
"emailListIds": [1],
"itblInternal": {"documentUpdatedAt": "2021", "documentCreatedAt": "202"},
"_type": "str",
"messageTypeIds": [],
"channelIds": [],
"email": "test@mail.com",
"profileUpdatedAt": "2021",
}
],
[
{
"itblInternal": {"documentUpdatedAt": "2021", "documentCreatedAt": "202"},
"_type": "str",
"createdAt": "2021",
"email": "test@mail.com",
"data": {
"signupSource": "str",
"emailListIds": [1],
"messageTypeIds": [],
"channelIds": [],
"profileUpdatedAt": "2021",
},
}
],
True,
),
],
)
def test_events_parse_response(response_objects, expected_objects, jsonl_body):
if jsonl_body:
response_body = "\n".join([json.dumps(obj) for obj in response_objects])
else:
response_body = json.dumps(response_objects)
responses.add(responses.GET, "https://example.com", body=response_body)
response = requests.get("https://example.com")
stream = Events(api_key="key")
if jsonl_body:
records = [record for record in stream.parse_response(response)]
assert records == expected_objects
else:
with pytest.raises(TypeError):
[record for record in stream.parse_response(response)]

View File

@@ -1,7 +0,0 @@
#
# Copyright (c) 2021 Airbyte, Inc., all rights reserved.
#
def test_example_method():
assert True