Skip to content

Commit

Permalink
fixed test for batch > 50
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Chan committed Apr 10, 2014
1 parent 55cee17 commit 334231c
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions tests/test_graph_api.py
Expand Up @@ -516,15 +516,22 @@ def test_batch_error_references_request():
def test_batch_over_50_requests():
graph = GraphAPI('<access_token')

mock_request.return_value.content = json.dumps([
{
'code': 200,
'headers': [
{'name': 'Content-Type', 'value': 'text/javascript; charset=UTF-8'}
],
'body': '{"foo": "bar"}'
} for i in xrange(60)
])
def side_effect_batch_size(*args, **kwargs):
batch_size = len(json.loads(kwargs['data']['batch']))
if batch_size > 50:
return MagicMock(content='{"error":{"message":"Too many requests in batch message. Maximum batch size is 50","type":"GraphBatchException"}}')
else:
return MagicMock(content=json.dumps([
{
'code': 200,
'headers': [
{'name': 'Content-Type', 'value': 'text/javascript; charset=UTF-8'}
],
'body': '{"foo": "bar"}'
} for i in xrange(batch_size)
]))

mock_request.side_effect = side_effect_batch_size

requests = [dict(method="GET", relative_url="me?fields=username") for i in xrange(60)]

Expand Down

0 comments on commit 334231c

Please sign in to comment.