small timezone related change
This commit is contained in:
@@ -1604,7 +1604,6 @@ def save_workout_database(f2, r, dosmooth=True, workouttype='rower',
|
|||||||
|
|
||||||
startdatetime,startdate,starttime,timezone_str,partofday = get_startdate_time_zone(r,row,startdatetime=startdatetime)
|
startdatetime,startdate,starttime,timezone_str,partofday = get_startdate_time_zone(r,row,startdatetime=startdatetime)
|
||||||
|
|
||||||
|
|
||||||
if title is None or title == '':
|
if title is None or title == '':
|
||||||
title = 'Workout'
|
title = 'Workout'
|
||||||
|
|
||||||
@@ -1766,6 +1765,7 @@ def save_workout_database(f2, r, dosmooth=True, workouttype='rower',
|
|||||||
|
|
||||||
timezone_str = str(workoutstartdatetime.tzinfo)
|
timezone_str = str(workoutstartdatetime.tzinfo)
|
||||||
|
|
||||||
|
|
||||||
w = Workout(user=r, name=title, date=workoutdate,
|
w = Workout(user=r, name=title, date=workoutdate,
|
||||||
workouttype=workouttype,
|
workouttype=workouttype,
|
||||||
boattype=boattype,
|
boattype=boattype,
|
||||||
@@ -1896,6 +1896,8 @@ def get_startdate_time_zone(r,row,startdatetime=None):
|
|||||||
else:
|
else:
|
||||||
timezone_str = str(startdatetime.tzinfo)
|
timezone_str = str(startdatetime.tzinfo)
|
||||||
|
|
||||||
|
startdatetime = startdatetime.astimezone(pytz.timezone(timezone_str))
|
||||||
|
|
||||||
startdate = startdatetime.strftime('%Y-%m-%d')
|
startdate = startdatetime.strftime('%Y-%m-%d')
|
||||||
starttime = startdatetime.strftime('%H:%M:%S')
|
starttime = startdatetime.strftime('%H:%M:%S')
|
||||||
|
|
||||||
|
|||||||
@@ -834,6 +834,45 @@ class ViewTest(TestCase):
|
|||||||
except (FileNotFoundError,OSError):
|
except (FileNotFoundError,OSError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@patch('rowers.dataprep.create_engine')
|
||||||
|
def test_upload_boatcoach_timezone(self, mocked_sqlalchemy):
|
||||||
|
self.r.defaulttimezone = 'US/Pacific'
|
||||||
|
self.r.save()
|
||||||
|
self.c.login(username='john',password='koeinsloot')
|
||||||
|
|
||||||
|
filename = 'rowers/tests/testdata/boatcoach_2021-09-09__18-15-53.csv'
|
||||||
|
f = open(filename,'rb')
|
||||||
|
file_data = {'file':f}
|
||||||
|
form_data = {
|
||||||
|
'title':'test',
|
||||||
|
'workouttype':'rower',
|
||||||
|
'boattype':'1x',
|
||||||
|
'notes':'aap noot mies',
|
||||||
|
'rpe':4,
|
||||||
|
'make_plot':False,
|
||||||
|
'upload_to_c2':False,
|
||||||
|
'plottype':'timeplot',
|
||||||
|
'raceid':0,
|
||||||
|
'landingpage':'workout_edit_view',
|
||||||
|
'file': f,
|
||||||
|
}
|
||||||
|
|
||||||
|
form = DocumentsForm(form_data,file_data)
|
||||||
|
|
||||||
|
response = self.c.post('/rowers/workout/upload/', form_data, follow=True)
|
||||||
|
self.assertRedirects(response, expected_url='/rowers/workout/'+encoded1+'/edit/',
|
||||||
|
status_code=302,target_status_code=200)
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
|
w = Workout.objects.get(id=1)
|
||||||
|
|
||||||
|
self.assertEqual(w.starttime,datetime.time(18,15,55))
|
||||||
|
want = arrow.get('2021-09-09 18:15:55.800000-07:00').isoformat()
|
||||||
|
got = arrow.get(w.startdatetime.astimezone(pytz.timezone(w.timezone))).isoformat()
|
||||||
|
self.assertEqual(got, want)
|
||||||
|
|
||||||
|
self.assertEqual(w.timezone,'US/Pacific')
|
||||||
|
|
||||||
@patch('rowers.dataprep.create_engine')
|
@patch('rowers.dataprep.create_engine')
|
||||||
def test_upload_view_sled_boatcoach(self, mocked_sqlalchemy):
|
def test_upload_view_sled_boatcoach(self, mocked_sqlalchemy):
|
||||||
self.c.login(username='john',password='koeinsloot')
|
self.c.login(username='john',password='koeinsloot')
|
||||||
|
|||||||
5302
rowers/tests/testdata/boatcoach_2021-09-07__11-35-01.csv
vendored
Normal file
5302
rowers/tests/testdata/boatcoach_2021-09-07__11-35-01.csv
vendored
Normal file
File diff suppressed because it is too large
Load Diff
5211
rowers/tests/testdata/boatcoach_2021-09-09__18-15-53.csv
vendored
Normal file
5211
rowers/tests/testdata/boatcoach_2021-09-09__18-15-53.csv
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
Normal file
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
Normal file
Binary file not shown.
Reference in New Issue
Block a user