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
e0fb68ce
Commit
e0fb68ce
authored
Mar 01, 2016
by
Jacek Bzdak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added two new tests for the new behavior.
parent
cc5c2727
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
82 additions
and
43 deletions
+82
-43
problem_builder/tests/integration/base_test.py
+17
-0
problem_builder/tests/integration/test_mentoring.py
+39
-9
problem_builder/tests/integration/xml_templates/feedback_persistence_mcq_no_tips.xml
+11
-0
problem_builder/tests/integration/xml_templates/feedback_persistence_mcq_tips.xml
+15
-0
problem_builder/tests/integration/xml_templates/feedback_persistence_no_tips_in_mcq.xml
+0
-34
No files found.
problem_builder/tests/integration/base_test.py
View file @
e0fb68ce
...
@@ -63,6 +63,23 @@ class PopupCheckMixin(object):
...
@@ -63,6 +63,23 @@ class PopupCheckMixin(object):
self
.
assertFalse
(
item_feedback_popup
.
is_displayed
())
self
.
assertFalse
(
item_feedback_popup
.
is_displayed
())
class
ScrollToMixin
(
object
):
def
scroll_to
(
self
,
component
,
offset
=
100
):
"""
Scrolls browser viewport so component is visible. In rare cases you might
need to provide an offset, which will change position by some amount
of pixels.
:return:
"""
self
.
browser
.
execute_script
(
"return window.scrollTo(0, arguments[0]);"
,
component
.
location
[
'y'
]
+
offset
)
self
.
browser
.
execute_script
(
"return window.scrollTo(0, arguments[0]);"
,
component
.
location
[
'y'
]
-
offset
)
class
ProblemBuilderBaseTest
(
SeleniumXBlockTest
,
PopupCheckMixin
,
ScrollToMixin
):
class
ProblemBuilderBaseTest
(
SeleniumXBlockTest
,
PopupCheckMixin
,
ScrollToMixin
):
"""
"""
The new base class for integration tests.
The new base class for integration tests.
...
...
problem_builder/tests/integration/test_mentoring.py
View file @
e0fb68ce
...
@@ -137,12 +137,16 @@ class ProblemBuilderQuestionnaireBlockTest(ProblemBuilderBaseTest):
...
@@ -137,12 +137,16 @@ class ProblemBuilderQuestionnaireBlockTest(ProblemBuilderBaseTest):
self
.
assertFalse
(
choice_input
.
is_selected
())
self
.
assertFalse
(
choice_input
.
is_selected
())
def
_standard_filling
(
self
,
answer
,
mcq
,
mrq
,
rating
):
def
_standard_filling
(
self
,
answer
,
mcq
,
mrq
,
rating
):
self
.
scroll_to
(
answer
)
answer
.
send_keys
(
'This is the answer'
)
answer
.
send_keys
(
'This is the answer'
)
self
.
scroll_to
(
mcq
)
self
.
click_choice
(
mcq
,
"Yes"
)
self
.
click_choice
(
mcq
,
"Yes"
)
# 1st, 3rd and 4th options, first three are correct, i.e. two mistakes: 2nd and 4th
# 1st, 3rd and 4th options, first three are correct, i.e. two mistakes: 2nd and 4th
self
.
scroll_to
(
mrq
,
300
)
self
.
click_choice
(
mrq
,
"Its elegance"
)
self
.
click_choice
(
mrq
,
"Its elegance"
)
self
.
click_choice
(
mrq
,
"Its gracefulness"
)
self
.
click_choice
(
mrq
,
"Its gracefulness"
)
self
.
click_choice
(
mrq
,
"Its bugs"
)
self
.
click_choice
(
mrq
,
"Its bugs"
)
self
.
scroll_to
(
rating
)
self
.
click_choice
(
rating
,
"4"
)
self
.
click_choice
(
rating
,
"4"
)
# mcq and rating can't be reset easily, but it's not required; listing them here to keep method signature similar
# mcq and rating can't be reset easily, but it's not required; listing them here to keep method signature similar
...
@@ -153,8 +157,11 @@ class ProblemBuilderQuestionnaireBlockTest(ProblemBuilderBaseTest):
...
@@ -153,8 +157,11 @@ class ProblemBuilderQuestionnaireBlockTest(ProblemBuilderBaseTest):
checkbox
.
click
()
checkbox
.
click
()
def
_standard_checks
(
self
,
answer
,
mcq
,
mrq
,
rating
,
messages
):
def
_standard_checks
(
self
,
answer
,
mcq
,
mrq
,
rating
,
messages
):
self
.
scroll_to
(
answer
)
self
.
assertEqual
(
answer
.
get_attribute
(
'value'
),
'This is the answer'
)
self
.
assertEqual
(
answer
.
get_attribute
(
'value'
),
'This is the answer'
)
self
.
scroll_to
(
mcq
)
self
.
_assert_feedback_showed
(
mcq
,
0
,
"Great!"
,
click_choice_result
=
True
)
self
.
_assert_feedback_showed
(
mcq
,
0
,
"Great!"
,
click_choice_result
=
True
)
self
.
scroll_to
(
mrq
,
300
)
self
.
_assert_feedback_showed
(
self
.
_assert_feedback_showed
(
mrq
,
0
,
"This is something everyone has to like about this MRQ"
,
mrq
,
0
,
"This is something everyone has to like about this MRQ"
,
click_choice_result
=
True
click_choice_result
=
True
...
@@ -165,18 +172,23 @@ class ProblemBuilderQuestionnaireBlockTest(ProblemBuilderBaseTest):
...
@@ -165,18 +172,23 @@ class ProblemBuilderQuestionnaireBlockTest(ProblemBuilderBaseTest):
)
)
self
.
_assert_feedback_showed
(
mrq
,
2
,
"This MRQ is indeed very graceful"
,
click_choice_result
=
True
)
self
.
_assert_feedback_showed
(
mrq
,
2
,
"This MRQ is indeed very graceful"
,
click_choice_result
=
True
)
self
.
_assert_feedback_showed
(
mrq
,
3
,
"Nah, there aren't any!"
,
click_choice_result
=
True
,
success
=
False
)
self
.
_assert_feedback_showed
(
mrq
,
3
,
"Nah, there aren't any!"
,
click_choice_result
=
True
,
success
=
False
)
self
.
scroll_to
(
rating
)
self
.
_assert_feedback_showed
(
rating
,
3
,
"I love good grades."
,
click_choice_result
=
True
)
self
.
_assert_feedback_showed
(
rating
,
3
,
"I love good grades."
,
click_choice_result
=
True
)
self
.
assertTrue
(
messages
.
is_displayed
())
self
.
assertTrue
(
messages
.
is_displayed
())
self
.
scroll_to
(
messages
)
self
.
assertEqual
(
messages
.
text
,
"FEEDBACK
\n
Not done yet"
)
self
.
assertEqual
(
messages
.
text
,
"FEEDBACK
\n
Not done yet"
)
def
_feedback_customized_checks
(
self
,
answer
,
mcq
,
mrq
,
rating
,
messages
):
def
_feedback_customized_checks
(
self
,
answer
,
mcq
,
mrq
,
rating
,
messages
):
# Long answer: Previous answer and feedback visible
# Long answer: Previous answer and feedback visible
self
.
scroll_to
(
answer
)
self
.
assertEqual
(
answer
.
get_attribute
(
'value'
),
'This is the answer'
)
self
.
assertEqual
(
answer
.
get_attribute
(
'value'
),
'This is the answer'
)
# MCQ: Previous answer and feedback hidden
# MCQ: Previous answer and feedback hidden
self
.
scroll_to
(
mcq
)
for
i
in
range
(
3
):
for
i
in
range
(
3
):
self
.
_assert_feedback_hidden
(
mcq
,
i
)
self
.
_assert_feedback_hidden
(
mcq
,
i
)
self
.
_assert_not_checked
(
mcq
,
i
)
self
.
_assert_not_checked
(
mcq
,
i
)
# MRQ: Previous answer and feedback visible
# MRQ: Previous answer and feedback visible
self
.
scroll_to
(
mrq
,
300
)
self
.
_assert_feedback_showed
(
self
.
_assert_feedback_showed
(
mrq
,
0
,
"This is something everyone has to like about this MRQ"
,
mrq
,
0
,
"This is something everyone has to like about this MRQ"
,
click_choice_result
=
True
click_choice_result
=
True
...
@@ -188,11 +200,13 @@ class ProblemBuilderQuestionnaireBlockTest(ProblemBuilderBaseTest):
...
@@ -188,11 +200,13 @@ class ProblemBuilderQuestionnaireBlockTest(ProblemBuilderBaseTest):
self
.
_assert_feedback_showed
(
mrq
,
2
,
"This MRQ is indeed very graceful"
,
click_choice_result
=
True
)
self
.
_assert_feedback_showed
(
mrq
,
2
,
"This MRQ is indeed very graceful"
,
click_choice_result
=
True
)
self
.
_assert_feedback_showed
(
mrq
,
3
,
"Nah, there aren't any!"
,
click_choice_result
=
True
,
success
=
False
)
self
.
_assert_feedback_showed
(
mrq
,
3
,
"Nah, there aren't any!"
,
click_choice_result
=
True
,
success
=
False
)
# Rating: Previous answer and feedback hidden
# Rating: Previous answer and feedback hidden
self
.
scroll_to
(
rating
)
for
i
in
range
(
5
):
for
i
in
range
(
5
):
self
.
_assert_feedback_hidden
(
rating
,
i
)
self
.
_assert_feedback_hidden
(
rating
,
i
)
self
.
_assert_not_checked
(
rating
,
i
)
self
.
_assert_not_checked
(
rating
,
i
)
# Messages
# Messages
self
.
assertTrue
(
messages
.
is_displayed
())
self
.
assertTrue
(
messages
.
is_displayed
())
self
.
scroll_to
(
messages
)
self
.
assertEqual
(
messages
.
text
,
"FEEDBACK
\n
Not done yet"
)
self
.
assertEqual
(
messages
.
text
,
"FEEDBACK
\n
Not done yet"
)
def
reload_student_view
(
self
):
def
reload_student_view
(
self
):
...
@@ -205,7 +219,7 @@ class ProblemBuilderQuestionnaireBlockTest(ProblemBuilderBaseTest):
...
@@ -205,7 +219,7 @@ class ProblemBuilderQuestionnaireBlockTest(ProblemBuilderBaseTest):
return
title
and
title
.
text
==
"XBlock scenarios"
return
title
and
title
.
text
==
"XBlock scenarios"
wait
.
until
(
did_load_homepage
,
u"Workbench home page should have loaded"
)
wait
.
until
(
did_load_homepage
,
u"Workbench home page should have loaded"
)
mentoring
=
self
.
go_to_view
(
"student_view"
)
mentoring
=
self
.
go_to_view
(
"student_view"
)
self
.
wait_until_visible
(
self
.
_get_
messages_element
(
mentoring
))
self
.
wait_until_visible
(
self
.
_get_
xblock
(
mentoring
,
"feedback_mcq_2"
))
return
mentoring
return
mentoring
def
test_feedbacks_and_messages_is_not_shown_on_first_load
(
self
):
def
test_feedbacks_and_messages_is_not_shown_on_first_load
(
self
):
...
@@ -249,14 +263,6 @@ class ProblemBuilderQuestionnaireBlockTest(ProblemBuilderBaseTest):
...
@@ -249,14 +263,6 @@ class ProblemBuilderQuestionnaireBlockTest(ProblemBuilderBaseTest):
self
.
click_choice
(
mrq
,
"Its elegance"
)
self
.
click_choice
(
mrq
,
"Its elegance"
)
self
.
assertTrue
(
submit
.
is_enabled
())
self
.
assertTrue
(
submit
.
is_enabled
())
@ddt.unpack
@ddt.data
(
# Standard scenario
(
"feedback_persistence.xml"
,
),
# Like feedback_persistence but instead of tips in MCQ
# has a question level feedback. This feedback should also be suppressed.
(
"feedback_persistence_no_tips_in_mcq.xml"
,
)
)
def
test_does_not_persist_mcq_feedback_on_page_reload_if_disabled
(
self
,
scenario
):
def
test_does_not_persist_mcq_feedback_on_page_reload_if_disabled
(
self
,
scenario
):
with
mock
.
patch
(
"problem_builder.mentoring.MentoringBlock.get_options"
)
as
patched_options
:
with
mock
.
patch
(
"problem_builder.mentoring.MentoringBlock.get_options"
)
as
patched_options
:
patched_options
.
return_value
=
{
'pb_mcq_hide_previous_answer'
:
True
}
patched_options
.
return_value
=
{
'pb_mcq_hide_previous_answer'
:
True
}
...
@@ -279,8 +285,11 @@ class ProblemBuilderQuestionnaireBlockTest(ProblemBuilderBaseTest):
...
@@ -279,8 +285,11 @@ class ProblemBuilderQuestionnaireBlockTest(ProblemBuilderBaseTest):
self
.
assertFalse
(
submit
.
is_enabled
())
self
.
assertFalse
(
submit
.
is_enabled
())
# ... until student answers MCQs again
# ... until student answers MCQs again
self
.
scroll_to
(
mcq
)
self
.
click_choice
(
mcq
,
"Maybe not"
)
self
.
click_choice
(
mcq
,
"Maybe not"
)
self
.
scroll_to
(
rating
)
self
.
click_choice
(
rating
,
"2"
)
self
.
click_choice
(
rating
,
"2"
)
self
.
scroll_to
(
submit
)
self
.
assertTrue
(
submit
.
is_enabled
())
self
.
assertTrue
(
submit
.
is_enabled
())
def
test_given_perfect_score_in_past_loads_current_result
(
self
):
def
test_given_perfect_score_in_past_loads_current_result
(
self
):
...
@@ -362,3 +371,24 @@ class ProblemBuilderQuestionnaireBlockTest(ProblemBuilderBaseTest):
...
@@ -362,3 +371,24 @@ class ProblemBuilderQuestionnaireBlockTest(ProblemBuilderBaseTest):
answer
,
mcq
,
mrq
,
rating
=
self
.
_get_controls
(
mentoring
)
answer
,
mcq
,
mrq
,
rating
=
self
.
_get_controls
(
mentoring
)
messages
=
self
.
_get_messages_element
(
mentoring
)
messages
=
self
.
_get_messages_element
(
mentoring
)
assert_state
(
answer
,
mcq
,
mrq
,
rating
,
messages
)
assert_state
(
answer
,
mcq
,
mrq
,
rating
,
messages
)
@ddt.unpack
@ddt.data
(
# MCQ with tips
(
"feedback_persistence_mcq_tips.xml"
,
'.choice-tips'
),
# Like feedback_persistence but instead of tips in MCQ
# has a question level feedback. This feedback should also be suppressed.
(
"feedback_persistence_mcq_no_tips.xml"
,
'.feedback'
)
)
def
testFeedbackPersistenceTips
(
self
,
scenario
,
tips_selector
):
mentoring
=
self
.
load_scenario
(
scenario
)
mcq
=
self
.
_get_xblock
(
mentoring
,
"feedback_mcq_2"
)
messages
=
mentoring
.
find_element_by_css_selector
(
tips_selector
)
self
.
assertFalse
(
messages
.
is_displayed
())
self
.
click_choice
(
mcq
,
"Yes"
)
self
.
click_submit
(
mentoring
)
self
.
assertTrue
(
messages
.
is_displayed
())
self
.
reload_student_view
()
mentoring
=
self
.
load_scenario
(
scenario
)
messages
=
mentoring
.
find_element_by_css_selector
(
tips_selector
)
self
.
assertFalse
(
messages
.
is_displayed
())
problem_builder/tests/integration/xml_templates/feedback_persistence_mcq_no_tips.xml
0 → 100644
View file @
e0fb68ce
<vertical_demo>
<problem-builder
url_name=
"feedback_tips"
enforce_dependency=
"false"
>
<pb-mcq
name=
"feedback_mcq_2"
question=
"Do you like this MCQ?"
correct_choices=
'["yes"]'
message=
"Question level Feedback"
>
<pb-choice
value=
"yes"
>
Yes
</pb-choice>
<pb-choice
value=
"maybenot"
>
Maybe not
</pb-choice>
<pb-choice
value=
"understand"
>
I don't understand
</pb-choice>
</pb-mcq>
</problem-builder>
</vertical_demo>
problem_builder/tests/integration/xml_templates/feedback_persistence_mcq_tips.xml
0 → 100644
View file @
e0fb68ce
<vertical_demo>
<problem-builder
url_name=
"feedback_no_tips"
enforce_dependency=
"false"
>
<pb-mcq
name=
"feedback_mcq_2"
question=
"Do you like this MCQ?"
correct_choices=
'["yes"]'
>
<pb-choice
value=
"yes"
>
Yes
</pb-choice>
<pb-choice
value=
"maybenot"
>
Maybe not
</pb-choice>
<pb-choice
value=
"understand"
>
I don't understand
</pb-choice>
<pb-tip
values=
'["yes"]'
>
Great!
</pb-tip>
<pb-tip
values=
'["maybenot"]'
>
Ah, damn.
</pb-tip>
<pb-tip
values=
'["understand"]'
><div
id=
"test-custom-html"
>
Really?
</div></pb-tip>
</pb-mcq>
</problem-builder>
</vertical_demo>
problem_builder/tests/integration/xml_templates/feedback_persistence_no_tips_in_mcq.xml
deleted
100644 → 0
View file @
cc5c2727
<vertical_demo>
<problem-builder
url_name=
"feedback"
enforce_dependency=
"false"
>
<pb-answer
name=
"feedback_answer_1"
/>
<pb-mcq
name=
"feedback_mcq_2"
question=
"Do you like this MCQ?"
correct_choices=
'["yes"]'
message=
"Question level Feedback"
>
<pb-choice
value=
"yes"
>
Yes
</pb-choice>
<pb-choice
value=
"maybenot"
>
Maybe not
</pb-choice>
<pb-choice
value=
"understand"
>
I don't understand
</pb-choice>
</pb-mcq>
<pb-mrq
name=
"feedback_mrq_3"
question=
"What do you like in this MRQ?"
required_choices=
'["elegance","gracefulness","beauty"]'
>
<pb-choice
value=
"elegance"
>
Its elegance
</pb-choice>
<pb-choice
value=
"beauty"
>
Its beauty
</pb-choice>
<pb-choice
value=
"gracefulness"
>
Its gracefulness
</pb-choice>
<pb-choice
value=
"bugs"
>
Its bugs
</pb-choice>
<pb-tip
values=
'["elegance"]'
>
This is something everyone has to like about this MRQ
</pb-tip>
<pb-tip
values=
'["beauty"]'
>
This is something everyone has to like about beauty
</pb-tip>
<pb-tip
values=
'["gracefulness"]'
>
This MRQ is indeed very graceful
</pb-tip>
<pb-tip
values=
'["bugs"]'
>
Nah, there aren't any!
</pb-tip>
</pb-mrq>
<pb-rating
name=
"feedback_rating_4"
low=
"Not good at all"
high=
"Extremely good"
question=
"How do you rate this MCQ?"
correct_choices=
'["4","5"]'
>
<pb-choice
value=
"notwant"
>
I don't want to rate it
</pb-choice>
<pb-tip
values=
'["4","5"]'
>
I love good grades.
</pb-tip>
<pb-tip
values=
'["1","2","3"]'
>
Will do better next time...
</pb-tip>
<pb-tip
values=
'["notwant"]'
>
Your loss!
</pb-tip>
</pb-rating>
<pb-message
type=
"completed"
>
All Good
</pb-message>
<pb-message
type=
"incomplete"
>
Not done yet
</pb-message>
</problem-builder>
</vertical_demo>
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