[Python-modules-commits] [python-social-auth] 76/322: Fix YahooOAuth get primary email sorting order
Wolfgang Borgert
debacle at moszumanska.debian.org
Sat Dec 24 15:12:51 UTC 2016
This is an automated email from the git hooks/post-receive script.
debacle pushed a commit to tag v0.2.10
in repository python-social-auth.
commit d87e12ad3a205cebb30181a9b4c4234d538d8f72
Author: Jun Wang <wj1918 at hotmail.com>
Date: Fri Jan 2 09:04:53 2015 -0500
Fix YahooOAuth get primary email sorting order
---
social/backends/yahoo.py | 2 +-
social/tests/backends/test_yahoo.py | 26 +++++++++++++++++++++++++-
2 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/social/backends/yahoo.py b/social/backends/yahoo.py
index 746b9b3..206949e 100644
--- a/social/backends/yahoo.py
+++ b/social/backends/yahoo.py
@@ -34,7 +34,7 @@ class YahooOAuth(BaseOAuth1):
)
emails = [email for email in response.get('emails', [])
if email.get('handle')]
- emails.sort(key=lambda e: e.get('primary', False))
+ emails.sort(key=lambda e: e.get('primary', False), reverse=True)
return {'username': response.get('nickname'),
'email': emails[0]['handle'] if emails else '',
'fullname': fullname,
diff --git a/social/tests/backends/test_yahoo.py b/social/tests/backends/test_yahoo.py
index d3c87ae..ec4d21c 100644
--- a/social/tests/backends/test_yahoo.py
+++ b/social/tests/backends/test_yahoo.py
@@ -1,4 +1,5 @@
import json
+import requests
from httpretty import HTTPretty
from social.p3 import urlencode
@@ -41,7 +42,19 @@ class YahooOAuth1Test(OAuth1Test):
'isConnected': False,
'profileUrl': 'http://profile.yahoo.com/a-guid',
'guid': 'a-guid',
- 'nickname': 'foobar'
+ 'nickname': 'foobar',
+ 'emails': [{
+ 'handle': 'foobar at yahoo.com',
+ 'id': 1,
+ 'primary': True,
+ 'type': 'HOME',
+ },
+ {
+ 'handle': 'foobar at email.com',
+ 'id': 2,
+ 'type': 'HOME',
+ }],
+
}
})
@@ -56,3 +69,14 @@ class YahooOAuth1Test(OAuth1Test):
def test_partial_pipeline(self):
self.do_partial_pipeline()
+
+ def test_get_user_details(self):
+ HTTPretty.register_uri(
+ HTTPretty.GET,
+ self.user_data_url,
+ status=200,
+ body=self.user_data_body
+ )
+ response = requests.get(self.user_data_url)
+ user_details=self.backend.get_user_details(response.json()['profile'])
+ self.assertEqual(user_details['email'], 'foobar at yahoo.com')
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-social-auth.git
More information about the Python-modules-commits
mailing list