working with pytest
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
#from __future__ import print_function
|
||||
import pytest
|
||||
|
||||
pytestmark = pytest.mark.django_db
|
||||
|
||||
from bs4 import BeautifulSoup
|
||||
import re
|
||||
from nose_parameterized import parameterized
|
||||
@@ -40,7 +44,7 @@ from rowers.dataprep import delete_strokedata
|
||||
from redis import StrictRedis
|
||||
redis_connection = StrictRedis()
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
class DjangoTestCase(TestCase, MockTestCase):
|
||||
def _pre_setup(self):
|
||||
MockTestCase.setUp(self)
|
||||
@@ -376,7 +380,7 @@ def mocked_requests(*args, **kwargs):
|
||||
|
||||
return MockResponse(None,404)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
class C2Objects(DjangoTestCase):
|
||||
def setUp(self):
|
||||
self.c = Client()
|
||||
@@ -509,6 +513,7 @@ class C2Objects(DjangoTestCase):
|
||||
res = add_workout_from_strokedata(self.u,1,data,strokedata,source='c2')
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
class StravaObjects(DjangoTestCase):
|
||||
def setUp(self):
|
||||
self.c = Client()
|
||||
@@ -547,6 +552,7 @@ class StravaObjects(DjangoTestCase):
|
||||
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
class STObjects(DjangoTestCase):
|
||||
def setUp(self):
|
||||
self.c = Client()
|
||||
@@ -664,6 +670,7 @@ class STObjects(DjangoTestCase):
|
||||
|
||||
res = add_workout_from_data(self.u,1,data,data)
|
||||
|
||||
@pytest.mark.django_db
|
||||
class RunKeeperObjects(DjangoTestCase):
|
||||
def setUp(self):
|
||||
self.c = Client()
|
||||
@@ -755,6 +762,7 @@ class RunKeeperObjects(DjangoTestCase):
|
||||
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
class UAObjects(DjangoTestCase):
|
||||
def setUp(self):
|
||||
self.c = Client()
|
||||
@@ -855,6 +863,7 @@ class UAObjects(DjangoTestCase):
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
class TPObjects(DjangoTestCase):
|
||||
def setUp(self):
|
||||
self.c = Client()
|
||||
@@ -940,6 +949,7 @@ class TPObjects(DjangoTestCase):
|
||||
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
class TestErrorPages(TestCase):
|
||||
def test_error_handlers(self):
|
||||
|
||||
@@ -954,6 +964,7 @@ class TestErrorPages(TestCase):
|
||||
self.assertEqual(response.status_code, 500)
|
||||
self.assertIn('500 Internal Server Error', unicode(response))
|
||||
|
||||
@pytest.mark.django_db
|
||||
class NewUserRegistrationTest(TestCase):
|
||||
def setUp(self):
|
||||
self.c = Client()
|
||||
@@ -1030,7 +1041,10 @@ boattype: 2x
|
||||
for filename in os.listdir('media/mailbox_attachments'):
|
||||
path = os.path.join('media/mailbox_attachments/',filename)
|
||||
if not os.path.isdir(path):
|
||||
os.remove(path)
|
||||
try:
|
||||
os.remove(path)
|
||||
except WindowsError:
|
||||
pass
|
||||
|
||||
@patch('rowers.tpstuff.requests.post', side_effect=mocked_requests)
|
||||
@patch('rowers.tpstuff.requests.get', side_effect=mocked_requests)
|
||||
@@ -1072,7 +1086,7 @@ workout run
|
||||
if not os.path.isdir(path):
|
||||
try:
|
||||
os.remove(path)
|
||||
except IOError:
|
||||
except (IOError,WindowsError):
|
||||
pass
|
||||
|
||||
@patch('requests.get', side_effect=mocked_requests)
|
||||
@@ -1133,7 +1147,7 @@ workout water
|
||||
if not os.path.isdir(path):
|
||||
try:
|
||||
os.remove(path)
|
||||
except IOError:
|
||||
except (IOError,WindowsError):
|
||||
pass
|
||||
|
||||
@patch('requests.get', side_effect=mocked_requests)
|
||||
@@ -1450,7 +1464,10 @@ class ViewTest(TestCase):
|
||||
|
||||
w = Workout.objects.get(id=1)
|
||||
f_to_be_deleted = w.csvfilename
|
||||
os.remove(f_to_be_deleted+'.gz')
|
||||
try:
|
||||
os.remove(f_to_be_deleted+'.gz')
|
||||
except WindowsError:
|
||||
pass
|
||||
|
||||
|
||||
|
||||
@@ -1504,7 +1521,10 @@ class ViewTest(TestCase):
|
||||
|
||||
w = Workout.objects.get(id=1)
|
||||
f_to_be_deleted = w.csvfilename
|
||||
os.remove(f_to_be_deleted+'.gz')
|
||||
try:
|
||||
os.remove(f_to_be_deleted+'.gz')
|
||||
except WindowsError:
|
||||
pass
|
||||
|
||||
|
||||
|
||||
@@ -1539,7 +1559,10 @@ class ViewTest(TestCase):
|
||||
|
||||
w = Workout.objects.get(id=1)
|
||||
f_to_be_deleted = w.csvfilename
|
||||
os.remove(f_to_be_deleted+'.gz')
|
||||
try:
|
||||
os.remove(f_to_be_deleted+'.gz')
|
||||
except WindowsError:
|
||||
pass
|
||||
|
||||
def test_upload_view_logcard(self):
|
||||
self.c.login(username='john',password='koeinsloot')
|
||||
@@ -1615,7 +1638,10 @@ class ViewTest(TestCase):
|
||||
self.assertEqual(response.status_code, 200)
|
||||
w = Workout.objects.get(id=1)
|
||||
f_to_be_deleted = w.csvfilename
|
||||
os.remove(f_to_be_deleted+'.gz')
|
||||
try:
|
||||
os.remove(f_to_be_deleted+'.gz')
|
||||
except WindowsError:
|
||||
pass
|
||||
|
||||
def test_upload_view_TCX_SpeedCoach2a(self):
|
||||
self.c.login(username='john',password='koeinsloot')
|
||||
@@ -1646,7 +1672,10 @@ class ViewTest(TestCase):
|
||||
|
||||
w = Workout.objects.get(id=1)
|
||||
f_to_be_deleted = w.csvfilename
|
||||
os.remove(f_to_be_deleted+'.gz')
|
||||
try:
|
||||
os.remove(f_to_be_deleted+'.gz')
|
||||
except WindowsError:
|
||||
pass
|
||||
|
||||
def test_upload_view_TCX_SpeedCoach2b(self):
|
||||
self.c.login(username='john',password='koeinsloot')
|
||||
@@ -1677,7 +1706,10 @@ class ViewTest(TestCase):
|
||||
|
||||
w = Workout.objects.get(id=1)
|
||||
f_to_be_deleted = w.csvfilename
|
||||
os.remove(f_to_be_deleted+'.gz')
|
||||
try:
|
||||
os.remove(f_to_be_deleted+'.gz')
|
||||
except WindowsError:
|
||||
pass
|
||||
|
||||
|
||||
|
||||
@@ -1710,7 +1742,11 @@ class ViewTest(TestCase):
|
||||
|
||||
w = Workout.objects.get(id=1)
|
||||
f_to_be_deleted = w.csvfilename
|
||||
os.remove(f_to_be_deleted+'.gz')
|
||||
try:
|
||||
os.remove(f_to_be_deleted+'.gz')
|
||||
except WindowsError:
|
||||
pass
|
||||
|
||||
|
||||
def test_upload_view_SpeedCoach2v127(self):
|
||||
self.c.login(username='john',password='koeinsloot')
|
||||
@@ -1741,7 +1777,11 @@ class ViewTest(TestCase):
|
||||
|
||||
w = Workout.objects.get(id=1)
|
||||
f_to_be_deleted = w.csvfilename
|
||||
os.remove(f_to_be_deleted+'.gz')
|
||||
try:
|
||||
os.remove(f_to_be_deleted+'.gz')
|
||||
except WindowsError:
|
||||
pass
|
||||
|
||||
|
||||
|
||||
def test_upload_view_SpeedCoach2v127intervals(self):
|
||||
@@ -1773,7 +1813,11 @@ class ViewTest(TestCase):
|
||||
|
||||
w = Workout.objects.get(id=1)
|
||||
f_to_be_deleted = w.csvfilename
|
||||
os.remove(f_to_be_deleted+'.gz')
|
||||
try:
|
||||
os.remove(f_to_be_deleted+'.gz')
|
||||
except WindowsError:
|
||||
pass
|
||||
|
||||
|
||||
|
||||
def test_upload_view_TCX_NoHR(self):
|
||||
@@ -1805,7 +1849,11 @@ class ViewTest(TestCase):
|
||||
|
||||
w = Workout.objects.get(id=1)
|
||||
f_to_be_deleted = w.csvfilename
|
||||
os.remove(f_to_be_deleted+'.gz')
|
||||
try:
|
||||
os.remove(f_to_be_deleted+'.gz')
|
||||
except WindowsError:
|
||||
pass
|
||||
|
||||
|
||||
def test_upload_view_TCX_CN(self):
|
||||
self.c.login(username='john',password='koeinsloot')
|
||||
@@ -1833,7 +1881,11 @@ class ViewTest(TestCase):
|
||||
|
||||
w = Workout.objects.get(id=1)
|
||||
f_to_be_deleted = w.csvfilename
|
||||
os.remove(f_to_be_deleted+'.gz')
|
||||
try:
|
||||
os.remove(f_to_be_deleted+'.gz')
|
||||
except WindowsError:
|
||||
pass
|
||||
|
||||
|
||||
def test_upload_view_RP(self):
|
||||
self.c.login(username='john',password='koeinsloot')
|
||||
@@ -1861,7 +1913,11 @@ class ViewTest(TestCase):
|
||||
|
||||
w = Workout.objects.get(id=1)
|
||||
f_to_be_deleted = w.csvfilename
|
||||
os.remove(f_to_be_deleted+'.gz')
|
||||
try:
|
||||
os.remove(f_to_be_deleted+'.gz')
|
||||
except WindowsError:
|
||||
pass
|
||||
|
||||
|
||||
def test_upload_view_Mystery(self):
|
||||
self.c.login(username='john',password='koeinsloot')
|
||||
@@ -1889,7 +1945,11 @@ class ViewTest(TestCase):
|
||||
|
||||
w = Workout.objects.get(id=1)
|
||||
f_to_be_deleted = w.csvfilename
|
||||
os.remove(f_to_be_deleted+'.gz')
|
||||
try:
|
||||
os.remove(f_to_be_deleted+'.gz')
|
||||
except WindowsError:
|
||||
pass
|
||||
|
||||
|
||||
def test_upload_view_RP_interval(self):
|
||||
self.c.login(username='john',password='koeinsloot')
|
||||
@@ -1917,7 +1977,11 @@ class ViewTest(TestCase):
|
||||
|
||||
w = Workout.objects.get(id=1)
|
||||
f_to_be_deleted = w.csvfilename
|
||||
os.remove(f_to_be_deleted+'.gz')
|
||||
try:
|
||||
os.remove(f_to_be_deleted+'.gz')
|
||||
except WindowsError:
|
||||
pass
|
||||
|
||||
|
||||
|
||||
def test_upload_view_sled_desktop(self):
|
||||
@@ -1946,7 +2010,10 @@ class ViewTest(TestCase):
|
||||
|
||||
w = Workout.objects.get(id=1)
|
||||
f_to_be_deleted = w.csvfilename
|
||||
os.remove(f_to_be_deleted+'.gz')
|
||||
try:
|
||||
os.remove(f_to_be_deleted+'.gz')
|
||||
except WindowsError:
|
||||
pass
|
||||
|
||||
def test_upload_view_sled_ergdata(self):
|
||||
self.c.login(username='john',password='koeinsloot')
|
||||
@@ -1974,7 +2041,10 @@ class ViewTest(TestCase):
|
||||
|
||||
w = Workout.objects.get(id=1)
|
||||
f_to_be_deleted = w.csvfilename
|
||||
os.remove(f_to_be_deleted+'.gz')
|
||||
try:
|
||||
os.remove(f_to_be_deleted+'.gz')
|
||||
except WindowsError:
|
||||
pass
|
||||
|
||||
def test_upload_view_sled_boatcoach(self):
|
||||
self.c.login(username='john',password='koeinsloot')
|
||||
@@ -2002,7 +2072,10 @@ class ViewTest(TestCase):
|
||||
|
||||
w = Workout.objects.get(id=1)
|
||||
f_to_be_deleted = w.csvfilename
|
||||
os.remove(f_to_be_deleted+'.gz')
|
||||
try:
|
||||
os.remove(f_to_be_deleted+'.gz')
|
||||
except WindowsError:
|
||||
pass
|
||||
|
||||
def test_upload_view_sled_ergstick(self):
|
||||
self.c.login(username='john',password='koeinsloot')
|
||||
@@ -2030,7 +2103,10 @@ class ViewTest(TestCase):
|
||||
|
||||
w = Workout.objects.get(id=1)
|
||||
f_to_be_deleted = w.csvfilename
|
||||
os.remove(f_to_be_deleted+'.gz')
|
||||
try:
|
||||
os.remove(f_to_be_deleted+'.gz')
|
||||
except WindowsError:
|
||||
pass
|
||||
|
||||
|
||||
# def test_upload_view_FIT_SpeedCoach2a(self):
|
||||
@@ -2398,7 +2474,10 @@ class PlotTests(TestCase):
|
||||
w.name,self.hrdata,plotnr,imagename)
|
||||
i = GraphImage(workout=w,creationdatetime=self.nu,
|
||||
filename=fullpathimagename)
|
||||
os.remove(fullpathimagename)
|
||||
try:
|
||||
os.remove(fullpathimagename)
|
||||
except WindowsError:
|
||||
pass
|
||||
|
||||
plotnr = 1
|
||||
if (w.workouttype=='water'):
|
||||
@@ -2408,7 +2487,10 @@ class PlotTests(TestCase):
|
||||
w.name,self.hrdata,plotnr,imagename)
|
||||
i = GraphImage(workout=w,creationdatetime=self.nu,
|
||||
filename=fullpathimagename)
|
||||
os.remove(fullpathimagename)
|
||||
try:
|
||||
os.remove(fullpathimagename)
|
||||
except WindowsError:
|
||||
pass
|
||||
|
||||
plotnr = 2
|
||||
if (w.workouttype=='water'):
|
||||
@@ -2418,7 +2500,10 @@ class PlotTests(TestCase):
|
||||
w.name,self.hrdata,plotnr,imagename)
|
||||
i = GraphImage(workout=w,creationdatetime=self.nu,
|
||||
filename=fullpathimagename)
|
||||
os.remove(fullpathimagename)
|
||||
try:
|
||||
os.remove(fullpathimagename)
|
||||
except WindowsError:
|
||||
pass
|
||||
|
||||
plotnr = 3
|
||||
if (w.workouttype=='water'):
|
||||
@@ -2428,7 +2513,10 @@ class PlotTests(TestCase):
|
||||
w.name,self.hrdata,plotnr,imagename)
|
||||
i = GraphImage(workout=w,creationdatetime=self.nu,
|
||||
filename=fullpathimagename)
|
||||
os.remove(fullpathimagename)
|
||||
try:
|
||||
os.remove(fullpathimagename)
|
||||
except WindowsError:
|
||||
pass
|
||||
|
||||
plotnr = 4
|
||||
if (w.workouttype=='water'):
|
||||
@@ -2438,7 +2526,10 @@ class PlotTests(TestCase):
|
||||
w.name,self.hrdata,plotnr,imagename)
|
||||
i = GraphImage(workout=w,creationdatetime=self.nu,
|
||||
filename=fullpathimagename)
|
||||
os.remove(fullpathimagename)
|
||||
try:
|
||||
os.remove(fullpathimagename)
|
||||
except WindowsError:
|
||||
pass
|
||||
|
||||
plotnr = 5
|
||||
if (w.workouttype=='water'):
|
||||
@@ -2448,7 +2539,10 @@ class PlotTests(TestCase):
|
||||
w.name,self.hrdata,plotnr,imagename)
|
||||
i = GraphImage(workout=w,creationdatetime=self.nu,
|
||||
filename=fullpathimagename)
|
||||
os.remove(fullpathimagename)
|
||||
try:
|
||||
os.remove(fullpathimagename)
|
||||
except WindowsError:
|
||||
pass
|
||||
|
||||
plotnr = 6
|
||||
if (w.workouttype=='water'):
|
||||
@@ -2458,7 +2552,10 @@ class PlotTests(TestCase):
|
||||
w.name,self.hrdata,plotnr,imagename)
|
||||
i = GraphImage(workout=w,creationdatetime=self.nu,
|
||||
filename=fullpathimagename)
|
||||
os.remove(fullpathimagename)
|
||||
try:
|
||||
os.remove(fullpathimagename)
|
||||
except WindowsError:
|
||||
pass
|
||||
|
||||
plotnr = 7
|
||||
if (w.workouttype=='water'):
|
||||
@@ -2468,7 +2565,10 @@ class PlotTests(TestCase):
|
||||
w.name,self.hrdata,plotnr,imagename)
|
||||
i = GraphImage(workout=w,creationdatetime=self.nu,
|
||||
filename=fullpathimagename)
|
||||
os.remove(fullpathimagename)
|
||||
try:
|
||||
os.remove(fullpathimagename)
|
||||
except WindowsError:
|
||||
pass
|
||||
|
||||
plotnr = 8
|
||||
if (w.workouttype=='water'):
|
||||
@@ -2478,7 +2578,10 @@ class PlotTests(TestCase):
|
||||
w.name,self.hrdata,plotnr,imagename)
|
||||
i = GraphImage(workout=w,creationdatetime=self.nu,
|
||||
filename=fullpathimagename)
|
||||
os.remove(fullpathimagename)
|
||||
try:
|
||||
os.remove(fullpathimagename)
|
||||
except WindowsError:
|
||||
pass
|
||||
|
||||
plotnr = 13
|
||||
if (w.workouttype=='water'):
|
||||
@@ -2488,7 +2591,10 @@ class PlotTests(TestCase):
|
||||
w.name,self.hrdata,plotnr,imagename)
|
||||
i = GraphImage(workout=w,creationdatetime=self.nu,
|
||||
filename=fullpathimagename)
|
||||
os.remove(fullpathimagename)
|
||||
try:
|
||||
os.remove(fullpathimagename)
|
||||
except WindowsError:
|
||||
pass
|
||||
|
||||
def test_otw_plots(self):
|
||||
w = self.wotw
|
||||
@@ -2505,7 +2611,10 @@ class PlotTests(TestCase):
|
||||
w.name,self.hrdata,plotnr,imagename)
|
||||
i = GraphImage(workout=w,creationdatetime=self.nu,
|
||||
filename=fullpathimagename)
|
||||
os.remove(fullpathimagename)
|
||||
try:
|
||||
os.remove(fullpathimagename)
|
||||
except WindowsError:
|
||||
pass
|
||||
|
||||
plotnr = 1
|
||||
if (w.workouttype=='water'):
|
||||
@@ -2515,7 +2624,10 @@ class PlotTests(TestCase):
|
||||
w.name,self.hrdata,plotnr,imagename)
|
||||
i = GraphImage(workout=w,creationdatetime=self.nu,
|
||||
filename=fullpathimagename)
|
||||
os.remove(fullpathimagename)
|
||||
try:
|
||||
os.remove(fullpathimagename)
|
||||
except WindowsError:
|
||||
pass
|
||||
|
||||
plotnr = 2
|
||||
if (w.workouttype=='water'):
|
||||
@@ -2525,7 +2637,10 @@ class PlotTests(TestCase):
|
||||
w.name,self.hrdata,plotnr,imagename)
|
||||
i = GraphImage(workout=w,creationdatetime=self.nu,
|
||||
filename=fullpathimagename)
|
||||
os.remove(fullpathimagename)
|
||||
try:
|
||||
os.remove(fullpathimagename)
|
||||
except WindowsError:
|
||||
pass
|
||||
|
||||
plotnr = 3
|
||||
if (w.workouttype=='water'):
|
||||
@@ -2535,7 +2650,10 @@ class PlotTests(TestCase):
|
||||
w.name,self.hrdata,plotnr,imagename)
|
||||
i = GraphImage(workout=w,creationdatetime=self.nu,
|
||||
filename=fullpathimagename)
|
||||
os.remove(fullpathimagename)
|
||||
try:
|
||||
os.remove(fullpathimagename)
|
||||
except WindowsError:
|
||||
pass
|
||||
|
||||
plotnr = 4
|
||||
if (w.workouttype=='water'):
|
||||
@@ -2545,7 +2663,10 @@ class PlotTests(TestCase):
|
||||
w.name,self.hrdata,plotnr,imagename)
|
||||
i = GraphImage(workout=w,creationdatetime=self.nu,
|
||||
filename=fullpathimagename)
|
||||
os.remove(fullpathimagename)
|
||||
try:
|
||||
os.remove(fullpathimagename)
|
||||
except WindowsError:
|
||||
pass
|
||||
|
||||
plotnr = 5
|
||||
if (w.workouttype=='water'):
|
||||
@@ -2555,7 +2676,10 @@ class PlotTests(TestCase):
|
||||
w.name,self.hrdata,plotnr,imagename)
|
||||
i = GraphImage(workout=w,creationdatetime=self.nu,
|
||||
filename=fullpathimagename)
|
||||
os.remove(fullpathimagename)
|
||||
try:
|
||||
os.remove(fullpathimagename)
|
||||
except WindowsError:
|
||||
pass
|
||||
|
||||
plotnr = 6
|
||||
if (w.workouttype=='water'):
|
||||
@@ -2565,7 +2689,10 @@ class PlotTests(TestCase):
|
||||
w.name,self.hrdata,plotnr,imagename)
|
||||
i = GraphImage(workout=w,creationdatetime=self.nu,
|
||||
filename=fullpathimagename)
|
||||
os.remove(fullpathimagename)
|
||||
try:
|
||||
os.remove(fullpathimagename)
|
||||
except WindowsError:
|
||||
pass
|
||||
|
||||
plotnr = 7
|
||||
if (w.workouttype=='water'):
|
||||
@@ -2575,7 +2702,10 @@ class PlotTests(TestCase):
|
||||
w.name,self.hrdata,plotnr,imagename)
|
||||
i = GraphImage(workout=w,creationdatetime=self.nu,
|
||||
filename=fullpathimagename)
|
||||
os.remove(fullpathimagename)
|
||||
try:
|
||||
os.remove(fullpathimagename)
|
||||
except WindowsError:
|
||||
pass
|
||||
|
||||
plotnr = 8
|
||||
if (w.workouttype=='water'):
|
||||
@@ -2585,7 +2715,10 @@ class PlotTests(TestCase):
|
||||
w.name,self.hrdata,plotnr,imagename)
|
||||
i = GraphImage(workout=w,creationdatetime=self.nu,
|
||||
filename=fullpathimagename)
|
||||
os.remove(fullpathimagename)
|
||||
try:
|
||||
os.remove(fullpathimagename)
|
||||
except WindowsError:
|
||||
pass
|
||||
|
||||
plotnr = 9
|
||||
if (w.workouttype=='water'):
|
||||
@@ -2595,7 +2728,10 @@ class PlotTests(TestCase):
|
||||
w.name,self.hrdata,plotnr,imagename)
|
||||
i = GraphImage(workout=w,creationdatetime=self.nu,
|
||||
filename=fullpathimagename)
|
||||
os.remove(fullpathimagename)
|
||||
try:
|
||||
os.remove(fullpathimagename)
|
||||
except WindowsError:
|
||||
pass
|
||||
|
||||
plotnr = 13
|
||||
if (w.workouttype=='water'):
|
||||
@@ -2605,4 +2741,7 @@ class PlotTests(TestCase):
|
||||
w.name,self.hrdata,plotnr,imagename)
|
||||
i = GraphImage(workout=w,creationdatetime=self.nu,
|
||||
filename=fullpathimagename)
|
||||
os.remove(fullpathimagename)
|
||||
try:
|
||||
os.remove(fullpathimagename)
|
||||
except WindowsError:
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user