passing tests
This commit is contained in:
@@ -141,6 +141,16 @@ def mocked_read_df_sql(id):
|
||||
|
||||
return df
|
||||
|
||||
def mocked_get_video_data(*args, **kwargs):
|
||||
with open('rowers/tests/testdata/videodata.json','r') as infile:
|
||||
data = json.load(infile)
|
||||
|
||||
maxtime = 4135.
|
||||
with open('rowers/tests/testdata/videometrics.json','r') as infile:
|
||||
metrics = json.load(infile)
|
||||
|
||||
return data,metrics,maxtime
|
||||
|
||||
def mocked_getrowdata_db(*args, **kwargs):
|
||||
df = pd.read_csv('rowers/tests/testdata/getrowdata_mock.csv')
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ tested = [
|
||||
'/rowers/me/delete/'
|
||||
]
|
||||
|
||||
#@pytest.mark.django_db
|
||||
#@pytest.mark.django_db
|
||||
@override_settings(TESTING=True)
|
||||
class URLTests(TestCase):
|
||||
def setUp(self):
|
||||
@@ -25,7 +25,7 @@ class URLTests(TestCase):
|
||||
r = Rower.objects.create(user=u,rowerplan='coach',gdproptin=True,
|
||||
gdproptindate=timezone.now())
|
||||
self.c = Client()
|
||||
|
||||
|
||||
self.nu = datetime.datetime.now()
|
||||
filename = 'rowers/tests/testdata/testdata.csv'
|
||||
self.wotw = Workout.objects.create(name='testworkout',
|
||||
@@ -34,20 +34,20 @@ class URLTests(TestCase):
|
||||
starttime=self.nu.strftime('%H:%M:%S'),
|
||||
duration="0:55:00",distance=8000,
|
||||
csvfilename=filename)
|
||||
|
||||
|
||||
self.wote = Workout.objects.create(name='testworkout',
|
||||
workouttype='Indoor Rower',
|
||||
user=r,date=self.nu.strftime('%Y-%m-%d'),
|
||||
starttime=self.nu.strftime('%H:%M:%S'),
|
||||
duration="0:55:00",distance=8000,
|
||||
csvfilename=filename)
|
||||
|
||||
|
||||
powerperc = 100*np.array([r.pw_ut2,
|
||||
r.pw_ut1,
|
||||
r.pw_at,
|
||||
r.pw_tr,r.pw_an])/r.ftp
|
||||
|
||||
|
||||
|
||||
self.hrdata = {
|
||||
'hrmax':r.max,
|
||||
'hrut2':r.ut2,
|
||||
@@ -103,7 +103,7 @@ class URLTests(TestCase):
|
||||
'/rowers/help/',
|
||||
'/rowers/histo/',
|
||||
'/rowers/histo/user/1/',
|
||||
# '/rowers/histo/user/1/2016-01-01/2016-12-31/',
|
||||
# '/rowers/histo/user/1/2016-01-01/2016-12-31/',
|
||||
'/rowers/histodata/',
|
||||
# '/rowers/job-kill/1/',
|
||||
# '/rowers/jobs-status/',
|
||||
@@ -238,7 +238,7 @@ class URLTests(TestCase):
|
||||
'/rowers/workout/upload/team/',
|
||||
'/rowers/workouts-join/',
|
||||
'/rowers/workouts-join-select/',
|
||||
# '/rowers/workouts-join-select/2016-01-01/2016-12-31/',
|
||||
# '/rowers/workouts-join-select/2016-01-01/2016-12-31/',
|
||||
]
|
||||
|
||||
# urlstotest = ['/rowers/createplan/user/1/']
|
||||
@@ -249,19 +249,21 @@ class URLTests(TestCase):
|
||||
(url,200)
|
||||
)
|
||||
|
||||
|
||||
|
||||
@parameterized.expand(lijst)
|
||||
@patch('rowers.dataprep.create_engine')
|
||||
@patch('rowers.dataprep.read_df_sql')
|
||||
@patch('rowers.dataprep.getsmallrowdata_db')
|
||||
@patch('requests.get',side_effect=mocked_requests)
|
||||
@patch('requests.post',side_effect=mocked_requests)
|
||||
@patch('rowers.dataprep.get_video_data',side_effect=mocked_get_video_data)
|
||||
def test_url_generator(self,url,expected,
|
||||
mocked_sqlalchemy,
|
||||
mocked_read_df_sql,
|
||||
mocked_getsmallrowdata_db,
|
||||
mock_get,
|
||||
mock_post):
|
||||
mock_post,
|
||||
mocked_get_video_data):
|
||||
|
||||
if url not in tested:
|
||||
login = self.c.login(username='john',password='koeinsloot')
|
||||
@@ -276,10 +278,10 @@ class URLTests(TestCase):
|
||||
|
||||
html = BeautifulSoup(response.content,'html.parser')
|
||||
|
||||
|
||||
|
||||
urls = [a['href'] for a in html.find_all('a')]
|
||||
|
||||
|
||||
|
||||
for u in urls:
|
||||
if u not in tested and 'rowers' in u and 'http' not in u and 'authorize' not in u and 'import' not in u and 'logout' not in u:
|
||||
response2 = self.c.get(u)
|
||||
@@ -294,5 +296,3 @@ class URLTests(TestCase):
|
||||
[200,302,301])
|
||||
else:
|
||||
tested.append(u)
|
||||
|
||||
|
||||
|
||||
1
rowers/tests/testdata/videodata.json
vendored
Normal file
1
rowers/tests/testdata/videodata.json
vendored
Normal file
File diff suppressed because one or more lines are too long
1
rowers/tests/testdata/videometrics.json
vendored
Normal file
1
rowers/tests/testdata/videometrics.json
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"boatspeed": {"name": "Boat Speed (m/s)", "metric": "velo", "unit": ""}, "cumdist": {"name": "Cumulative Distance (m)", "metric": "cumdist", "unit": ""}, "distance": {"name": "Distance (m)", "metric": "distance", "unit": ""}, "distanceperstroke": {"name": "Distance per Stroke (m)", "metric": "distanceperstroke", "unit": ""}, "pace": {"name": "Pace (/500m)", "metric": "pace", "unit": ""}, "spm": {"name": "Stroke Rate (spm)", "metric": "spm", "unit": ""}}
|
||||
@@ -675,6 +675,14 @@ def workouts_join_view(request):
|
||||
url = reverse('workouts_join_select')
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
defaultoptions = {
|
||||
'includereststrokes': False,
|
||||
'workouttypes':['rower','dynamic','slides'],
|
||||
'waterboattype': mytypes.waterboattype,
|
||||
'rankingonly': False,
|
||||
'function':'boxplot'
|
||||
}
|
||||
|
||||
@user_passes_test(ispromember, login_url="/rowers/paidplans",
|
||||
message="This functionality requires a Pro plan or higher",
|
||||
redirect_field_name=None)
|
||||
|
||||
Reference in New Issue
Block a user