Skip to content

Commit

Permalink
Adding a test for extra requests when paginating
Browse files Browse the repository at this point in the history
  • Loading branch information
maraujop committed Jun 22, 2012
1 parent 70a7624 commit 1722b00
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/test_graph_api.py
Expand Up @@ -123,6 +123,31 @@ def test_get():
}
)

@with_setup(mock, unmock)
def test_paged_get_avoid_extra_request():
graph = GraphAPI('<access token>')
limit = 2

mock_request.return_value.content = json.dumps({
'data': [
{
'message': 'He\'s a complicated man. And the only one that understands him is his woman',
},
],
'paging': {
'next': 'https://graph.facebook.com/herc/posts?limit=%(limit)s&offset=%(limit)s&value=1&access_token=<access token>' % {
'limit': limit
}
}
})

pages = graph.get('herc/posts', page=True, limit=limit)

for index, page in enumerate(pages):
pass

assert_equal(index, 0)

@with_setup(mock, unmock)
def test_get_with_retries():
graph = GraphAPI(TEST_USER_ACCESS_TOKEN)
Expand Down

0 comments on commit 1722b00

Please sign in to comment.