Skip to content

Fix connection errors when paginating -- fixes #120 #125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion intercom/collection_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,6 @@ def paging_info_present(self, response):
def extract_next_link(self, response):
if self.paging_info_present(response):
paging_info = response["pages"]
return paging_info["next"]
if paging_info["next"]:
next_parsed = six.moves.urllib.parse.urlparse(paging_info["next"])
return '{}?{}'.format(next_parsed.path, next_parsed.query)
2 changes: 1 addition & 1 deletion tests/unit/test_collection_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def it_keeps_iterating_if_next_link(self):
side_effect = [page1, page2]
with patch.object(Client, 'get', side_effect=side_effect) as mock_method: # noqa
emails = [user.email for user in self.client.users.all()]
eq_([call('/users', {}), call('https://api.intercom.io/users?per_page=50&page=2', {})], # noqa
eq_([call('/users', {}), call('/users?per_page=50&page=2', {})], # noqa
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A request with a hostname will fail.

mock_method.mock_calls)
eq_(emails, ['user1@example.com', 'user2@example.com', 'user3@example.com'] * 2) # noqa

Expand Down