3
from httpretty import HTTPretty
5
from six.moves.urllib_parse import urlencode
7
from .oauth import OAuth1Test
10
class YahooOAuth1Test(OAuth1Test):
11
backend_path = 'social_core.backends.yahoo.YahooOAuth'
12
user_data_url = 'https://social.yahooapis.com/v1/user/a-guid/profile?' \
14
expected_username = 'foobar'
15
access_token_body = json.dumps({
16
'access_token': 'foobar',
17
'token_type': 'bearer'
19
request_token_body = urlencode({
20
'oauth_token_secret': 'foobar-secret',
21
'oauth_token': 'foobar',
22
'oauth_callback_confirmed': 'true'
24
guid_body = json.dumps({
26
'uri': 'https://social.yahooapis.com/v1/me/guid',
30
user_data_body = json.dumps({
33
'memberSince': '2007-12-11T14:40:30Z',
36
'imageUrl': 'http://l.yimg.com/dh/ap/social/profile/'
41
'created': '2013-03-18T04:15:08Z',
42
'uri': 'https://social.yahooapis.com/v1/user/a-guid/profile',
44
'profileUrl': 'http://profile.yahoo.com/a-guid',
48
'handle': 'foobar@yahoo.com',
53
'handle': 'foobar@email.com',
61
HTTPretty.register_uri(
63
'https://social.yahooapis.com/v1/me/guid?format=json',
69
def test_partial_pipeline(self):
70
self.do_partial_pipeline()
72
def test_get_user_details(self):
73
HTTPretty.register_uri(
77
body=self.user_data_body
79
response = requests.get(self.user_data_url)
80
user_details = self.backend.get_user_details(
81
response.json()['profile']
83
self.assertEqual(user_details['email'], 'foobar@yahoo.com')