Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xblock-mentoring
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
xblock-mentoring
Commits
d92c56bd
Commit
d92c56bd
authored
Sep 19, 2014
by
dragonfi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor assert_tips_present in test_quizz
parent
884aef2d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
31 deletions
+28
-31
tests/test_quizz.py
+28
-31
No files found.
tests/test_quizz.py
View file @
d92c56bd
...
@@ -31,6 +31,12 @@ from mentoring.test_base import MentoringBaseTest
...
@@ -31,6 +31,12 @@ from mentoring.test_base import MentoringBaseTest
# Classes ###########################################################
# Classes ###########################################################
class
QuizzBlockTest
(
MentoringBaseTest
):
class
QuizzBlockTest
(
MentoringBaseTest
):
def
assert_tips_present
(
self
,
messages
,
*
args
):
tips
=
messages
.
find_elements_by_xpath
(
'./*'
)
self
.
assertEqual
(
len
(
tips
),
len
(
args
)
+
1
)
self
.
assertEqual
(
tips
[
0
]
.
text
,
'FEEDBACK'
)
for
i
in
range
(
len
(
args
)):
self
.
assertEqual
(
tips
[
i
+
1
]
.
text
,
args
[
i
])
def
test_quizz_choices_rating
(
self
):
def
test_quizz_choices_rating
(
self
):
"""
"""
...
@@ -95,13 +101,13 @@ class QuizzBlockTest(MentoringBaseTest):
...
@@ -95,13 +101,13 @@ class QuizzBlockTest(MentoringBaseTest):
submit
=
mentoring
.
find_element_by_css_selector
(
'input.submit'
)
submit
=
mentoring
.
find_element_by_css_selector
(
'input.submit'
)
submit
.
click
()
submit
.
click
()
tips
=
messages
.
find_elements_by_css_selector
(
'.quizz-tip'
)
self
.
assert_tips_present
(
messages
,
self
.
assertEqual
(
len
(
tips
),
2
)
'To the question "Do you like this quizz?", you have not provided an answer.'
,
self
.
assertEqual
(
tips
[
0
]
.
text
,
'To the question "Do you like this quizz?", you have not provided an answer.'
)
'To the question "How much do you rate 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.'
)
)
# TODO:
Cannot test rejection of partial answers, as partial answers
# TODO:
Test rejection of partial answers. Unable to do, since
#
are allowed when dependencies are not enforced, even if the block
#
partial answers are allowed when dependencies are not enforced,
# reports non-completion.
#
even if the block
reports non-completion.
#self.assertEqual(progress.text, '(Not completed)')
#self.assertEqual(progress.text, '(Not completed)')
#self.assertFalse(progress.find_elements_by_xpath('./*'))
#self.assertFalse(progress.find_elements_by_xpath('./*'))
...
@@ -110,15 +116,11 @@ class QuizzBlockTest(MentoringBaseTest):
...
@@ -110,15 +116,11 @@ class QuizzBlockTest(MentoringBaseTest):
submit
.
click
()
submit
.
click
()
time
.
sleep
(
1
)
time
.
sleep
(
1
)
tips
=
messages
.
find_elements_by_css_selector
(
'.quizz-tip'
)
self
.
assert_tips_present
(
messages
,
self
.
assertEqual
(
len
(
tips
),
2
)
'To the question "Do you like this quizz?", you answered "Maybe not".
\n
Ah, damn.'
,
self
.
assertEqual
(
tips
[
0
]
.
text
,
'To the question "Do you like this quizz?", you answered "Maybe not".
\n
Ah, damn.'
)
'To the question "How much do you rate 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.'
)
)
# TODO: Cannot test rejection of partial answers, as partial answers
# TODO: Test rejection of partial answers
# are allowed when dependencies are not enforced, even if the block
# reports non-completion.
#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
# One with only display tip, one with reject tip - should not complete
quizz1_choices_input
[
0
]
.
click
()
quizz1_choices_input
[
0
]
.
click
()
...
@@ -126,15 +128,11 @@ class QuizzBlockTest(MentoringBaseTest):
...
@@ -126,15 +128,11 @@ class QuizzBlockTest(MentoringBaseTest):
submit
.
click
()
submit
.
click
()
time
.
sleep
(
1
)
time
.
sleep
(
1
)
tips
=
messages
.
find_elements_by_css_selector
(
'.quizz-tip'
)
self
.
assert_tips_present
(
messages
,
self
.
assertEqual
(
len
(
tips
),
2
)
'To the question "Do you like this quizz?", you answered "Yes".
\n
Great!'
,
self
.
assertEqual
(
tips
[
0
]
.
text
,
'To the question "Do you like this quizz?", you answered "Yes".
\n
Great!'
)
'To the question "How much do you rate this quizz?", you answered "3".
\n
Will do better next time...'
,
self
.
assertEqual
(
tips
[
1
]
.
text
,
'To the question "How much do you rate this quizz?", you answered "3".
\n
Will do better next time...'
)
)
# TODO: Cannot test rejection of partial answers, as partial answers
# TODO: Test rejection of partial answers
# are allowed when dependencies are not enforced, even if the block
# reports non-completion.
#self.assertEqual(progress.text, '(Not completed)')
#self.assertFalse(progress.find_elements_by_xpath('./*'))
# Only display tips, to allow to complete
# Only display tips, to allow to complete
quizz1_choices_input
[
0
]
.
click
()
quizz1_choices_input
[
0
]
.
click
()
...
@@ -142,12 +140,11 @@ class QuizzBlockTest(MentoringBaseTest):
...
@@ -142,12 +140,11 @@ class QuizzBlockTest(MentoringBaseTest):
submit
.
click
()
submit
.
click
()
time
.
sleep
(
1
)
time
.
sleep
(
1
)
tips
=
messages
.
find_elements_by_xpath
(
'./*'
)
self
.
assert_tips_present
(
messages
,
self
.
assertEqual
(
len
(
tips
),
4
)
'To the question "Do you like this quizz?", you answered "Yes".
\n
Great!'
,
self
.
assertEqual
(
tips
[
0
]
.
text
,
'FEEDBACK'
)
'To the question "How much do you rate this quizz?", you answered "4".
\n
I love good grades.'
,
self
.
assertEqual
(
tips
[
1
]
.
text
,
'To the question "Do you like this quizz?", you answered "Yes".
\n
Great!'
)
'Congratulations!
\n
All is good now...'
,
self
.
assertEqual
(
tips
[
2
]
.
text
,
'To the question "How much do you rate this quizz?", you answered "4".
\n
I love good grades.'
)
)
self
.
assertEqual
(
tips
[
3
]
.
text
,
'Congratulations!
\n
All is good now...'
)
# Includes child <html>
self
.
assertEqual
(
progress
.
text
,
''
)
self
.
assertEqual
(
progress
.
text
,
''
)
self
.
assertTrue
(
progress
.
find_elements_by_css_selector
(
'img'
))
self
.
assertTrue
(
progress
.
find_elements_by_css_selector
(
'img'
))
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