def test_facebook_fetch_user(self): client = OAuthClient('a', 'b', api_base_url='https://facebook.com/api') client.set_token({'access_token': 'a', 'token_type': 'bearer'}) client.session.send = mock_json_response({ 'id': 1, 'name': 'Hsiaoming', 'email': '[email protected]' }) user = facebook_fetch_user(client) self.assertEqual(user.id, 1) self.assertEqual(user.name, 'Hsiaoming')
def test_google_fetch_user(self): client = OAuthClient('a', 'b', api_base_url='https://google.com/api') client.set_token({'access_token': 'a', 'token_type': 'bearer'}) client.session.send = mock_json_response({ 'sub': 1, 'name': 'Grey Li', 'email': '[email protected]' }) user = google_fetch_user(client) self.assertEqual(user.id, 1) self.assertEqual(user.name, 'Grey Li')
def test_dropbox_fetch_user(self): client = OAuthClient('a', 'b', api_base_url='https://dropbox.com/api') client.set_token({'access_token': 'a', 'token_type': 'bearer'}) client.session.send = mock_json_response({ 'account_id': 1, 'name': { 'display_name': 'Hsiaoming' }, 'email': '[email protected]' }) user = dropbox_fetch_user(client) self.assertEqual(user.id, 1) self.assertEqual(user.name, 'Hsiaoming')
def test_twitter_fetch_user(self): client = OAuthClient('a', 'b', request_token_url='https://i.b', api_base_url='https://twitter.com/api') client.set_token({'oauth_token': 'a', 'oauth_token_secret': 'b'}) client.session.send = mock_json_response({ 'id': 1, 'name': 'Hsiaoming', 'email': '[email protected]' }) user = twitter_fetch_user(client) self.assertEqual(user.id, 1) self.assertEqual(user.name, 'Hsiaoming')