Skip to content

Commit dcd3977

Browse files
author
rtschu
committed
removed lsfcourseid var and introduced checking for coursetitle
1 parent fcc9687 commit dcd3977

File tree

4 files changed

+28
-20
lines changed

4 files changed

+28
-20
lines changed
8.92 KB
Binary file not shown.
6.8 KB
Binary file not shown.

tests/behat/generator/generator.py

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
category = 1
88
coursename = "C1"
99
tags = "@block @block_evasys_sync @block_evasys_sync_fulltest"
10-
lsfcourseid = 0
1110
# options
1211
OPTIONS = {
1312
"automode": ["manual", "auto"],
@@ -19,13 +18,6 @@
1918
"actualstate": ["open", "closed", "mixed"]
2019
}
2120

22-
### GLOBAL VARIABLES ###
23-
# Section for non-intuitive global variables
24-
# - lsfcourseid:
25-
# This variable gets reset to 0 everytime a new scenario is building. Everytime a scenario is added via
26-
# declaring a valid idnumber (+1) a single link course (+1) or mutiple linked courses(+2) it gets incremented.
27-
# after these parameters have been processed, the text to mock *idnumber* evasyscourses will be added.
28-
2921

3022
def get_checks(mode, standardtime, students_state, idnumber_state, mapped_state, internal_state, actual_state):
3123
"""
@@ -77,16 +69,16 @@ def get_checks(mode, standardtime, students_state, idnumber_state, mapped_state,
7769
return checks
7870

7971

80-
def get_postcondensing_checks():
72+
def get_postcondensing_checks(idnumber_state, mapped_state):
8173
"""
8274
:return: checks for a scenario that should NOT be considered in the condense step
8375
"""
8476
postchecks = ""
8577
# Check that surveys are actually shown.
8678
# We don't want to include this in the sorting, because it only tests a for loop, but multiplies the tests by 2.
87-
global lsfcourseid
88-
for i in range(0, lsfcourseid):
89-
postchecks += "And I should see \"Name: Evatestcourse " + str(i) + "\"\n"
79+
postchecks += postcheck_idnumber(idnumber_state)
80+
postchecks += postcheck_mappedstate(mapped_state)
81+
9082
postchecks = postchecks.replace("\n", "\n ")
9183
return postchecks
9284

@@ -140,8 +132,6 @@ def get_scenario(mode, standardtime, students_state, idnumber_state, mapped_stat
140132
This constructs the actual scenario by building all courses, states etc.
141133
:return: string the combined enviroment specifiing string for a scenario
142134
"""
143-
global lsfcourseid
144-
lsfcourseid = 0
145135
behat_scenario = manual_auto_mode[mode].replace("{{category}}", str(category)) + "\n"
146136
behat_scenario += standardtimeMode[standardtime].replace("{{category}}", str(category)) + "\n"
147137
behat_scenario += studentsState[students_state] + "\n"
@@ -153,7 +143,8 @@ def get_scenario(mode, standardtime, students_state, idnumber_state, mapped_stat
153143
behat_scenario += "And I turn editing mode off\n"
154144
behat_scenario = behat_scenario.replace("\n", "\n ")
155145

156-
if actual_state == "mixed" and lsfcourseid < 2:
146+
if actual_state == "mixed" and not ((idnumber_state == "one" and (mapped_state == "multi" or mapped_state == "one"))
147+
or mapped_state == "multi"):
157148
# a mixed state is impossible with less than 2 lsfscourseids, so we skip this.
158149
return False
159150
return behat_scenario
@@ -308,7 +299,7 @@ def main():
308299
if not scen_text:
309300
print("Warning impossible scenario!!!")
310301
continue
311-
postcheck = get_postcondensing_checks()
302+
postcheck = get_postcondensing_checks(idnumber_state, mapped_state)
312303
output += make_scenario(desc, scen_text, check + postcheck)
313304

314305
output = output.replace("\n \n", "\n\n") # remove whitespaces on empty lines

tests/behat/generator/steps.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from generator import coursename, lsfcourseid
1+
from generator import coursename
22
import random
33
# Background
44
background = ' Background:\n\
@@ -121,15 +121,13 @@
121121
# There are only methods when using a dict (like above) is either unnecessarry complicated
122122
# needs preparation (from a state like "multi" to an array of surveys)
123123
# or something has to be added programatically (like coursenames or ids)
124-
lsfcourseid = 0
125124

126125

127126
def idnumberState(state, openstate):
128127
"""
129128
:param state: idnumber state (none/invalid/one)
130129
:return: String either creating none, an invalid or one evasys-course - moodle-course link via idnumber
131130
"""
132-
global lsfcourseid
133131
if state == "none":
134132
return "And there is no idnumber mapped to course " + coursename + "\n"
135133
elif state == "invalid":
@@ -144,7 +142,6 @@ def mappedState(state, openstate):
144142
:param state: mapped state (none/invalid/one/multi)
145143
:return: a string creating none, only invalid, one or multiple mappings of a moodle-course to evasys-courses
146144
"""
147-
global lsfcourseid
148145
if state == "none":
149146
return "And no courses are mapped to course " + coursename + "\n"
150147
elif state == "invalid":
@@ -199,6 +196,26 @@ def checks_internalstate(internal_state, actual_state, student_state, no_valid_m
199196
return checks
200197

201198

199+
def postcheck_idnumber(idnumber_state):
200+
if idnumber_state == "one":
201+
return 'And I should see "IdnumberSurvey"\n'
202+
else:
203+
return 'And I should not see "IdnumberSurvey"\n'
204+
205+
206+
def postcheck_mappedstate(mapped_state):
207+
postchecks = ""
208+
if mapped_state == "one":
209+
postchecks += 'And I should see "DynamicSurvey0"\n'
210+
postchecks += 'And I should not see "DynamicSurvey1"\n'
211+
elif mapped_state == "mulit":
212+
postchecks += 'And I should see "DynamicSurvey0"\n'
213+
postchecks += 'And I should see "DynamicSurvey1"\n'
214+
else:
215+
postchecks += 'And I should not see "DynamicSurvey"\n'
216+
return postchecks
217+
218+
202219
def description_modeconsistency(mode, internal_state, actual_state):
203220
description = ""
204221
# check if there is a mismatch in internal_state and mode (i.E. auto mode but manually opened internal state)

0 commit comments

Comments
 (0)