1515 "idnumber" : ["none" , "invalid" , "one" ],
1616 "mapped" : ["none" , "invalid" , "one" , "multi" ],
1717 "internalstate" : ["notopened" , "opened" , "closed" , "manual" , "none" ],
18- "actualstate" : ["open" , "closed" , "mixed" ]
18+ "actualstate" : ["open" , "closed" , "mixed" ],
19+ "recordstandardtime" : ["recordstandardtimemode" , "recordnonstandardtimemode" , "norecordstandardtimemode" ]
1920}
2021
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+
2145
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 ):
2347 """
2448 This Function will take the scenario parameters and construct the resulting checks.
2549 :return: The combined checks for the parameters.
2650 """
27- checks = ""
2851 # If there are no mapped courses the Block not offer the option to "Show surveys"
2952 if (idnumber_state == "none" ) and (mapped_state == "none" ):
3053 return "Then I should see \" Change mapping\" \n And I should not see \" Name:\" \n "
3154
55+ checks = ""
3256 # In all other cases (even if there are only invalid entries) we need to click the button to start code execution
3357 checks += "And I load the evasys block\n "
3458
@@ -62,7 +86,7 @@ def get_checks(mode, standardtime, students_state, idnumber_state, mapped_state,
6286 checks += "And I should see \" There are some closed surveys, but all surveys should be open.\" " + "\n "
6387
6488 # 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 "
6690 # if there are no students that are eligible to evaluate we want to output a warning
6791 checks += student_checks [students_state ]
6892 checks = checks .replace ("\n " , "\n " )
@@ -136,13 +160,15 @@ def get_combi_sentence(set, dictionary, param_name):
136160
137161
138162def get_combi_description (mode , standardtime , students_state , idnumber_state , mapped_state , internal_state ,
139- actual_state ):
163+ actual_state , recordstandardtimemode ):
140164 """
141165 This will construct the description for a scenario that covers multiple states.
142166 :return: String the description of the scenario.
143167 """
144168 if "none" in mapped_state and "none" in idnumber_state :
145169 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 }
146172 description = ""
147173 description += get_combi_sentence (standardtime , standardtimemode_descriptions , "standardtime" )
148174 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
153179 return description
154180
155181
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 ):
157183 """
158184 This constructs the actual scenario by building all courses, states etc.
159185 :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
164190 behat_scenario += step_idnumberstate (idnumber_state , actual_state )
165191 behat_scenario += step_mappedstate (mapped_state , actual_state )
166192 behat_scenario += step_internal_state [internal_state ].replace ("{{course}}" , str (coursename )) + "\n "
193+ behat_scenario += step_record_standardtimemode [recordstandardtimemode ].replace ("{{course}}" , str (coursename )) + "\n "
167194 behat_scenario += "And I turn editing mode on\n "
168195 behat_scenario += "And I add the \" EvaSys Sync\" block\n "
169196 behat_scenario += "And I turn editing mode off\n "
@@ -246,6 +273,7 @@ def condense_keep_options(fullarray):
246273 if changed :
247274 break
248275 fullarray = new_array
276+
249277 return fullarray
250278
251279
@@ -278,17 +306,20 @@ def main():
278306 # get the checks for all options to be able to condense options with the same expected outcome
279307 uncondensed_dict = {}
280308 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 ] )
282310 if not check in uncondensed_dict .keys ():
283311 uncondensed_dict [check ] = []
284312 uncondensed_dict [check ].append (scenario )
285313
286314 # condense those scenarios
287315 condensed_dict = {}
288316 if CONDENSE_TESTS :
317+ i = 0
289318 for check in uncondensed_dict .keys ():
290319 scenarios = uncondensed_dict [check ]
291320 condensed_dict [check ] = condense_keep_options (scenarios )
321+ i += 1
322+ print ("Condensed " + str (i ) + " of " + str (len (uncondensed_dict .keys ())))
292323 else :
293324 for check in uncondensed_dict .keys ():
294325 fullarray = uncondensed_dict [check ]
@@ -310,18 +341,42 @@ def main():
310341 # do a deep-copy of the scenario because sets can only be accessed by pop which alters the set itself
311342 scenario_copy = copy .deepcopy (scenario )
312343 desc = get_combi_description (scenario [0 ], scenario [1 ], scenario [2 ], scenario [3 ], scenario [4 ], scenario [5 ],
313- scenario [6 ])
344+ scenario [6 ], scenario [ 7 ] )
314345 mode = scenario_copy [0 ].pop ()
315346 standardtime = scenario_copy [1 ].pop ()
316347 students_state = scenario_copy [2 ].pop ()
317348 idnumber_state = scenario_copy [3 ].pop ()
318349 mapped_state = scenario_copy [4 ].pop ()
319350 internal_state = scenario_copy [5 ].pop ()
320351 actual_state = scenario_copy [6 ].pop ()
352+ recordstandardtime = scenario_copy [7 ].pop ()
321353 if actual_state == "mixed" and len (scenario_copy [6 ]) > 0 :
322354 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
323378 scen_text = get_scenario (mode , standardtime , students_state , idnumber_state , mapped_state , internal_state ,
324- actual_state )
379+ actual_state , recordstandardtime )
325380 if not scen_text :
326381 print ("Warning impossible scenario!!!" )
327382 continue
0 commit comments