fix
This commit is contained in:
@@ -3778,9 +3778,12 @@ def update_duplicates_on_delete(sender, instance, **kwargs):
|
|||||||
t = ww.duration
|
t = ww.duration
|
||||||
delta = datetime.timedelta(
|
delta = datetime.timedelta(
|
||||||
hours=t.hour, minutes=t.minute, seconds=t.second)
|
hours=t.hour, minutes=t.minute, seconds=t.second)
|
||||||
enddatetime = ww.startdatetime+delta
|
try:
|
||||||
if enddatetime > d.startdatetime:
|
enddatetime = ww.startdatetime+delta
|
||||||
ws2.append(ww)
|
if enddatetime > d.startdatetime:
|
||||||
|
ws2.append(ww)
|
||||||
|
except TypeError:
|
||||||
|
pass
|
||||||
|
|
||||||
if len(ws2) == 0:
|
if len(ws2) == 0:
|
||||||
d.duplicate = False
|
d.duplicate = False
|
||||||
|
|||||||
@@ -181,6 +181,30 @@ class OwnApi(TestCase):
|
|||||||
|
|
||||||
self.assertEqual(response.status_code,200)
|
self.assertEqual(response.status_code,200)
|
||||||
|
|
||||||
|
def test_strokedataform_tcx(self):
|
||||||
|
login = self.c.login(username=self.u.username, password=self.password)
|
||||||
|
self.assertTrue(login)
|
||||||
|
|
||||||
|
w = self.user_workouts[1]
|
||||||
|
|
||||||
|
url = reverse('strokedata_tcx')
|
||||||
|
|
||||||
|
with open('rowers/tests/testdata/crewnerddata.tcx') as f:
|
||||||
|
tcxdata_str = f.read()
|
||||||
|
|
||||||
|
result = get_random_file(filename='rowers/tests/testdata/thyro.csv')
|
||||||
|
|
||||||
|
request = self.factory.post(url, data = tcxdata_str, content_type='application/xml')
|
||||||
|
request.user = self.u
|
||||||
|
request.content_type = 'application/xml'
|
||||||
|
|
||||||
|
force_authenticate(request, user=self.u)
|
||||||
|
with patch('rowers.dataprep.getrowdata_db') as mock_getrowdata:
|
||||||
|
mock_getrowdata.return_value = (pd.DataFrame(),None)
|
||||||
|
response = strokedata_tcx(request)
|
||||||
|
self.assertEqual(response.status_code,200)
|
||||||
|
|
||||||
|
|
||||||
def test_strokedataform_v3(self):
|
def test_strokedataform_v3(self):
|
||||||
login = self.c.login(username=self.u.username, password=self.password)
|
login = self.c.login(username=self.u.username, password=self.password)
|
||||||
self.assertTrue(login)
|
self.assertTrue(login)
|
||||||
|
|||||||
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
Binary file not shown.
@@ -11,9 +11,11 @@ from rowers.dataroutines import get_workouttype_from_tcx, get_startdate_time_zon
|
|||||||
from rest_framework.decorators import parser_classes
|
from rest_framework.decorators import parser_classes
|
||||||
from rest_framework.parsers import BaseParser
|
from rest_framework.parsers import BaseParser
|
||||||
|
|
||||||
|
from datetime import datetime as dt
|
||||||
|
|
||||||
import rowingdata.tcxtools as tcxtools
|
import rowingdata.tcxtools as tcxtools
|
||||||
from rowingdata import TCXParser, rowingdata
|
from rowingdata import TCXParser, rowingdata
|
||||||
from datetime import timedelta, datetime
|
|
||||||
|
|
||||||
class XMLParser(BaseParser):
|
class XMLParser(BaseParser):
|
||||||
media_type = "application/xml"
|
media_type = "application/xml"
|
||||||
@@ -264,7 +266,8 @@ def strokedata_tcx(request):
|
|||||||
lap_duration_seconds = float(lap_duration_node.text)
|
lap_duration_seconds = float(lap_duration_node.text)
|
||||||
total_duration += lap_duration_seconds
|
total_duration += lap_duration_seconds
|
||||||
|
|
||||||
except:
|
except Exception as e:
|
||||||
|
dologging('apilog.log',e)
|
||||||
return HttpResponseNotAllowed("Could not parse TCX data")
|
return HttpResponseNotAllowed("Could not parse TCX data")
|
||||||
|
|
||||||
|
|
||||||
@@ -276,7 +279,7 @@ def strokedata_tcx(request):
|
|||||||
|
|
||||||
|
|
||||||
duration = totaltime_sec_to_string(total_duration)
|
duration = totaltime_sec_to_string(total_duration)
|
||||||
startdatetime = datetime.strptime(start_time_str, "%Y-%m-%dT%H:%M:%S%z")
|
startdatetime = dt.strptime(start_time_str, "%Y-%m-%dT%H:%M:%S%z")
|
||||||
startdate = startdatetime.date()
|
startdate = startdatetime.date()
|
||||||
partofday = part_of_day(startdatetime.hour)
|
partofday = part_of_day(startdatetime.hour)
|
||||||
title = '{partofday} water'.format(partofday=partofday)
|
title = '{partofday} water'.format(partofday=partofday)
|
||||||
|
|||||||
Reference in New Issue
Block a user