Esempio n. 1
0
 def test_initialization(self):
     f = fbkit.Facebook(app_id=my_app_id, app_secret=my_app_secret)
     self.assertEquals(f.app_id, my_app_id)
     self.assertEquals(f.app_secret, my_app_secret)
     self.assertEquals(f.auth_token, None)
     self.assertEquals(f.app_name, None)
     self.assertEquals(f.canvas_url, None)
Esempio n. 2
0
 def test_login_url(self):
     response = 'abcdef'
     self.urlopen.next_response = simplejson.dumps(response)
     fb = fbkit.Facebook(my_app_secret, app_id=my_app_id)
     fb.auth.createToken()
     self.assertEquals(str(fb.auth_token), "abcdef")
     url = fb.get_login_url(next="nowhere", popup=True)
     expected = ('https://graph.facebook.com/oauth/authorize?'
                 'redirect_uri=nowhere&display=popup&client_id=%s' %
                 my_app_id)
     self.assertEquals(url, expected)
Esempio n. 3
0
 def test_validate_session(self):
     session = {
         'sig': 'e1e94eca2c0085d0ebd7ed8216337e67',
         'lorem': 'ipsum',
         'dolor': 'sit amet'
     }
     session_json = simplejson.dumps(session)
     fb = fbkit.Facebook(my_app_secret, app_id=my_app_id)
     self.assertEqual(fb.validate_oauth_session(session_json), {
         'lorem': 'ipsum',
         'dolor': 'sit amet'
     })
Esempio n. 4
0
 def test_session_parse(self):
     response = {'stuff': 'abcd'}
     self.urlopen.next_response = simplejson.dumps(response)
     fb = fbkit.Facebook(my_app_secret, app_id=my_app_id)
     fb.auth.createToken()
     self.assertEquals(str(fb.auth_token['stuff']), "abcd")
     response = {
         "session_key": "key",
         "uid": "my_uid",
         "secret": "my_secret",
         "expires": "my_expires"
     }
     self.urlopen.next_response = simplejson.dumps(response)
     res = fb.auth.getSession()
     self.assertEquals(str(res["expires"]), response["expires"])
     self.assertEquals(str(res["secret"]), response["secret"])
     self.assertEquals(str(res["session_key"]), response["session_key"])
     self.assertEquals(str(res["uid"]), response["uid"])