From c21e176830ca67fc4a7d2d012bf156cffaa18ec0 Mon Sep 17 00:00:00 2001 From: Matthew Madurski Date: Thu, 26 Feb 2015 15:38:44 -0500 Subject: [PATCH 1/4] Rename id param in get_object() to object_id In order to specify 'id' as a keyword argument, we cannot use 'id' as a positional argument name. --- facebook/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/facebook/__init__.py b/facebook/__init__.py index 46ab1fe8..9bc91168 100755 --- a/facebook/__init__.py +++ b/facebook/__init__.py @@ -105,9 +105,9 @@ def __init__(self, access_token=None, timeout=None, version=None): else: self.version = "v" + default_version - def get_object(self, id, **args): + def get_object(self, object_id, **args): """Fetchs the given object from the graph.""" - return self.request(self.version + "/" + id, args) + return self.request(self.version + "/" + object_id, args) def get_objects(self, ids, **args): """Fetchs all of the given object from the graph. From cf83c7f4a31b3fe150397ad0c57be614d811e86a Mon Sep 17 00:00:00 2001 From: Matthew Madurski Date: Sat, 28 Feb 2015 21:45:25 -0500 Subject: [PATCH 2/4] test case for get_object --- test/test_facebook.py | 11 +++++++++++ 1 file changed, 11 insertions(+) mode change 100644 => 100755 test/test_facebook.py diff --git a/test/test_facebook.py b/test/test_facebook.py old mode 100644 new mode 100755 index f6013e78..7bcb34fb --- a/test/test_facebook.py +++ b/test/test_facebook.py @@ -130,5 +130,16 @@ def test_auth_url(self): self.assertEqual(actual_query, expected_query) +class TestGetObject(FacebookTestCase): + def test_get_object(self): + graph = facebook.GraphAPI(access_token=facebook.get_app_access_token( + self.app_id, self.secret), version=2.0) + + graph_obj = graph.get_object( + '', id='http://facebook.com', fields='og_object{comments}') + + self.assertIsNotNone(graph_obj) + + if __name__ == '__main__': unittest.main() From c0d52f77c91334cfda715b0616d8e8d6383bedae Mon Sep 17 00:00:00 2001 From: Matthew Madurski Date: Sat, 28 Feb 2015 21:48:19 -0500 Subject: [PATCH 3/4] add comments and specify version=2.1 --- test/test_facebook.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/test_facebook.py b/test/test_facebook.py index 7bcb34fb..d77adec7 100755 --- a/test/test_facebook.py +++ b/test/test_facebook.py @@ -132,13 +132,14 @@ def test_auth_url(self): class TestGetObject(FacebookTestCase): def test_get_object(self): + # The value we are passing as 'fields' is valid only in 2.1+. graph = facebook.GraphAPI(access_token=facebook.get_app_access_token( - self.app_id, self.secret), version=2.0) - + self.app_id, self.secret), version=2.1) + # We should be able to use 'id' as a keyword argument. graph_obj = graph.get_object( '', id='http://facebook.com', fields='og_object{comments}') - self.assertIsNotNone(graph_obj) + self.assertTrue(graph_obj is not None) if __name__ == '__main__': From f1026643c5534a467561652603f482d9b189c5b1 Mon Sep 17 00:00:00 2001 From: Matthew Madurski Date: Sun, 1 Mar 2015 20:19:21 -0500 Subject: [PATCH 4/4] update to use GraphAPI.get_app_access_token --- test/test_facebook.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/test_facebook.py b/test/test_facebook.py index d77adec7..f8df6707 100755 --- a/test/test_facebook.py +++ b/test/test_facebook.py @@ -133,8 +133,9 @@ def test_auth_url(self): class TestGetObject(FacebookTestCase): def test_get_object(self): # The value we are passing as 'fields' is valid only in 2.1+. - graph = facebook.GraphAPI(access_token=facebook.get_app_access_token( - self.app_id, self.secret), version=2.1) + graph = facebook.GraphAPI(version=2.1) + graph.access_token = graph.get_app_access_token( + self.app_id, self.secret) # We should be able to use 'id' as a keyword argument. graph_obj = graph.get_object( '', id='http://facebook.com', fields='og_object{comments}')