Private
Public Access
1
0

more coverage

This commit is contained in:
Sander Roosendaal
2021-04-26 18:26:16 +02:00
parent 9e2a97e721
commit 594ee6239a
11 changed files with 133 additions and 91 deletions

View File

@@ -10,7 +10,7 @@ def create_alert(manager, rower, measured,period=7, emailalert=True,
name='',**kwargs):
# check if manager is coach of rower. If not return 0
if manager.rower != rower:
if manager.rower != rower: # pragma: no cover
if rower not in coach_getcoachees(manager.rower):
return 0,'You are not allowed to create this alert'
@@ -85,7 +85,7 @@ def alert_add_filters(alert,filters):
# get alert stats
# nperiod = 0: current period, i.e. next_run - n days to today
# nperiod = 1: 1 period ago , i.e. next_run -2n days to next_run -n days
def alert_get_stats(alert,nperiod=0):
def alert_get_stats(alert,nperiod=0): # pragma: no cover
# get strokes
workstrokesonly = not alert.reststrokes
startdate = (alert.next_run - datetime.timedelta(days=(nperiod+1)*alert.period-1))
@@ -117,10 +117,10 @@ def alert_get_stats(alert,nperiod=0):
}
# check if filters are in columns list
pdcolumns = set(df.columns)
pdcolumns = set(df.columns) # pragma: no cover
# drop strokes through filter
if set(columns) <= pdcolumns:
if set(columns) <= pdcolumns: # pragma: no cover
for condition in alert.filter.all():
if condition.condition == '>':
mask = df[condition.metric] > condition.value1
@@ -137,7 +137,7 @@ def alert_get_stats(alert,nperiod=0):
df.loc[mask,alert.measured.metric] = np.nan
df.dropna(inplace=True,axis=0)
else:
else: # pragma: no cover
return {
'workouts':workouts.count(),
'startdate':startdate,