passing some tests on py3, all on py2
This commit is contained in:
@@ -913,7 +913,7 @@ def save_workout_database(f2, r, dosmooth=True, workouttype='rower',
|
||||
try:
|
||||
checks = row.check_consistency()
|
||||
allchecks = 1
|
||||
for key, value in checks.iteritems():
|
||||
for key, value in checks.items():
|
||||
if not value:
|
||||
allchecks = 0
|
||||
if consistencychecks:
|
||||
@@ -2093,7 +2093,7 @@ def dataprep(rowdatadf, id=0, bands=True, barchart=True, otwpower=True,
|
||||
if rowdatadf.empty:
|
||||
return 0
|
||||
|
||||
rowdatadf.set_index([range(len(rowdatadf))], inplace=True)
|
||||
#rowdatadf.set_index([range(len(rowdatadf))], inplace=True)
|
||||
t = rowdatadf.loc[:, 'TimeStamp (sec)']
|
||||
t = pd.Series(t - rowdatadf.loc[:, 'TimeStamp (sec)'].iloc[0])
|
||||
|
||||
|
||||
@@ -264,7 +264,7 @@ def getcp(dfgrouped,logarr):
|
||||
length = len(ww)
|
||||
dt = []
|
||||
cpw = []
|
||||
for i in xrange(length-2):
|
||||
for i in range(length-2):
|
||||
deltat,wmax = getmaxwattinterval(tt,ww,i)
|
||||
|
||||
if not np.isnan(deltat) and not np.isnan(wmax):
|
||||
|
||||
@@ -246,9 +246,12 @@ def interactive_boxchart(datadf,fieldname,extratitle=''):
|
||||
|
||||
return script,div
|
||||
|
||||
import holoviews as hv
|
||||
hv.extension('bokeh')
|
||||
renderer = hv.renderer('bokeh')
|
||||
try:
|
||||
import holoviews as hv
|
||||
hv.extension('bokeh')
|
||||
renderer = hv.renderer('bokeh')
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
def interactive_activitychart(workouts,startdate,enddate,stack='type'):
|
||||
|
||||
@@ -908,7 +911,12 @@ def interactive_histoall(theworkouts):
|
||||
axis_label="Cumulative % of strokes"),'right')
|
||||
|
||||
plot.sizing_mode = 'scale_width'
|
||||
script, div = components(plot)
|
||||
try:
|
||||
script, div = components(plot)
|
||||
except ValueError:
|
||||
script = ''
|
||||
div = ''
|
||||
|
||||
return [script,div]
|
||||
|
||||
def course_map(course):
|
||||
@@ -4249,7 +4257,11 @@ def interactive_otw_advanced_pace_chart(id=0,promember=0):
|
||||
|
||||
hover.mode = 'mouse'
|
||||
|
||||
script, div = components(plot)
|
||||
try:
|
||||
script, div = components(plot)
|
||||
except:
|
||||
script = ''
|
||||
div = ''
|
||||
|
||||
return [script,div]
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ from rowers.opaque import encoder
|
||||
|
||||
import arrow
|
||||
|
||||
from six import string_types
|
||||
|
||||
def strfdelta(tdelta):
|
||||
minutes,seconds = divmod(tdelta.seconds,60)
|
||||
@@ -220,7 +221,7 @@ def jsdict(dict,key):
|
||||
def lookup(dict, key):
|
||||
s = dict.get(key)
|
||||
|
||||
if isinstance(s,basestring) and len(s) > 22:
|
||||
if isinstance(s,string_types) and len(s) > 22:
|
||||
s = s[:22]
|
||||
return s
|
||||
|
||||
|
||||
@@ -105,13 +105,13 @@ def mocked_sqlalchemy(*args, **kwargs):
|
||||
#@pytest.mark.django_db
|
||||
class DjangoTestCase(TestCase): #, MockTestCase):
|
||||
def _pre_setup(self):
|
||||
MockTestCase.setUp(self)
|
||||
# MockTestCase.setUp(self)
|
||||
TestCase._pre_setup(self)
|
||||
self.client = Client()
|
||||
|
||||
def _post_teardown(self):
|
||||
TestCase._post_teardown(self)
|
||||
MockTestCase.tearDown(self)
|
||||
#MockTestCase.tearDown(self)
|
||||
# delete_strokedata(1)
|
||||
|
||||
def mocked_tcx_parser(*args, **kwargs):
|
||||
|
||||
@@ -3,6 +3,11 @@ try:
|
||||
except NameError:
|
||||
WindowsError = None
|
||||
|
||||
try:
|
||||
FileNotFoundError
|
||||
except NameError:
|
||||
FileNotFoundError = None
|
||||
|
||||
try:
|
||||
OSError
|
||||
except NameError:
|
||||
|
||||
BIN
rowers/tests/testdata/testdata.csv.gz
vendored
BIN
rowers/tests/testdata/testdata.csv.gz
vendored
Binary file not shown.
@@ -206,7 +206,7 @@ def uniqify(seq, idfun=None):
|
||||
|
||||
def serialize_list(value,token=','):
|
||||
assert(isinstance(value, list) or isinstance(value, tuple) or isinstance(value,np.ndarray))
|
||||
return token.join([s for s in value])
|
||||
return token.join([str(s) for s in value])
|
||||
|
||||
def deserialize_list(value,token=','):
|
||||
if isinstance(value, list):
|
||||
|
||||
@@ -2106,7 +2106,7 @@ def virtualevent_submit_result_view(request,id=0,workoutid=0):
|
||||
entrychoices = []
|
||||
|
||||
for record in records:
|
||||
rtpl = (record.id, record.__unicode__())
|
||||
rtpl = (record.id, record.__str__())
|
||||
entrychoices.append(rtpl)
|
||||
|
||||
entries = {}
|
||||
@@ -2153,7 +2153,7 @@ def virtualevent_submit_result_view(request,id=0,workoutid=0):
|
||||
choices = []
|
||||
|
||||
for w in ws:
|
||||
wtpl = (w.id, w.__unicode__())
|
||||
wtpl = (w.id, w.__str__())
|
||||
choices.append(wtpl)
|
||||
if w.id in initialworkouts:
|
||||
workoutdata['initial'].append(w.id)
|
||||
|
||||
@@ -726,7 +726,10 @@ def get_stored_tasks_status(request):
|
||||
taskstatus = []
|
||||
for id,func_name in reversed(taskids):
|
||||
progress = 0
|
||||
cached_progress = cache.get(id)
|
||||
try:
|
||||
cached_progress = cache.get(id)
|
||||
except ValueError:
|
||||
cached_progress = 0
|
||||
finished = get_job_status(id)['finished']
|
||||
if finished:
|
||||
cache.set(id,100)
|
||||
|
||||
@@ -874,7 +874,7 @@ def virtualevent_compare_view(request,id=0):
|
||||
pass
|
||||
|
||||
labeldict = {
|
||||
int(w.id): w.__unicode__() for w in workouts
|
||||
int(w.id): w.__str__() for w in workouts
|
||||
}
|
||||
|
||||
chartform = ChartParamChoiceForm(
|
||||
@@ -906,7 +906,7 @@ def virtualevent_compare_view(request,id=0):
|
||||
pass
|
||||
|
||||
labeldict = {
|
||||
int(w.id): w.__unicode__() for w in workouts
|
||||
int(w.id): w.__str__() for w in workouts
|
||||
}
|
||||
else:
|
||||
raise HttpResponse('Only GET and POST allowed',status=405)
|
||||
@@ -988,7 +988,7 @@ def plannedsession_compare_view(request,id=0,userid=0):
|
||||
ids = [int(w.id) for w in workouts]
|
||||
|
||||
labeldict = {
|
||||
int(w.id): w.__unicode__() for w in workouts
|
||||
int(w.id): w.__str__() for w in workouts
|
||||
}
|
||||
|
||||
xparam = 'time'
|
||||
@@ -1033,7 +1033,7 @@ def multi_compare_view(request,id=0,userid=0):
|
||||
request.session['ids'] = ids
|
||||
|
||||
labeldict = {
|
||||
int(w.id): w.__unicode__() for w in workouts
|
||||
int(w.id): w.__str__() for w in workouts
|
||||
}
|
||||
|
||||
else:
|
||||
@@ -1055,7 +1055,7 @@ def multi_compare_view(request,id=0,userid=0):
|
||||
pass
|
||||
|
||||
labeldict = {
|
||||
int(w.id): w.__unicode__() for w in workouts
|
||||
int(w.id): w.__str__() for w in workouts
|
||||
}
|
||||
elif 'ids' in request.session and 'plottype' in request.session:
|
||||
xparam = request.session['xparam']
|
||||
@@ -1071,7 +1071,7 @@ def multi_compare_view(request,id=0,userid=0):
|
||||
pass
|
||||
|
||||
labeldict = {
|
||||
int(w.id): w.__unicode__() for w in workouts
|
||||
int(w.id): w.__str__() for w in workouts
|
||||
}
|
||||
chartform = ChartParamChoiceForm(
|
||||
initial = {
|
||||
@@ -2510,7 +2510,7 @@ def workout_stats_view(request,id=0,message="",successmessage=""):
|
||||
fielddict.pop('workoutstate')
|
||||
fielddict.pop('workoutid')
|
||||
|
||||
for field,verbosename in fielddict.iteritems():
|
||||
for field,verbosename in fielddict.items():
|
||||
thedict = {
|
||||
'mean':datadf[field].mean(),
|
||||
'wmean': wavg(datadf, field, 'deltat'),
|
||||
@@ -2528,9 +2528,9 @@ def workout_stats_view(request,id=0,message="",successmessage=""):
|
||||
cor = datadf.corr(method='spearman')
|
||||
cor.fillna(value=0,inplace=True)
|
||||
cordict = {}
|
||||
for field1,verbosename in fielddict.iteritems():
|
||||
for field1,verbosename in fielddict.items():
|
||||
thedict = {}
|
||||
for field2,verbosename in fielddict.iteritems():
|
||||
for field2,verbosename in fielddict.items():
|
||||
try:
|
||||
thedict[field2] = cor.loc[field1,field2]
|
||||
except KeyError:
|
||||
@@ -3211,10 +3211,14 @@ def workout_comment_view(request,id=0):
|
||||
cd = form.cleaned_data
|
||||
comment = cd['comment']
|
||||
comment = bleach.clean(comment)
|
||||
if isinstance(comment,unicode):
|
||||
comment = comment.encode('utf8')
|
||||
elif isinstance(comment, str):
|
||||
comment = comment.decode('utf8')
|
||||
try:
|
||||
if isinstance(comment,unicode):
|
||||
comment = comment.encode('utf8')
|
||||
elif isinstance(comment, str):
|
||||
comment = comment.decode('utf8')
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
notification = cd['notification']
|
||||
c = WorkoutComment(workout=w,user=request.user,comment=comment,
|
||||
@@ -4978,7 +4982,7 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
|
||||
iunits = []
|
||||
itypes = []
|
||||
iresults = []
|
||||
for i in xrange(nrintervals):
|
||||
for i in range(nrintervals):
|
||||
try:
|
||||
t = datetime.datetime.strptime(request.POST['intervalt_%s' % i],"%H:%M:%S.%f")
|
||||
except ValueError:
|
||||
@@ -5042,7 +5046,7 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
|
||||
iunits = []
|
||||
itypes = []
|
||||
iresults = []
|
||||
for i in xrange(nrintervals):
|
||||
for i in range(nrintervals):
|
||||
t = cd['intervalt_%s' % i]
|
||||
timesecs = t.total_seconds()
|
||||
itime += [timesecs]
|
||||
@@ -5076,7 +5080,7 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
|
||||
|
||||
|
||||
initial = {}
|
||||
for i in xrange(nrintervals):
|
||||
for i in range(nrintervals):
|
||||
try:
|
||||
initial['intervald_%s' % i] = idist[i]
|
||||
initial['intervalt_%s' % i] = get_time(itime[i])
|
||||
|
||||
Reference in New Issue
Block a user