Skip to content

Commit 712e947

Browse files
authored
Address issues found while testing with tap-salesforce (#11)
* Address issues found while testing with tap-salesforce - Recognize ACTIVE_VERSION messages - Disable GzipAdapter - Update dependencies
1 parent 7a7b84f commit 712e947

File tree

5 files changed

+17
-10
lines changed

5 files changed

+17
-10
lines changed

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ def find_version(*paths):
6262
],
6363
packages=find_packages(),
6464
install_requires=[
65-
'backoff>=1.4.3,<2.0a',
65+
'backoff>=1.3.0,<2.0a',
6666
'click>=6.7,<7.0a',
6767
'jsonschema>=2.6.0,<3.0a',
6868
'pyjwt>=1.5.3,<2.0a',
69-
'requests>=2.18.4,<3.0a',
70-
'singer-python==2.1.0',
69+
'requests>=2.4.0,<3.0a',
70+
'singer-python>=5.0.4,<6.0a',
7171
],
7272
setup_requires=[
7373
'pytest-runner>=2.11,<3.0a',

target_datadotworld/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@
2121

2222
import singer
2323

24-
__version__ = '1.0.0b2'
24+
__version__ = '1.0.0b3'
2525

2626
logger = copy(singer.get_logger()) # copy needed in order to set level

target_datadotworld/api_client.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,10 @@ def __init__(self, api_token, **kwargs):
5757
'User-Agent': 'target-datadotworld - {}'.format(__version__)
5858
}
5959
self._session.headers.update(default_headers)
60+
61+
# TODO Fix and turn GzipAdapter back on (GH Issue #10)
6062
self._session.mount(self._api_url,
61-
BackoffAdapter(GzipAdapter(HTTPAdapter())))
63+
BackoffAdapter(HTTPAdapter()))
6264

6365
# Create a limited thread pool.
6466
self._executor = ThreadPoolExecutor(
@@ -101,7 +103,8 @@ def append_stream(self, owner, dataset, stream, records):
101103
'{}/streams/{}/{}/{}'.format(
102104
self._api_url, owner, dataset, stream),
103105
data=to_jsonlines(records).encode('utf-8'),
104-
headers={'Content-Type': 'application/json-l'}
106+
headers={'Content-Type':
107+
'application/json-l; charset=utf-8'}
105108
).raise_for_status()
106109
except RequestException as e:
107110
raise convert_requests_exception(e)
@@ -210,7 +213,8 @@ def create_dataset(self, owner, dataset, **kwargs):
210213
raise convert_requests_exception(e)
211214

212215

213-
class GzipAdapter(BaseAdapter):
216+
# TODO Re-enable test coverage (GH issue #10)
217+
class GzipAdapter(BaseAdapter): # pragma: no cover
214218
def __init__(self, delegate):
215219
"""Requests adapter for compressing request bodies
216220

target_datadotworld/target.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,10 @@ async def process_lines(self, lines, loop=None):
171171
elif isinstance(msg, singer.StateMessage):
172172
logger.info('State message found: {}'.format(msg.value))
173173
state = msg.value
174+
elif isinstance(msg, singer.ActivateVersionMessage):
175+
logger.info('Version message found: {}/{}'.format(
176+
msg.stream, msg.version))
177+
# TODO Handle Active Version Messages (GH Issue #2)
174178
else:
175179
raise Error('Unrecognized message'.format(msg))
176180

tests/target_datadotworld/test_api_client.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
# data.world, Inc.(http://data.world/).
1919

2020
import asyncio
21-
import gzip
2221
import time
2322

2423
import pytest
@@ -48,7 +47,7 @@ def verify_body_and_count(req):
4847
nonlocal call_count, all_records
4948

5049
assert_that(
51-
gzip.decompress(req.body).decode('utf-8'),
50+
req.body.decode('utf-8'),
5251
equal_to(to_jsonlines(all_records)))
5352

5453
call_count += 1
@@ -83,7 +82,7 @@ def verify_body_and_count(req):
8382
expected_records = all_records[first_record:last_record]
8483

8584
assert_that(
86-
gzip.decompress(req.body).decode('utf-8'),
85+
req.body.decode('utf-8'),
8786
equal_to(to_jsonlines(expected_records)))
8887

8988
call_count += 1

0 commit comments

Comments
 (0)