passing test_imports
This commit is contained in:
@@ -128,13 +128,17 @@ class SyncIntegration(metaclass=ABCMeta):
|
||||
try:
|
||||
expires_in = token_json['expires_in']
|
||||
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:
|
||||
expires_in = int(expires_in)
|
||||
except (ValueError, TypeError): # pragma: no cover
|
||||
expires_in = 0
|
||||
else: # pragma: no cover
|
||||
raise NoTokenError("Failed to obtain token")
|
||||
else: # pragma: no cover
|
||||
raise NoTokenError("Failed to obtain token")
|
||||
|
||||
return [thetoken, expires_in, refresh_token]
|
||||
|
||||
|
||||
@@ -313,8 +313,8 @@ class StravaIntegration(SyncIntegration):
|
||||
def token_refresh(self, *args, **kwargs):
|
||||
return super(StravaIntegration, self).token_refresh(*args, **kwargs)
|
||||
|
||||
def set_strava_athlete_id():
|
||||
r = self.rower()
|
||||
def set_strava_athlete_id(self, *args, **kwargs):
|
||||
r = self.rower
|
||||
if (r.stravatoken == '') or (r.stravatoken is None): # pragma: no cover
|
||||
s = "Token doesn't exist. Need to authorize"
|
||||
return custom_exception_handler(401, s)
|
||||
|
||||
@@ -1366,7 +1366,7 @@ def mocked_requests(*args, **kwargs):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if stravatester.match(args[0]):
|
||||
if stravaworkoutlisttester.match(args[0]):
|
||||
return MockResponse(stravaworkoutlist,200)
|
||||
|
||||
@@ -1165,7 +1165,8 @@ class StravaObjects(DjangoTestCase):
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
@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)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user