Added simple test for C2 Stroke data
This commit is contained in:
1
c2stroketestdata.txt
Normal file
1
c2stroketestdata.txt
Normal file
File diff suppressed because one or more lines are too long
1
c2testdata.txt
Normal file
1
c2testdata.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"data": {"distance": 3467, "user_id": 457764, "ranked": false, "weight_class": "L", "verified": false, "workout_type": "unknown", "comments": null, "source": "rowingdata", "date_utc": "2016-11-04 16:26:16", "time_formatted": "16:12.9", "time": 9729, "date": "2016-11-04 16:26:16", "timezone": "Etc/UTC", "stroke_data": true, "type": "rower", "id": 27710744, "heart_rate": {"max": 158, "average": 146}}}
|
||||||
@@ -16,7 +16,7 @@ from rowers.tasks import handle_makeplot
|
|||||||
from rowers.c2stuff import C2NoTokenError
|
from rowers.c2stuff import C2NoTokenError
|
||||||
|
|
||||||
from minimocktest import MockTestCase
|
from minimocktest import MockTestCase
|
||||||
|
import pandas as pd
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ from rowers.views import error500_view,error404_view,error400_view,error403_view
|
|||||||
|
|
||||||
class DjangoTestCase(TestCase, MockTestCase):
|
class DjangoTestCase(TestCase, MockTestCase):
|
||||||
def _pre_setup(self):
|
def _pre_setup(self):
|
||||||
MockTestCase.setup(self)
|
MockTestCase.setUp(self)
|
||||||
TestCase._pre_setup(self)
|
TestCase._pre_setup(self)
|
||||||
self.client = Client()
|
self.client = Client()
|
||||||
|
|
||||||
@@ -35,6 +35,29 @@ class DjangoTestCase(TestCase, MockTestCase):
|
|||||||
|
|
||||||
# Create your tests here.
|
# Create your tests here.
|
||||||
|
|
||||||
|
class C2Objects(DjangoTestCase):
|
||||||
|
def test_strokedata(self):
|
||||||
|
with open('c2stroketestdata.txt','r') as infile:
|
||||||
|
res = json.load(infile)
|
||||||
|
|
||||||
|
strokedata = pd.DataFrame.from_dict(res['data'])
|
||||||
|
|
||||||
|
with open('c2testdata.txt','r') as infile:
|
||||||
|
res = json.load(infile)
|
||||||
|
|
||||||
|
data = res['data']
|
||||||
|
|
||||||
|
from rowers.views import add_workout_from_strokedata
|
||||||
|
|
||||||
|
u = User.objects.create_user('john',
|
||||||
|
'sander@ds.ds',
|
||||||
|
'koeinsloot')
|
||||||
|
r = Rower.objects.create(user=u)
|
||||||
|
|
||||||
|
res = add_workout_from_strokedata(u,1,data,strokedata,source='c2')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class TestErrorPages(TestCase):
|
class TestErrorPages(TestCase):
|
||||||
def test_error_handlers(self):
|
def test_error_handlers(self):
|
||||||
self.assertTrue(urls.handler404.endswith('.error404_view'))
|
self.assertTrue(urls.handler404.endswith('.error404_view'))
|
||||||
|
|||||||
@@ -370,6 +370,7 @@ def add_workout_from_strokedata(user,importid,data,strokedata,source='c2'):
|
|||||||
' latitude':latcoord,
|
' latitude':latcoord,
|
||||||
' Stroke500mPace (sec/500m)':pace,
|
' Stroke500mPace (sec/500m)':pace,
|
||||||
' Power (watts)':power,
|
' Power (watts)':power,
|
||||||
|
' DragFactor':np.zeros(nr_rows),
|
||||||
' DriveLength (meters)':np.zeros(nr_rows),
|
' DriveLength (meters)':np.zeros(nr_rows),
|
||||||
' StrokeDistance (meters)':strokelength,
|
' StrokeDistance (meters)':strokelength,
|
||||||
' DriveTime (ms)':np.zeros(nr_rows),
|
' DriveTime (ms)':np.zeros(nr_rows),
|
||||||
|
|||||||
Reference in New Issue
Block a user