-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix iterable memory consumption (#7591)
- Loading branch information
Dmytro
authored
Nov 3, 2021
1 parent
a915034
commit 0c2fcb8
Showing
8 changed files
with
70 additions
and
6 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
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 |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
"requests~=2.25", | ||
] | ||
|
||
TEST_REQUIREMENTS = ["pytest~=6.1"] | ||
TEST_REQUIREMENTS = ["pytest~=6.1", "responses==0.13.3"] | ||
|
||
|
||
setup( | ||
|
@@ -20,6 +20,9 @@ | |
author="Airbyte", | ||
author_email="[email protected]", | ||
packages=find_packages(), | ||
install_requires=MAIN_REQUIREMENTS + TEST_REQUIREMENTS, | ||
install_requires=MAIN_REQUIREMENTS, | ||
extras_require={ | ||
"tests": TEST_REQUIREMENTS, | ||
}, | ||
package_data={"": ["*.json", "schemas/*.json"]}, | ||
) |
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
3 changes: 3 additions & 0 deletions
3
airbyte-integrations/connectors/source-iterable/unit_tests/__init__.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,3 @@ | ||
# | ||
# Copyright (c) 2021 Airbyte, Inc., all rights reserved. | ||
# |
42 changes: 42 additions & 0 deletions
42
airbyte-integrations/connectors/source-iterable/unit_tests/test_exports_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,42 @@ | ||
# | ||
# Copyright (c) 2021 Airbyte, Inc., all rights reserved. | ||
# | ||
|
||
import json | ||
from unittest import mock | ||
|
||
import pytest | ||
import responses | ||
from airbyte_cdk.models import SyncMode | ||
from source_iterable.api import EmailSend | ||
|
||
|
||
@pytest.fixture | ||
def session_mock(): | ||
with mock.patch("airbyte_cdk.sources.streams.http.http.requests") as requests_mock: | ||
session_mock = mock.MagicMock() | ||
response_mock = mock.MagicMock() | ||
requests_mock.Session.return_value = session_mock | ||
session_mock.send.return_value = response_mock | ||
response_mock.status_code = 200 | ||
yield session_mock | ||
|
||
|
||
def test_send_email_stream(session_mock): | ||
stream = EmailSend(start_date="2020", api_key="") | ||
_ = list(stream.read_records(sync_mode=SyncMode.full_refresh, cursor_field=None, stream_slice=[], stream_state={})) | ||
|
||
assert session_mock.send.called | ||
send_args = session_mock.send.call_args[1] | ||
assert send_args.get("stream") is True | ||
|
||
|
||
@responses.activate | ||
def test_stream_correct(): | ||
record_js = {"createdAt": "2020"} | ||
NUMBER_OF_RECORDS = 10 ** 2 | ||
resp_body = "\n".join([json.dumps(record_js)] * NUMBER_OF_RECORDS) | ||
responses.add("GET", "https://api.iterable.com/api/export/data.json", body=resp_body) | ||
stream = EmailSend(start_date="2020", api_key="") | ||
records = list(stream.read_records(sync_mode=SyncMode.full_refresh, cursor_field=None, stream_slice=[], stream_state={})) | ||
assert len(records) == NUMBER_OF_RECORDS |
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