Private
Public Access
1
0

passes tests but doesn't clean up all temp

This commit is contained in:
Sander Roosendaal
2019-01-15 10:38:18 +01:00
parent 7c02366cad
commit 9cc80b9ce2
23 changed files with 777 additions and 702 deletions

View File

@@ -1,62 +1,10 @@
from statements import *
from nose.tools import assert_raises
from rowers.views import get_workout
from django.http import Http404
from django.core.exceptions import PermissionDenied
filename = 'rowers/tests/testdata/testdata.csv'
row = rdata(filename)
totaldist = row.df['cum_dist'].max()
totaltime = row.df['TimeStamp (sec)'].max()-row.df['TimeStamp (sec)'].min()
totaltime = totaltime+row.df.ix[0,' ElapsedTime (sec)']
hours = int(totaltime/3600.)
minutes = int((totaltime - 3600.*hours)/60.)
seconds = int(totaltime - 3600.*hours - 60.*minutes)
tenths = int(10*(totaltime - 3600.*hours - 60.*minutes - seconds))
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')
nu = datetime.datetime.now()
class UserFactory(factory.DjangoModelFactory):
class Meta:
model = User
from django.http import Http404
email = faker.email()
username = faker.profile()['username']
first_name = faker.name().split(' ')[0]
last_name = faker.name().split(' ')[0]
class WorkoutFactory(factory.DjangoModelFactory):
class Meta:
model = Workout
name = factory.LazyAttribute(lambda _: faker.word())
notes = faker.text()
startdatetime = row.rowdatetime
starttime = workoutstarttime
workouttype='water'
date=timezone.now().date()
duration=duration
distance=totaldist
csvfilename=filename
class SessionFactory(factory.DjangoModelFactory):
class Meta:
model = PlannedSession
name = factory.LazyAttribute(lambda _: faker.word())
comment = faker.text()
from rowers.views import get_workout
# tests simple functions from views.py
class SimpleViewTest(TestCase):
@@ -76,6 +24,13 @@ class SimpleViewTest(TestCase):
self.u.set_password(self.password)
self.u.save()
def tearDown(self):
for workout in self.user_workouts:
try:
os.remove(workout.csvfilename)
except (IOError, WindowsError):
pass
def test_getrequestrower(self):
user_no_rower = UserFactory(username='norower')
user_no_rower.set_password(faker.word())