Permalink
Browse files

Adding a test for extra requests when paginating

  • Loading branch information...
1 parent 70a7624 commit 1722b00ea6a207169e717d692a5d57d0152e2f1b @maraujop maraujop committed Jun 22, 2012
Showing with 25 additions and 0 deletions.
  1. +25 −0 tests/test_graph_api.py
View
@@ -124,6 +124,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)

0 comments on commit 1722b00

Please sign in to comment.