Private
Public Access
1
0

passing test_imports

This commit is contained in:
Sander Roosendaal
2023-02-11 17:48:39 +01:00
parent def98b9a85
commit 3a82d91d2a
4 changed files with 12 additions and 7 deletions

View File

@@ -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]

View File

@@ -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)

View File

@@ -1366,7 +1366,7 @@ def mocked_requests(*args, **kwargs):
if stravatester.match(args[0]):
if stravaworkoutlisttester.match(args[0]):
return MockResponse(stravaworkoutlist,200)

View File

@@ -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)