Skip to content

Commit

Permalink
Merge mobolic#341 (request method's args default again).
Browse files Browse the repository at this point in the history
  • Loading branch information
martey committed Jan 6, 2017
2 parents 8e02bef + bd40c39 commit a3931ab
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
5 changes: 3 additions & 2 deletions facebook/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,15 +232,16 @@ def get_version(self):
raise GraphAPIError("API version number not available")

def request(
self, path, args=dict(), post_args=None, files=None, method=None):
self, path, args=None, post_args=None, files=None, method=None):
"""Fetches the given path in the Graph API.
We translate args to a valid query string. If post_args is
given, we send a POST request to the given path with the given
arguments.
"""

if args is None:
args = dict()
if post_args is not None:
method = "POST"

Expand Down
17 changes: 17 additions & 0 deletions test/test_facebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,23 @@ def test_request(self):
result = graph.request(FB_OBJECT_ID)
self.assertEqual(result["created_time"], "2016-12-24T05:20:55+0000")

def test_request_access_tokens_are_unique_to_instances(self):
"""Verify that access tokens are unique to each GraphAPI object."""
graph1 = facebook.GraphAPI(access_token="foo")
graph2 = facebook.GraphAPI(access_token="bar")
# We use `delete_object` so that the access_token will appear
# in request.__defaults__.
try:
graph1.delete_object("baz")
except facebook.GraphAPIError:
pass
try:
graph2.delete_object("baz")
except facebook.GraphAPIError:
pass
self.assertEqual(graph1.request.__defaults__[0], None)
self.assertEqual(graph2.request.__defaults__[0], None)


if __name__ == '__main__':
unittest.main()

0 comments on commit a3931ab

Please sign in to comment.