-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #346 from pcattori/response-ndjson
response.ndjson utility
- Loading branch information
Showing
6 changed files
with
65 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Response | ||
======== | ||
|
||
Utilities for working with :class:`requests.Response` . | ||
|
||
.. autofunction:: tamr_client.response.successful | ||
.. autofunction:: tamr_client.response.ndjson |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import json | ||
|
||
import responses | ||
|
||
import tamr_client as tc | ||
import tests.tamr_client.utils as utils | ||
|
||
|
||
@responses.activate | ||
def test_ndjson(): | ||
s = utils.session() | ||
|
||
records = [{"a": 1}, {"b": 2}, {"c": 3}] | ||
url = tc.URL(path="datasets/1/records") | ||
responses.add( | ||
responses.GET, str(url), body="\n".join(json.dumps(x) for x in records) | ||
) | ||
|
||
r = s.get(str(url)) | ||
|
||
ndjson = list(tc.response.ndjson(r)) | ||
assert len(ndjson) == 3 | ||
for record in ndjson: | ||
assert record in records |