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 " )
@@ -110,13 +134,15 @@ def get_combi_sentence(set, dictionary, param_name):
110134
111135
112136def get_combi_description (mode , standardtime , students_state , idnumber_state , mapped_state , internal_state ,
113- actual_state ):
137+ actual_state , recordstandardtimemode ):
114138 """
115139 This will construct the description for a scenario that covers multiple states.
116140 :return: String the description of the scenario.
117141 """
118142 if "none" in mapped_state and "none" in idnumber_state :
119143 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 }
120146 description = ""
121147 description += get_combi_sentence (standardtime , standardtimemode_descriptions , "standardtime" )
122148 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
127153 return description
128154
129155
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 ):
131157 """
132158 This constructs the actual scenario by building all courses, states etc.
133159 :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
138164 behat_scenario += step_idnumberstate (idnumber_state , actual_state )
139165 behat_scenario += step_mappedstate (mapped_state , actual_state )
140166 behat_scenario += step_internal_state [internal_state ].replace ("{{course}}" , str (coursename )) + "\n "
167+ behat_scenario += step_record_standardtimemode [recordstandardtimemode ].replace ("{{course}}" , str (coursename )) + "\n "
141168 behat_scenario += "And I turn editing mode on\n "
142169 behat_scenario += "And I add the \" EvaSys Sync\" block\n "
143170 behat_scenario += "And I turn editing mode off\n "
@@ -220,6 +247,7 @@ def condense_keep_options(fullarray):
220247 if changed :
221248 break
222249 fullarray = new_array
250+
223251 return fullarray
224252
225253
@@ -252,17 +280,20 @@ def main():
252280 # get the checks for all options to be able to condense options with the same expected outcome
253281 uncondensed_dict = {}
254282 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 ] )
256284 if not check in uncondensed_dict .keys ():
257285 uncondensed_dict [check ] = []
258286 uncondensed_dict [check ].append (scenario )
259287
260288 # condense those scenarios
261289 condensed_dict = {}
262290 if CONDENSE_TESTS :
291+ i = 0
263292 for check in uncondensed_dict .keys ():
264293 scenarios = uncondensed_dict [check ]
265294 condensed_dict [check ] = condense_keep_options (scenarios )
295+ i += 1
296+ print ("Condensed " + str (i ) + " of " + str (len (uncondensed_dict .keys ())))
266297 else :
267298 for check in uncondensed_dict .keys ():
268299 fullarray = uncondensed_dict [check ]
@@ -284,18 +315,42 @@ def main():
284315 # do a deep-copy of the scenario because sets can only be accessed by pop which alters the set itself
285316 scenario_copy = copy .deepcopy (scenario )
286317 desc = get_combi_description (scenario [0 ], scenario [1 ], scenario [2 ], scenario [3 ], scenario [4 ], scenario [5 ],
287- scenario [6 ])
318+ scenario [6 ], scenario [ 7 ] )
288319 mode = scenario_copy [0 ].pop ()
289320 standardtime = scenario_copy [1 ].pop ()
290321 students_state = scenario_copy [2 ].pop ()
291322 idnumber_state = scenario_copy [3 ].pop ()
292323 mapped_state = scenario_copy [4 ].pop ()
293324 internal_state = scenario_copy [5 ].pop ()
294325 actual_state = scenario_copy [6 ].pop ()
326+ recordstandardtime = scenario_copy [7 ].pop ()
295327 if actual_state == "mixed" and len (scenario_copy [6 ]) > 0 :
296328 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
297352 scen_text = get_scenario (mode , standardtime , students_state , idnumber_state , mapped_state , internal_state ,
298- actual_state )
353+ actual_state , recordstandardtime )
299354 if not scen_text :
300355 print ("Warning impossible scenario!!!" )
301356 continue
0 commit comments