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 " )
@@ -136,13 +160,15 @@ def get_combi_sentence(set, dictionary, param_name):
136
160
137
161
138
162
def get_combi_description (mode , standardtime , students_state , idnumber_state , mapped_state , internal_state ,
139
- actual_state ):
163
+ actual_state , recordstandardtimemode ):
140
164
"""
141
165
This will construct the description for a scenario that covers multiple states.
142
166
:return: String the description of the scenario.
143
167
"""
144
168
if "none" in mapped_state and "none" in idnumber_state :
145
169
return "If there are no related evasys-courses I should not see any.\n "
170
+ if not recordstandardtimemode == "norecordstandardtimemode" :
171
+ standardtime = {1 } if recordstandardtimemode == "recordstandardtimemode" else {0 }
146
172
description = ""
147
173
description += get_combi_sentence (standardtime , standardtimemode_descriptions , "standardtime" )
148
174
description += get_combi_sentence (students_state , students_descriptions , "number of students" )
@@ -153,7 +179,7 @@ def get_combi_description(mode, standardtime, students_state, idnumber_state, ma
153
179
return description
154
180
155
181
156
- def get_scenario (mode , standardtime , students_state , idnumber_state , mapped_state , internal_state , actual_state ):
182
+ def get_scenario (mode , standardtime , students_state , idnumber_state , mapped_state , internal_state , actual_state , recordstandardtimemode ):
157
183
"""
158
184
This constructs the actual scenario by building all courses, states etc.
159
185
:return: string the combined enviroment specifiing string for a scenario
@@ -164,6 +190,7 @@ def get_scenario(mode, standardtime, students_state, idnumber_state, mapped_stat
164
190
behat_scenario += step_idnumberstate (idnumber_state , actual_state )
165
191
behat_scenario += step_mappedstate (mapped_state , actual_state )
166
192
behat_scenario += step_internal_state [internal_state ].replace ("{{course}}" , str (coursename )) + "\n "
193
+ behat_scenario += step_record_standardtimemode [recordstandardtimemode ].replace ("{{course}}" , str (coursename )) + "\n "
167
194
behat_scenario += "And I turn editing mode on\n "
168
195
behat_scenario += "And I add the \" EvaSys Sync\" block\n "
169
196
behat_scenario += "And I turn editing mode off\n "
@@ -246,6 +273,7 @@ def condense_keep_options(fullarray):
246
273
if changed :
247
274
break
248
275
fullarray = new_array
276
+
249
277
return fullarray
250
278
251
279
@@ -278,17 +306,20 @@ def main():
278
306
# get the checks for all options to be able to condense options with the same expected outcome
279
307
uncondensed_dict = {}
280
308
for scenario in cartesianoptions :
281
- check = get_checks (scenario [0 ], scenario [1 ], scenario [2 ], scenario [3 ], scenario [4 ], scenario [5 ], scenario [6 ])
309
+ check = get_checks (scenario [0 ], scenario [1 ], scenario [2 ], scenario [3 ], scenario [4 ], scenario [5 ], scenario [6 ], scenario [ 7 ] )
282
310
if not check in uncondensed_dict .keys ():
283
311
uncondensed_dict [check ] = []
284
312
uncondensed_dict [check ].append (scenario )
285
313
286
314
# condense those scenarios
287
315
condensed_dict = {}
288
316
if CONDENSE_TESTS :
317
+ i = 0
289
318
for check in uncondensed_dict .keys ():
290
319
scenarios = uncondensed_dict [check ]
291
320
condensed_dict [check ] = condense_keep_options (scenarios )
321
+ i += 1
322
+ print ("Condensed " + str (i ) + " of " + str (len (uncondensed_dict .keys ())))
292
323
else :
293
324
for check in uncondensed_dict .keys ():
294
325
fullarray = uncondensed_dict [check ]
@@ -310,18 +341,42 @@ def main():
310
341
# do a deep-copy of the scenario because sets can only be accessed by pop which alters the set itself
311
342
scenario_copy = copy .deepcopy (scenario )
312
343
desc = get_combi_description (scenario [0 ], scenario [1 ], scenario [2 ], scenario [3 ], scenario [4 ], scenario [5 ],
313
- scenario [6 ])
344
+ scenario [6 ], scenario [ 7 ] )
314
345
mode = scenario_copy [0 ].pop ()
315
346
standardtime = scenario_copy [1 ].pop ()
316
347
students_state = scenario_copy [2 ].pop ()
317
348
idnumber_state = scenario_copy [3 ].pop ()
318
349
mapped_state = scenario_copy [4 ].pop ()
319
350
internal_state = scenario_copy [5 ].pop ()
320
351
actual_state = scenario_copy [6 ].pop ()
352
+ recordstandardtime = scenario_copy [7 ].pop ()
321
353
if actual_state == "mixed" and len (scenario_copy [6 ]) > 0 :
322
354
actual_state = scenario_copy [6 ].pop ()
355
+
356
+ corrected = True
357
+ illegal = False
358
+ illegals = []
359
+ while corrected :
360
+ corrected = False
361
+ if illegal_state ([mode , standardtime , students_state , idnumber_state , mapped_state , internal_state ,
362
+ actual_state , recordstandardtime ]):
363
+ corrected = True
364
+ illegals .append ([mode , standardtime , students_state , idnumber_state , mapped_state , internal_state ,
365
+ actual_state , recordstandardtime ])
366
+ if len (scenario_copy [5 ]) >= 1 :
367
+ internal_state = scenario_copy [5 ].pop ()
368
+ elif len (scenario_copy [7 ]) >= 1 :
369
+ recordstandardtime = scenario_copy [7 ].pop ()
370
+ else :
371
+ if len (illegals ) > 1 :
372
+ print ("Illegal multiscenario" )
373
+ print (illegals )
374
+ illegal = True
375
+ corrected = False
376
+ if illegal :
377
+ continue
323
378
scen_text = get_scenario (mode , standardtime , students_state , idnumber_state , mapped_state , internal_state ,
324
- actual_state )
379
+ actual_state , recordstandardtime )
325
380
if not scen_text :
326
381
print ("Warning impossible scenario!!!" )
327
382
continue
0 commit comments