Private
Public Access
1
0

committing survey

This commit is contained in:
Sander Roosendaal
2020-01-08 22:43:41 +01:00
parent cfc61e8621
commit 09a490c064
25 changed files with 572 additions and 597 deletions

View File

@@ -13,15 +13,15 @@ from rowers.utils import calculate_age
import rowers.dataprep as dataprep
@override_settings(TESTING=True)
class OTWCPChartTest(TestCase):
def setUp(self):
self.u = UserFactory()
self.r = Rower.objects.create(user=self.u,
birthdate=faker.profile()['birthdate'],
gdproptin=True,sex='male',
gdproptin=True,surveydone=True,sex='male',
weightcategory='hwt',
gdproptindate=timezone.now(),
rowerplan='coach')
@@ -45,8 +45,8 @@ class OTWCPChartTest(TestCase):
totaldist = row.df['cum_dist'].max()
totaltime = row.df['TimeStamp (sec)'].max()-row.df['TimeStamp (sec)'].min()
totaltime = totaltime+row.df.loc[:,' ElapsedTime (sec)'].iloc[0]
hours = int(totaltime/3600.)
minutes = int((totaltime - 3600.*hours)/60.)
seconds = int(totaltime - 3600.*hours - 60.*minutes)
@@ -54,7 +54,7 @@ class OTWCPChartTest(TestCase):
duration = "%s:%s:%s.%s" % (hours,minutes,seconds,tenths)
duration = datetime.time(hour=hours,minute=minutes,second=seconds)
workoutdate = row.rowdatetime.strftime('%Y-%m-%d')
workoutstarttime = row.rowdatetime.strftime('%H:%M:%S')
@@ -104,16 +104,16 @@ class OTWCPChartTest(TestCase):
response = self.c.get(url)
self.assertEqual(response.status_code, 200)
@override_settings(TESTING=True)
class CPChartTest(TestCase):
def setUp(self):
self.u = UserFactory()
self.r = Rower.objects.create(user=self.u,
birthdate=faker.profile()['birthdate'],
gdproptin=True,sex='male',
gdproptin=True,surveydone=True,sex='male',
weightcategory='hwt',
gdproptindate=timezone.now(),
rowerplan='coach')
@@ -146,7 +146,7 @@ class CPChartTest(TestCase):
perfsdf = pd.read_csv('rowers/tests/testdata/calcageperformance.csv')
r = self.u.rower
for i in perfsdf.index:
perf = CalcAgePerformance(
age = age,
@@ -156,14 +156,14 @@ class CPChartTest(TestCase):
weightcategory = r.weightcategory
)
perf.save()
def tearDown(self):
for workout in self.user_workouts:
try:
os.remove(workout.csvfilename)
except (IOError, FileNotFoundError,OSError):
pass
def test_analytics_page(self):
login = self.c.login(username=self.u.username,password=self.password)
self.assertTrue(login)
@@ -228,7 +228,7 @@ class CPChartTest(TestCase):
r = self.u.rower
age = calculate_age(r.birthdate)
wcdurations = []
wcpower = []
durations = [1,4,30,60]
@@ -244,7 +244,7 @@ class CPChartTest(TestCase):
)
jsondf = df.to_json()
result = handle_getagegrouprecords(
jsondf,distances,durations,age,r.sex,r.weightcategory)
@@ -258,8 +258,8 @@ class CPChartTest(TestCase):
response = self.c.get(url)
self.assertEqual(response.status_code,200)
@patch('rowers.dataprep.fetchcperg', side_effect = mocked_fetchcperg)
@patch('rowers.dataprep.create_engine')
def test_rankingpieces(self, mocked_fetchcperg, mocked_sqlalchemy):
@@ -322,5 +322,3 @@ class CPChartTest(TestCase):
response = self.c.get(url)
self.assertEqual(response.status_code, 200)