Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
problem-builder
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
problem-builder
Commits
86c9db9c
Commit
86c9db9c
authored
Jan 03, 2014
by
Xavier Antoviaque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds tests for <quizz> block
parent
7ba0c8d2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
148 additions
and
0 deletions
+148
-0
tests/test_quizz.py
+123
-0
tests/xml/quizz_1.xml
+25
-0
No files found.
tests/test_quizz.py
0 → 100644
View file @
86c9db9c
# Imports ###########################################################
import
time
from
mentoring.test_base
import
MentoringBaseTest
# Classes ###########################################################
class
QuizzBlockTest
(
MentoringBaseTest
):
def
test_quizz_choices_rating
(
self
):
link
=
self
.
browser
.
find_element_by_link_text
(
'Quizz 1'
)
link
.
click
()
# Mentoring block
vertical
=
self
.
browser
.
find_element_by_css_selector
(
'div.vertical'
)
mentoring
=
vertical
.
find_element_by_css_selector
(
'div.mentoring'
)
# Initial quizzes status
quizz1
=
mentoring
.
find_element_by_css_selector
(
'fieldset.choices'
)
quizz2
=
mentoring
.
find_element_by_css_selector
(
'fieldset.rating'
)
messages
=
mentoring
.
find_element_by_css_selector
(
'.messages'
)
progress
=
mentoring
.
find_element_by_css_selector
(
'.progress > .indicator'
)
self
.
assertEqual
(
messages
.
text
,
''
)
self
.
assertFalse
(
messages
.
find_elements_by_xpath
(
'./*'
))
self
.
assertEqual
(
progress
.
text
,
'(Not completed)'
)
self
.
assertFalse
(
progress
.
find_elements_by_xpath
(
'./*'
))
quizz1_legend
=
quizz1
.
find_element_by_css_selector
(
'legend'
)
quizz2_legend
=
quizz2
.
find_element_by_css_selector
(
'legend'
)
self
.
assertEqual
(
quizz1_legend
.
text
,
'Do you like this quizz?'
)
self
.
assertEqual
(
quizz2_legend
.
text
,
'How much do you rate this quizz?'
)
quizz1_choices
=
quizz1
.
find_elements_by_css_selector
(
'.choices .choice label'
)
quizz2_choices
=
quizz2
.
find_elements_by_css_selector
(
'.choices .choice label'
)
self
.
assertEqual
(
len
(
quizz1_choices
),
3
)
self
.
assertEqual
(
len
(
quizz2_choices
),
6
)
self
.
assertEqual
(
quizz1_choices
[
0
]
.
text
,
'Yes'
)
self
.
assertEqual
(
quizz1_choices
[
1
]
.
text
,
'Maybe not'
)
self
.
assertEqual
(
quizz1_choices
[
2
]
.
text
,
"I don't understand"
)
self
.
assertEqual
(
quizz2_choices
[
0
]
.
text
,
'1'
)
self
.
assertEqual
(
quizz2_choices
[
1
]
.
text
,
'2'
)
self
.
assertEqual
(
quizz2_choices
[
2
]
.
text
,
'3'
)
self
.
assertEqual
(
quizz2_choices
[
3
]
.
text
,
'4'
)
self
.
assertEqual
(
quizz2_choices
[
4
]
.
text
,
'5'
)
self
.
assertEqual
(
quizz2_choices
[
5
]
.
text
,
"I don't want to rate it"
)
quizz1_choices_input
=
[
quizz1_choices
[
0
]
.
find_element_by_css_selector
(
'input'
),
quizz1_choices
[
1
]
.
find_element_by_css_selector
(
'input'
),
quizz1_choices
[
2
]
.
find_element_by_css_selector
(
'input'
),
]
quizz2_choices_input
=
[
quizz2_choices
[
0
]
.
find_element_by_css_selector
(
'input'
),
quizz2_choices
[
1
]
.
find_element_by_css_selector
(
'input'
),
quizz2_choices
[
2
]
.
find_element_by_css_selector
(
'input'
),
quizz2_choices
[
3
]
.
find_element_by_css_selector
(
'input'
),
quizz2_choices
[
4
]
.
find_element_by_css_selector
(
'input'
),
quizz2_choices
[
5
]
.
find_element_by_css_selector
(
'input'
),
]
self
.
assertEqual
(
quizz1_choices_input
[
0
]
.
get_attribute
(
'value'
),
'yes'
)
self
.
assertEqual
(
quizz1_choices_input
[
1
]
.
get_attribute
(
'value'
),
'maybenot'
)
self
.
assertEqual
(
quizz1_choices_input
[
2
]
.
get_attribute
(
'value'
),
'understand'
)
self
.
assertEqual
(
quizz2_choices_input
[
0
]
.
get_attribute
(
'value'
),
'1'
)
self
.
assertEqual
(
quizz2_choices_input
[
1
]
.
get_attribute
(
'value'
),
'2'
)
self
.
assertEqual
(
quizz2_choices_input
[
2
]
.
get_attribute
(
'value'
),
'3'
)
self
.
assertEqual
(
quizz2_choices_input
[
3
]
.
get_attribute
(
'value'
),
'4'
)
self
.
assertEqual
(
quizz2_choices_input
[
4
]
.
get_attribute
(
'value'
),
'5'
)
self
.
assertEqual
(
quizz2_choices_input
[
5
]
.
get_attribute
(
'value'
),
'notwant'
)
# Submit without selecting anything
submit
=
mentoring
.
find_element_by_css_selector
(
'input.submit'
)
submit
.
click
()
tips
=
messages
.
find_elements_by_xpath
(
'./*'
)
self
.
assertEqual
(
len
(
tips
),
2
)
self
.
assertEqual
(
tips
[
0
]
.
text
,
'To the question "Do you like this quizz?", you have not provided an answer.'
)
self
.
assertEqual
(
tips
[
1
]
.
text
,
'To the question "How much do you rate this quizz?", you have not provided an answer.'
)
self
.
assertEqual
(
progress
.
text
,
'(Not completed)'
)
self
.
assertFalse
(
progress
.
find_elements_by_xpath
(
'./*'
))
# Select only one option
quizz1_choices_input
[
1
]
.
click
()
submit
.
click
()
tips
=
messages
.
find_elements_by_xpath
(
'./*'
)
self
.
assertEqual
(
len
(
tips
),
2
)
self
.
assertEqual
(
tips
[
0
]
.
text
,
'To the question "Do you like this quizz?", you answered "Maybe not".
\n
Ah, damn.'
)
self
.
assertEqual
(
tips
[
1
]
.
text
,
'To the question "How much do you rate this quizz?", you have not provided an answer.'
)
self
.
assertEqual
(
progress
.
text
,
'(Not completed)'
)
self
.
assertFalse
(
progress
.
find_elements_by_xpath
(
'./*'
))
# One with only display tip, one with reject tip - should not complete
quizz1_choices_input
[
0
]
.
click
()
quizz2_choices_input
[
2
]
.
click
()
submit
.
click
()
time
.
sleep
(
1
)
tips
=
messages
.
find_elements_by_xpath
(
'./*'
)
self
.
assertEqual
(
len
(
tips
),
2
)
self
.
assertEqual
(
tips
[
0
]
.
text
,
'To the question "Do you like this quizz?", you answered "Yes".
\n
Great!'
)
self
.
assertEqual
(
tips
[
1
]
.
text
,
'To the question "How much do you rate this quizz?", you answered "3".
\n
Will do better next time...'
)
self
.
assertEqual
(
progress
.
text
,
'(Not completed)'
)
self
.
assertFalse
(
progress
.
find_elements_by_xpath
(
'./*'
))
# Only display tips, to allow to complete
quizz1_choices_input
[
0
]
.
click
()
quizz2_choices_input
[
3
]
.
click
()
submit
.
click
()
time
.
sleep
(
1
)
tips
=
messages
.
find_elements_by_xpath
(
'./*'
)
self
.
assertEqual
(
len
(
tips
),
3
)
self
.
assertEqual
(
tips
[
0
]
.
text
,
'To the question "Do you like this quizz?", you answered "Yes".
\n
Great!'
)
self
.
assertEqual
(
tips
[
1
]
.
text
,
'To the question "How much do you rate this quizz?", you answered "4".
\n
I love good grades.'
)
self
.
assertEqual
(
tips
[
2
]
.
text
,
'All is good now - congratulations!'
)
self
.
assertEqual
(
progress
.
text
,
''
)
self
.
assertTrue
(
progress
.
find_elements_by_css_selector
(
'img'
))
tests/xml/quizz_1.xml
0 → 100644
View file @
86c9db9c
<vertical>
<mentoring
url_name=
"quizz_1"
enforce_dependency=
"false"
>
<quizz
name=
"quizz_1_1"
type=
"choices"
>
<question>
Do you like this quizz?
</question>
<choice
value=
"yes"
>
Yes
</choice>
<choice
value=
"maybenot"
>
Maybe not
</choice>
<choice
value=
"understand"
>
I don't understand
</choice>
<tip
display=
"yes"
>
Great!
</tip>
<tip
reject=
"maybenot"
>
Ah, damn.
</tip>
<tip
reject=
"understand"
><html><div
id=
"test-custom-html"
>
Really?
</div></html></tip>
</quizz>
<quizz
name=
"quizz_1_2"
type=
"rating"
low=
"Not good at all"
high=
"Extremely good"
>
<question>
How much do you rate this quizz?
</question>
<choice
value=
"notwant"
>
I don't want to rate it
</choice>
<tip
display=
"4,5"
>
I love good grades.
</tip>
<tip
reject=
"1,2,3"
>
Will do better next time...
</tip>
<tip
reject=
"notwant"
>
Your loss!
</tip>
</quizz>
<message
type=
"completed"
>
All is good now - congratulations!
</message>
</mentoring>
</vertical>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment