added c2list test
This commit is contained in:
1
rowers/testdata/c2workoutlist.txt
vendored
Normal file
1
rowers/testdata/c2workoutlist.txt
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -61,6 +61,8 @@ def mocked_requests_get(*args, **kwargs):
|
||||
with open('rowers/testdata/c2jsonstrokedata.txt','r') as infile:
|
||||
c2strokedata = json.load(infile)
|
||||
|
||||
c2workoutlist = json.load(open('rowers/testdata/c2workoutlist.txt'))
|
||||
|
||||
class MockResponse:
|
||||
def __init__(self, json_data, status_code):
|
||||
self.json_data = json_data
|
||||
@@ -72,6 +74,8 @@ def mocked_requests_get(*args, **kwargs):
|
||||
if 'log.concept2.com/' in args[0]:
|
||||
if 'strokes' in args[0]:
|
||||
return MockResponse(c2strokedata,200)
|
||||
elif 'page' in args[0]:
|
||||
return MockResponse(c2workoutlist,200)
|
||||
else:
|
||||
return MockResponse(c2workoutdata,200)
|
||||
|
||||
@@ -95,11 +99,17 @@ class C2Objects(DjangoTestCase):
|
||||
self.r.c2token = '12'
|
||||
self.r.tokenexpirydate = datetime.datetime.now()+datetime.timedelta(days=1)
|
||||
self.r.save()
|
||||
self.c.login(username='john',password='koeinsloot')
|
||||
|
||||
|
||||
@patch('rowers.c2stuff.requests.get', side_effect=mocked_requests_get)
|
||||
def test_c2_list(self, mock_get):
|
||||
response = self.c.get('/rowers/workout/c2list',follow=True)
|
||||
|
||||
self.assertEqual(response.status_code,200)
|
||||
|
||||
@patch('rowers.c2stuff.requests.get', side_effect=mocked_requests_get)
|
||||
def test_c2_import(self, mock_get):
|
||||
self.c.login(username='john',password='koeinsloot')
|
||||
|
||||
response = self.c.get('/rowers/workout/c2import/12/',follow=True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user