Skip to content

Commit

Permalink
Fix strava tests and username generation. Refs #217
Browse files Browse the repository at this point in the history
  • Loading branch information
omab committed Mar 16, 2014
1 parent a8407fa commit 97993e7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
7 changes: 4 additions & 3 deletions social/backends/strava.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ def get_user_id(self, details, response):

def get_user_details(self, response):
"""Return user details from Strava account"""
username = response['athlete']['id'] # because there is no usernames on strava
# because there is no usernames on strava
username = response['athlete']['id']
first_name = response['athlete'].get('first_name', '')
email = response['athlete'].get('email', '')
return {'username': username,
return {'username': str(username),
'first_name': first_name,
'email': email}

def user_data(self, access_token, *args, **kwargs):
"""Loads user data from service"""
return self.get_json('https://www.strava.com/api/v3/athlete',
params={'access_token': access_token})
params={'access_token': access_token})
20 changes: 10 additions & 10 deletions social/tests/backends/test_strava.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class StravaOAuthTest(OAuth2Test):
backend_path = 'social.backends.strava.StravaOAuth'
user_data_url = 'https://www.strava.com/api/v3/athlete'
expected_username = 227615
expected_username = '227615'
access_token_body = json.dumps({
"access_token": "83ebeabdec09f6670863766f792ead24d61fe3f9",
"athlete": {
Expand All @@ -20,9 +20,9 @@ class StravaOAuthTest(OAuth2Test):
"state": "California",
"country": "United States",
"sex": "M",
"friend": null,
"follower": null,
"premium": true,
"friend": "null",
"follower": "null",
"premium": "true",
"created_at": "2008-01-01T17:44:00Z",
"updated_at": "2013-09-04T20:00:50Z",
"follower_count": 273,
Expand All @@ -31,9 +31,9 @@ class StravaOAuthTest(OAuth2Test):
"date_preference": "%m/%d/%Y",
"measurement_preference": "feet",
"email": "john@applestrava.com",
"clubs": [ ],
"bikes": [ ],
"shoes": [ ]
"clubs": [],
"bikes": [],
"shoes": []
}
})
user_data_body = json.dumps({
Expand All @@ -47,12 +47,12 @@ class StravaOAuthTest(OAuth2Test):
"state": "CA",
"country": "United States",
"sex": "M",
"friend": null,
"friend": "null",
"follower": "accepted",
"premium": true,
"premium": "true",
"created_at": "2011-03-19T21:59:57Z",
"updated_at": "2013-09-05T16:46:54Z",
"approve_followers": false
"approve_followers": "false"
})

def test_login(self):
Expand Down

0 comments on commit 97993e7

Please sign in to comment.