passing test_imports
This commit is contained in:
@@ -128,13 +128,17 @@ class SyncIntegration(metaclass=ABCMeta):
|
|||||||
try:
|
try:
|
||||||
expires_in = token_json['expires_in']
|
expires_in = token_json['expires_in']
|
||||||
except KeyError: # pragma: no cover
|
except KeyError: # pragma: no cover
|
||||||
expires_in = 0
|
try:
|
||||||
|
expires_at = arrow.get(token_json['expires_at']).timestamp()
|
||||||
|
expires_in = expires_at - arrow.now().timestamp()
|
||||||
|
except KeyError: # pragma: no cover
|
||||||
|
expires_in = 0
|
||||||
try:
|
try:
|
||||||
expires_in = int(expires_in)
|
expires_in = int(expires_in)
|
||||||
except (ValueError, TypeError): # pragma: no cover
|
except (ValueError, TypeError): # pragma: no cover
|
||||||
expires_in = 0
|
expires_in = 0
|
||||||
else: # pragma: no cover
|
else: # pragma: no cover
|
||||||
raise NoTokenError("Failed to obtain token")
|
raise NoTokenError("Failed to obtain token")
|
||||||
|
|
||||||
return [thetoken, expires_in, refresh_token]
|
return [thetoken, expires_in, refresh_token]
|
||||||
|
|
||||||
|
|||||||
@@ -313,8 +313,8 @@ class StravaIntegration(SyncIntegration):
|
|||||||
def token_refresh(self, *args, **kwargs):
|
def token_refresh(self, *args, **kwargs):
|
||||||
return super(StravaIntegration, self).token_refresh(*args, **kwargs)
|
return super(StravaIntegration, self).token_refresh(*args, **kwargs)
|
||||||
|
|
||||||
def set_strava_athlete_id():
|
def set_strava_athlete_id(self, *args, **kwargs):
|
||||||
r = self.rower()
|
r = self.rower
|
||||||
if (r.stravatoken == '') or (r.stravatoken is None): # pragma: no cover
|
if (r.stravatoken == '') or (r.stravatoken is None): # pragma: no cover
|
||||||
s = "Token doesn't exist. Need to authorize"
|
s = "Token doesn't exist. Need to authorize"
|
||||||
return custom_exception_handler(401, s)
|
return custom_exception_handler(401, s)
|
||||||
|
|||||||
@@ -1366,7 +1366,7 @@ def mocked_requests(*args, **kwargs):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if stravatester.match(args[0]):
|
if stravatester.match(args[0]):
|
||||||
if stravaworkoutlisttester.match(args[0]):
|
if stravaworkoutlisttester.match(args[0]):
|
||||||
return MockResponse(stravaworkoutlist,200)
|
return MockResponse(stravaworkoutlist,200)
|
||||||
|
|||||||
@@ -1165,7 +1165,8 @@ class StravaObjects(DjangoTestCase):
|
|||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
@patch('rowers.integrations.integrations.requests.post', side_effect=mocked_requests)
|
@patch('rowers.integrations.integrations.requests.post', side_effect=mocked_requests)
|
||||||
def test_strava_callback(self, mock_post):
|
@patch('rowers.integrations.strava.requests.get', side_effect=mocked_requests)
|
||||||
|
def test_strava_callback(self, mock_post, mock_get):
|
||||||
response = self.c.get('/stravacall_back?code=absdef23&scope=read',follow=True)
|
response = self.c.get('/stravacall_back?code=absdef23&scope=read',follow=True)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user