Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xblock-drag-and-drop-v2
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-drag-and-drop-v2
Commits
dcf7b6a2
Commit
dcf7b6a2
authored
Jan 15, 2016
by
Jonathan Piacenti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor event tests.
parent
82a02bc3
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
56 deletions
+57
-56
tests/integration/test_interaction.py
+57
-56
No files found.
tests/integration/test_interaction.py
View file @
dcf7b6a2
# Imports ###########################################################
# Imports ###########################################################
from
ddt
import
ddt
,
data
from
ddt
import
ddt
,
data
,
unpack
from
mock
import
Mock
,
patch
from
mock
import
Mock
,
patch
from
selenium.common.exceptions
import
NoSuchElementException
from
selenium.common.exceptions
import
NoSuchElementException
...
@@ -366,48 +366,35 @@ class BasicInteractionTest(DefaultDataTestMixin, InteractionTestBase):
...
@@ -366,48 +366,35 @@ class BasicInteractionTest(DefaultDataTestMixin, InteractionTestBase):
self
.
interact_with_keyboard_help
()
self
.
interact_with_keyboard_help
()
@ddt
class
EventsFiredTest
(
DefaultDataTestMixin
,
InteractionTestBase
,
BaseIntegrationTest
):
class
EventsFiredTest
(
DefaultDataTestMixin
,
InteractionTestBase
,
BaseIntegrationTest
):
"""
def
setUp
(
self
):
Tests that the analytics events are fired and in the proper order.
mock
=
Mock
()
"""
context
=
patch
.
object
(
WorkbenchRuntime
,
'publish'
,
mock
)
# These events must be fired in this order.
context
.
start
()
scenarios
=
(
self
.
addCleanup
(
context
.
stop
)
{
self
.
publish
=
mock
'name'
:
'edx.drag_and_drop_v2.loaded'
,
super
(
EventsFiredTest
,
self
)
.
setUp
()
'data'
:
{
def
_get_scenario_xml
(
self
):
# pylint: disable=no-self-use
return
"<vertical_demo><drag-and-drop-v2/></vertical_demo>"
def
test_loaded
(
self
):
dummy
,
name
,
event_data
=
self
.
publish
.
call_args
[
0
]
self
.
assertEqual
(
name
,
'edx.drag_and_drop_v2.loaded'
)
self
.
assertEqual
(
event_data
,
{
'component_id'
:
u'drag-and-drop-v2.drag-and-drop-v2.d0.u0'
,
'component_id'
:
u'drag-and-drop-v2.drag-and-drop-v2.d0.u0'
,
'user_id'
:
'student_1'
'user_id'
:
'student_1'
}
},
)
},
{
def
test_picked_up
(
self
):
'name'
:
'edx.drag_and_drop_v2.item.picked_up'
,
self
.
parameterized_item_positive_feedback_on_good_move
(
self
.
items_map
)
'data'
:
{
dummy
,
name
,
event_data
=
self
.
publish
.
call_args_list
[
1
][
0
]
self
.
assertEqual
(
name
,
'edx.drag_and_drop_v2.item.picked_up'
)
self
.
assertEqual
(
event_data
,
{
'component_id'
:
u'drag-and-drop-v2.drag-and-drop-v2.d0.u0'
,
'component_id'
:
u'drag-and-drop-v2.drag-and-drop-v2.d0.u0'
,
'user_id'
:
'student_1'
,
'user_id'
:
'student_1'
,
'item_id'
:
0
,
'item_id'
:
0
,
}
},
)
},
{
def
test_dropped
(
self
):
'name'
:
'grade'
,
self
.
parameterized_item_positive_feedback_on_good_move
(
self
.
items_map
)
'data'
:
{
'max_value'
:
1
,
'value'
:
(
1.0
/
3
)},
# Skipping to 3, since 2 is grade event.
},
dummy
,
name
,
event_data
=
self
.
publish
.
call_args_list
[
3
][
0
]
{
self
.
assertEqual
(
name
,
'edx.drag_and_drop_v2.item.dropped'
)
'name'
:
'edx.drag_and_drop_v2.item.dropped'
,
self
.
assertEqual
(
'data'
:
{
event_data
,
{
'component_id'
:
u'drag-and-drop-v2.drag-and-drop-v2.d0.u0'
,
'component_id'
:
u'drag-and-drop-v2.drag-and-drop-v2.d0.u0'
,
'input'
:
None
,
'input'
:
None
,
'is_correct'
:
True
,
'is_correct'
:
True
,
...
@@ -415,34 +402,48 @@ class EventsFiredTest(DefaultDataTestMixin, InteractionTestBase, BaseIntegration
...
@@ -415,34 +402,48 @@ class EventsFiredTest(DefaultDataTestMixin, InteractionTestBase, BaseIntegration
'item_id'
:
0
,
'item_id'
:
0
,
'location'
:
u'The Top Zone'
,
'location'
:
u'The Top Zone'
,
'user_id'
:
'student_1'
,
'user_id'
:
'student_1'
,
}
},
)
},
{
def
test_feedback_opened
(
self
):
'name'
:
'edx.drag_and_drop_v2.feedback.opened'
,
self
.
parameterized_item_positive_feedback_on_good_move
(
self
.
items_map
)
'data'
:
{
dummy
,
name
,
event_data
=
self
.
publish
.
call_args_list
[
4
][
0
]
self
.
assertEqual
(
name
,
'edx.drag_and_drop_v2.feedback.opened'
)
self
.
assertEqual
(
event_data
,
{
'component_id'
:
u'drag-and-drop-v2.drag-and-drop-v2.d0.u0'
,
'component_id'
:
u'drag-and-drop-v2.drag-and-drop-v2.d0.u0'
,
'content'
:
u'Correct! This one belongs to The Top Zone.'
,
'content'
:
u'Correct! This one belongs to The Top Zone.'
,
'user_id'
:
'student_1'
,
'user_id'
:
'student_1'
,
'truncated'
:
False
,
'truncated'
:
False
,
}
},
)
},
{
def
test_feedback_closed
(
self
):
'name'
:
'edx.drag_and_drop_v2.feedback.closed'
,
self
.
parameterized_item_positive_feedback_on_good_move
(
self
.
items_map
)
'data'
:
{
dummy
,
name
,
event_data
=
self
.
publish
.
call_args_list
[
5
][
0
]
self
.
assertEqual
(
name
,
'edx.drag_and_drop_v2.feedback.closed'
)
self
.
assertEqual
(
event_data
,
{
'component_id'
:
u'drag-and-drop-v2.drag-and-drop-v2.d0.u0'
,
'component_id'
:
u'drag-and-drop-v2.drag-and-drop-v2.d0.u0'
,
'user_id'
:
'student_1'
,
'user_id'
:
'student_1'
,
'manually'
:
False
,
'manually'
:
False
,
'content'
:
u'Correct! This one belongs to The Top Zone.'
,
'content'
:
u'Correct! This one belongs to The Top Zone.'
,
'truncated'
:
False
,
'truncated'
:
False
,
}
},
},
)
def
setUp
(
self
):
mock
=
Mock
()
context
=
patch
.
object
(
WorkbenchRuntime
,
'publish'
,
mock
)
context
.
start
()
self
.
addCleanup
(
context
.
stop
)
self
.
publish
=
mock
super
(
EventsFiredTest
,
self
)
.
setUp
()
def
_get_scenario_xml
(
self
):
# pylint: disable=no-self-use
return
"<vertical_demo><drag-and-drop-v2/></vertical_demo>"
@data
(
*
enumerate
(
scenarios
))
# pylint: disable=star-args
@unpack
def
test_event
(
self
,
index
,
event
):
self
.
parameterized_item_positive_feedback_on_good_move
(
self
.
items_map
)
dummy
,
name
,
published_data
=
self
.
publish
.
call_args_list
[
index
][
0
]
self
.
assertEqual
(
name
,
event
[
'name'
])
self
.
assertEqual
(
published_data
,
event
[
'data'
]
)
)
...
...
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