testing c2 import
This commit is contained in:
@@ -716,6 +716,10 @@ def mocked_requests(*args, **kwargs):
|
||||
with open('rowers/tests/testdata/c2_timezone.json','r') as infile:
|
||||
c2timezoneworkoutdata = json.load(infile)
|
||||
|
||||
with open('rowers/tests/testdata/c2_timezone2.json','r') as infile:
|
||||
c2timezoneworkoutdata2 = json.load(infile)
|
||||
|
||||
|
||||
with open('rowers/tests/testdata/c2jsonstrokedata.txt','r') as infile:
|
||||
c2strokedata = json.load(infile)
|
||||
|
||||
@@ -1186,6 +1190,8 @@ def mocked_requests(*args, **kwargs):
|
||||
elif c2importtester.match(args[0]):
|
||||
if '12' in args[0]:
|
||||
return MockResponse(c2workoutdata,200)
|
||||
elif '31' in args[0]:
|
||||
return MockResponse(c2timezoneworkoutdata2,200)
|
||||
else:
|
||||
return MockResponse(c2timezoneworkoutdata,200)
|
||||
elif c2workoutlisttester.match(args[0]):
|
||||
|
||||
@@ -276,6 +276,24 @@ class C2Objects(DjangoTestCase):
|
||||
w = Workout.objects.get(id=2)
|
||||
self.assertEqual(w.timezone,'Europe/Prague')
|
||||
|
||||
@patch('rowers.c2stuff.requests.get', side_effect=mocked_requests)
|
||||
@patch('rowers.dataprep.create_engine')
|
||||
def test_c2_import_tz2(self, mock_get, mocked_sqlalchemy):
|
||||
|
||||
response = self.c.get('/rowers/workout/c2import/31/',follow=True)
|
||||
|
||||
self.assertRedirects(response,
|
||||
expected_url='/rowers/workout/'+encoded2+'/edit/',
|
||||
status_code=302,target_status_code=200)
|
||||
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
w = Workout.objects.get(id=2)
|
||||
self.assertEqual(w.timezone,'Europe/Amsterdam')
|
||||
|
||||
self.assertEqual(w.starttime.strftime("%H:%M:%S"),"20:04:56")
|
||||
|
||||
|
||||
|
||||
@patch('rowers.dataprep.create_engine')
|
||||
def test_strokedata(self, mocked_sqlalchemy):
|
||||
|
||||
Reference in New Issue
Block a user