added test for c2 auto import
This commit is contained in:
@@ -699,7 +699,8 @@ def mocked_requests(*args, **kwargs):
|
||||
pass
|
||||
|
||||
def post(self, *args, **kwargs):
|
||||
return MockResponse('',200)
|
||||
json_data = {'id':1}
|
||||
return MockResponse(json_data,200)
|
||||
|
||||
def send(self,prepped):
|
||||
# prepped.url
|
||||
@@ -710,7 +711,7 @@ def mocked_requests(*args, **kwargs):
|
||||
json_data = {
|
||||
'access_token': 'TA3n1vrNjuQJWw0TdCDHnjSmrjIPULhTlejMIWqq',
|
||||
'expires_in': 604800,
|
||||
'refresh_token': 'jHJhFzCfOOKB8oyiayubhLAlxaMkG3ruC1E8YxaR'
|
||||
'refresh_token': 'jHJhFzCfOOKB8oyiayubhLAlxaMkG3ruC1E8YxaR',
|
||||
}
|
||||
|
||||
return MockResponse(json_data,200)
|
||||
|
||||
@@ -13,6 +13,7 @@ nu = datetime.datetime.now()
|
||||
import rowers
|
||||
from rowers import dataprep
|
||||
from rowers import tasks
|
||||
from rowers import c2stuff
|
||||
|
||||
@pytest.mark.django_db
|
||||
@override_settings(TESTING=True)
|
||||
@@ -195,7 +196,6 @@ class C2Objects(DjangoTestCase):
|
||||
def test_c2_callback(self, mock_Session):
|
||||
response = self.c.get('/call_back?code=dsdoij232s',follow=True)
|
||||
|
||||
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
|
||||
@@ -205,6 +205,19 @@ class C2Objects(DjangoTestCase):
|
||||
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
@patch('rowers.c2stuff.requests.post', side_effect=mocked_requests)
|
||||
@patch('rowers.c2stuff.requests.get', side_effect=mocked_requests)
|
||||
@patch('rowers.c2stuff.requests.session', side_effect=mocked_requests)
|
||||
def test_c2_auto_import(self, mock_get, mock_post,MockSession):
|
||||
self.r.sporttracks_auto_export = True
|
||||
self.r.save()
|
||||
res = c2stuff.get_c2_workouts(self.r)
|
||||
self.assertEqual(res,1)
|
||||
|
||||
res = c2stuff.get_c2_workouts(self.r,do_async=False)
|
||||
self.assertEqual(res,1)
|
||||
|
||||
|
||||
|
||||
@patch('rowers.c2stuff.requests.post', side_effect=mocked_requests)
|
||||
@patch('rowers.c2stuff.requests.get', side_effect=mocked_requests)
|
||||
|
||||
Reference in New Issue
Block a user