Private
Public Access
1
0

small timezone related change

This commit is contained in:
Sander Roosendaal
2021-09-14 22:05:14 +02:00
parent 2c1e6c5909
commit 86cef108fe
5 changed files with 10556 additions and 2 deletions

View File

@@ -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)
if title is None or title == '':
title = 'Workout'
@@ -1766,6 +1765,7 @@ def save_workout_database(f2, r, dosmooth=True, workouttype='rower',
timezone_str = str(workoutstartdatetime.tzinfo)
w = Workout(user=r, name=title, date=workoutdate,
workouttype=workouttype,
boattype=boattype,
@@ -1896,6 +1896,8 @@ def get_startdate_time_zone(r,row,startdatetime=None):
else:
timezone_str = str(startdatetime.tzinfo)
startdatetime = startdatetime.astimezone(pytz.timezone(timezone_str))
startdate = startdatetime.strftime('%Y-%m-%d')
starttime = startdatetime.strftime('%H:%M:%S')

View File

@@ -216,7 +216,7 @@ class ViewTest(TestCase):
}
form = DocumentsForm(form_data,file_data)
response = self.c.post('/rowers/workout/upload/', form_data, follow=True)
f.close()
@@ -834,6 +834,45 @@ class ViewTest(TestCase):
except (FileNotFoundError,OSError):
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')
def test_upload_view_sled_boatcoach(self, mocked_sqlalchemy):
self.c.login(username='john',password='koeinsloot')

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

BIN
rowers/tests/testdata/testdata.tcx.gz vendored Normal file

Binary file not shown.