Skip to content

Instantly share code, notes, and snippets.

@jaraco
Last active November 28, 2018 17:28
Show Gist options
  • Save jaraco/13038365bfc1f17c65b2b27dc0bf87a8 to your computer and use it in GitHub Desktop.
Save jaraco/13038365bfc1f17c65b2b27dc0bf87a8 to your computer and use it in GitHub Desktop.
__requires__ = ['pytest-responses', 'pytest']
import requests
def test_paginated_request(responses):
responses.add(
responses.GET,
'https://service.test/api/paginated/',
json=dict(
objects=[1, 2, 3],
meta=dict(next='/api/paginated/?start=4'),
),
)
responses.add(
responses.GET,
'https://service.test/api/paginated/?start=4',
json=dict(
objects=[4, 5, 6],
),
)
requests.get('https://service.test/api/paginated/')
doc = requests.get('https://service.test/api/paginated/?start=4').json()
assert doc['objects'] == [4, 5, 6]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment