15
15
"idnumber" : ["none" , "invalid" , "one" ],
16
16
"mapped" : ["none" , "invalid" , "one" , "multi" ],
17
17
"internalstate" : ["notopened" , "opened" , "closed" , "manual" , "none" ],
18
- "actualstate" : ["open" , "closed" , "mixed" ]
18
+ "actualstate" : ["open" , "closed" , "mixed" ],
19
+ "recordstandardtime" : ["recordstandardtimemode" , "recordnonstandardtimemode" , "norecordstandardtimemode" ]
19
20
}
20
21
22
+ ILLEGALSTATES = [
23
+ {"recordstandardtime" : "recordstandardtimemode" , "internalstate" : "none" },
24
+ {"recordstandardtime" : "recordnonstandardtimemode" , "internalstate" : "none" },
25
+ {"recordstandardtime" : "norecordstandardtimemode" , "internalstate" : "notopened" },
26
+ {"recordstandardtime" : "norecordstandardtimemode" , "internalstate" : "opened" },
27
+ {"recordstandardtime" : "norecordstandardtimemode" , "internalstate" : "closed" },
28
+ {"recordstandardtime" : "norecordstandardtimemode" , "internalstate" : "manual" },
29
+ ]
30
+
31
+
32
+ def illegal_state (scenario ):
33
+ for fullillegalstate in ILLEGALSTATES :
34
+ illegal = True
35
+ for illegalstate in fullillegalstate .keys ():
36
+ if scenario [list (OPTIONS .keys ()).index (illegalstate )] != fullillegalstate [illegalstate ]:
37
+ illegal = False
38
+ break
39
+ if illegal :
40
+ return True
41
+ if scenario [5 ] == "none" and scenario [7 ] != "norecordstandardtimemode" :
42
+ print (scenario )
43
+ return False
44
+
21
45
22
- def get_checks (mode , standardtime , students_state , idnumber_state , mapped_state , internal_state , actual_state ):
46
+ def get_checks (mode , standardtime , students_state , idnumber_state , mapped_state , internal_state , actual_state , recordstandardtimemode ):
23
47
"""
24
48
This Function will take the scenario parameters and construct the resulting checks.
25
49
:return: The combined checks for the parameters.
26
50
"""
27
- checks = ""
28
51
# If there are no mapped courses the Block not offer the option to "Show surveys"
29
52
if (idnumber_state == "none" ) and (mapped_state == "none" ):
30
53
return "Then I should see \" Change mapping\" \n And I should not see \" Name:\" \n "
31
54
55
+ checks = ""
32
56
# In all other cases (even if there are only invalid entries) we need to click the button to start code execution
33
57
checks += "And I load the evasys block\n "
34
58
@@ -62,7 +86,7 @@ def get_checks(mode, standardtime, students_state, idnumber_state, mapped_state,
62
86
checks += "And I should see \" There are some closed surveys, but all surveys should be open.\" " + "\n "
63
87
64
88
# if the standardtimemodecheckbox should be present from the start we also want to check that
65
- checks += checks_standardtimemode (standardtime , mode , internal_state , actual_state ) + "\n "
89
+ checks += checks_standardtimemode (standardtime , mode , internal_state , recordstandardtimemode ) + "\n "
66
90
# if there are no students that are eligible to evaluate we want to output a warning
67
91
checks += student_checks [students_state ]
68
92
checks = checks .replace ("\n " , "\n " )
@@ -110,13 +134,15 @@ def get_combi_sentence(set, dictionary, param_name):
110
134
111
135
112
136
def get_combi_description (mode , standardtime , students_state , idnumber_state , mapped_state , internal_state ,
113
- actual_state ):
137
+ actual_state , recordstandardtimemode ):
114
138
"""
115
139
This will construct the description for a scenario that covers multiple states.
116
140
:return: String the description of the scenario.
117
141
"""
118
142
if "none" in mapped_state and "none" in idnumber_state :
119
143
return "If there are no related evasys-courses I should not see any.\n "
144
+ if not recordstandardtimemode == "norecordstandardtimemode" :
145
+ standardtime = {1 } if recordstandardtimemode == "recordstandardtimemode" else {0 }
120
146
description = ""
121
147
description += get_combi_sentence (standardtime , standardtimemode_descriptions , "standardtime" )
122
148
description += get_combi_sentence (students_state , students_descriptions , "number of students" )
@@ -127,7 +153,7 @@ def get_combi_description(mode, standardtime, students_state, idnumber_state, ma
127
153
return description
128
154
129
155
130
- def get_scenario (mode , standardtime , students_state , idnumber_state , mapped_state , internal_state , actual_state ):
156
+ def get_scenario (mode , standardtime , students_state , idnumber_state , mapped_state , internal_state , actual_state , recordstandardtimemode ):
131
157
"""
132
158
This constructs the actual scenario by building all courses, states etc.
133
159
:return: string the combined enviroment specifiing string for a scenario
@@ -138,6 +164,7 @@ def get_scenario(mode, standardtime, students_state, idnumber_state, mapped_stat
138
164
behat_scenario += step_idnumberstate (idnumber_state , actual_state )
139
165
behat_scenario += step_mappedstate (mapped_state , actual_state )
140
166
behat_scenario += step_internal_state [internal_state ].replace ("{{course}}" , str (coursename )) + "\n "
167
+ behat_scenario += step_record_standardtimemode [recordstandardtimemode ].replace ("{{course}}" , str (coursename )) + "\n "
141
168
behat_scenario += "And I turn editing mode on\n "
142
169
behat_scenario += "And I add the \" EvaSys Sync\" block\n "
143
170
behat_scenario += "And I turn editing mode off\n "
@@ -220,6 +247,7 @@ def condense_keep_options(fullarray):
220
247
if changed :
221
248
break
222
249
fullarray = new_array
250
+
223
251
return fullarray
224
252
225
253
@@ -252,17 +280,20 @@ def main():
252
280
# get the checks for all options to be able to condense options with the same expected outcome
253
281
uncondensed_dict = {}
254
282
for scenario in cartesianoptions :
255
- check = get_checks (scenario [0 ], scenario [1 ], scenario [2 ], scenario [3 ], scenario [4 ], scenario [5 ], scenario [6 ])
283
+ check = get_checks (scenario [0 ], scenario [1 ], scenario [2 ], scenario [3 ], scenario [4 ], scenario [5 ], scenario [6 ], scenario [ 7 ] )
256
284
if not check in uncondensed_dict .keys ():
257
285
uncondensed_dict [check ] = []
258
286
uncondensed_dict [check ].append (scenario )
259
287
260
288
# condense those scenarios
261
289
condensed_dict = {}
262
290
if CONDENSE_TESTS :
291
+ i = 0
263
292
for check in uncondensed_dict .keys ():
264
293
scenarios = uncondensed_dict [check ]
265
294
condensed_dict [check ] = condense_keep_options (scenarios )
295
+ i += 1
296
+ print ("Condensed " + str (i ) + " of " + str (len (uncondensed_dict .keys ())))
266
297
else :
267
298
for check in uncondensed_dict .keys ():
268
299
fullarray = uncondensed_dict [check ]
@@ -284,18 +315,42 @@ def main():
284
315
# do a deep-copy of the scenario because sets can only be accessed by pop which alters the set itself
285
316
scenario_copy = copy .deepcopy (scenario )
286
317
desc = get_combi_description (scenario [0 ], scenario [1 ], scenario [2 ], scenario [3 ], scenario [4 ], scenario [5 ],
287
- scenario [6 ])
318
+ scenario [6 ], scenario [ 7 ] )
288
319
mode = scenario_copy [0 ].pop ()
289
320
standardtime = scenario_copy [1 ].pop ()
290
321
students_state = scenario_copy [2 ].pop ()
291
322
idnumber_state = scenario_copy [3 ].pop ()
292
323
mapped_state = scenario_copy [4 ].pop ()
293
324
internal_state = scenario_copy [5 ].pop ()
294
325
actual_state = scenario_copy [6 ].pop ()
326
+ recordstandardtime = scenario_copy [7 ].pop ()
295
327
if actual_state == "mixed" and len (scenario_copy [6 ]) > 0 :
296
328
actual_state = scenario_copy [6 ].pop ()
329
+
330
+ corrected = True
331
+ illegal = False
332
+ illegals = []
333
+ while corrected :
334
+ corrected = False
335
+ if illegal_state ([mode , standardtime , students_state , idnumber_state , mapped_state , internal_state ,
336
+ actual_state , recordstandardtime ]):
337
+ corrected = True
338
+ illegals .append ([mode , standardtime , students_state , idnumber_state , mapped_state , internal_state ,
339
+ actual_state , recordstandardtime ])
340
+ if len (scenario_copy [5 ]) >= 1 :
341
+ internal_state = scenario_copy [5 ].pop ()
342
+ elif len (scenario_copy [7 ]) >= 1 :
343
+ recordstandardtime = scenario_copy [7 ].pop ()
344
+ else :
345
+ if len (illegals ) > 1 :
346
+ print ("Illegal multiscenario" )
347
+ print (illegals )
348
+ illegal = True
349
+ corrected = False
350
+ if illegal :
351
+ continue
297
352
scen_text = get_scenario (mode , standardtime , students_state , idnumber_state , mapped_state , internal_state ,
298
- actual_state )
353
+ actual_state , recordstandardtime )
299
354
if not scen_text :
300
355
print ("Warning impossible scenario!!!" )
301
356
continue
0 commit comments