more tests unit tests on dataprep
This commit is contained in:
@@ -11,6 +11,72 @@ nu = datetime.datetime.now()
|
||||
|
||||
# interactive plots
|
||||
from rowers import interactiveplots
|
||||
from rowers import dataprep
|
||||
|
||||
class DataPrepTests(TestCase):
|
||||
def setUp(self):
|
||||
self.u = UserFactory()
|
||||
|
||||
self.r = Rower.objects.create(user=self.u,
|
||||
birthdate=faker.profile()['birthdate'],
|
||||
gdproptin=True,surveydone=True,
|
||||
gdproptindate=timezone.now(),
|
||||
rowerplan='coach')
|
||||
|
||||
self.c = Client()
|
||||
self.user_workouts = WorkoutFactory.create_batch(5, user=self.r)
|
||||
self.factory = RequestFactory()
|
||||
self.password = faker.word()
|
||||
self.u.set_password(self.password)
|
||||
self.u.save()
|
||||
|
||||
result = get_random_file(filename='rowers/tests/testdata/uherskehradiste_otw.csv')
|
||||
|
||||
self.wuh_otw = WorkoutFactory(user=self.r,
|
||||
csvfilename=result['filename'],
|
||||
starttime=result['starttime'],
|
||||
startdatetime=result['startdatetime'],
|
||||
duration=result['duration'],
|
||||
distance=result['totaldist'],
|
||||
workouttype = 'water',
|
||||
)
|
||||
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
@patch('rowers.dataprep.getsmallrowdata_db',side_effect=mocked_getsmallrowdata_uh)
|
||||
def test_get_videodata(self,mocked_getsmallrowdata_uh):
|
||||
data, metrics, maxtime = dataprep.get_video_data(self.wuh_otw)
|
||||
|
||||
self.assertEqual(len(data),9)
|
||||
self.assertEqual(len(metrics),6)
|
||||
self.assertEqual(int(maxtime),1737)
|
||||
|
||||
def test_polarization_index(self):
|
||||
df = pd.read_csv('rowers/tests/testdata/uhfull.csv')
|
||||
index = dataprep.polarization_index(df,self.r)
|
||||
self.assertEqual(int(100*index),-67)
|
||||
|
||||
def test_get_latlon(self):
|
||||
data = dataprep.get_latlon(self.wuh_otw.id)
|
||||
self.assertEqual(len(data),2)
|
||||
|
||||
def test_workout_summary_to_df(self):
|
||||
df = dataprep.workout_summary_to_df(self.r)
|
||||
self.assertEqual(len(df),6)
|
||||
|
||||
@patch('rowers.dataprep.create_engine')
|
||||
def test_update_c2id(self,mocked_sqlalchemy):
|
||||
res = dataprep.update_c2id_sql(1,1)
|
||||
self.assertEqual(res,1)
|
||||
|
||||
def test_checkmarker(self):
|
||||
workouts = Workout.objects.all().order_by("-date")
|
||||
wmax = dataprep.check_marker(workouts[0])
|
||||
self.assertTrue(wmax.rankingpiece)
|
||||
|
||||
|
||||
|
||||
class InteractivePlotTests(TestCase):
|
||||
def setUp(self):
|
||||
@@ -29,6 +95,9 @@ class InteractivePlotTests(TestCase):
|
||||
self.u.set_password(self.password)
|
||||
self.u.save()
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def test_interactive_hr_piechart(self):
|
||||
df = pd.read_csv('rowers/tests/testdata/getrowdata_mock.csv')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user