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
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
63 deletions
+64
-63
tests/integration/test_interaction.py
+64
-63
No files found.
tests/integration/test_interaction.py
View file @
dcf7b6a2
# Imports ###########################################################
from
ddt
import
ddt
,
data
from
ddt
import
ddt
,
data
,
unpack
from
mock
import
Mock
,
patch
from
selenium.common.exceptions
import
NoSuchElementException
...
...
@@ -366,7 +366,64 @@ class BasicInteractionTest(DefaultDataTestMixin, InteractionTestBase):
self
.
interact_with_keyboard_help
()
@ddt
class
EventsFiredTest
(
DefaultDataTestMixin
,
InteractionTestBase
,
BaseIntegrationTest
):
"""
Tests that the analytics events are fired and in the proper order.
"""
# These events must be fired in this order.
scenarios
=
(
{
'name'
:
'edx.drag_and_drop_v2.loaded'
,
'data'
:
{
'component_id'
:
u'drag-and-drop-v2.drag-and-drop-v2.d0.u0'
,
'user_id'
:
'student_1'
},
},
{
'name'
:
'edx.drag_and_drop_v2.item.picked_up'
,
'data'
:
{
'component_id'
:
u'drag-and-drop-v2.drag-and-drop-v2.d0.u0'
,
'user_id'
:
'student_1'
,
'item_id'
:
0
,
},
},
{
'name'
:
'grade'
,
'data'
:
{
'max_value'
:
1
,
'value'
:
(
1.0
/
3
)},
},
{
'name'
:
'edx.drag_and_drop_v2.item.dropped'
,
'data'
:
{
'component_id'
:
u'drag-and-drop-v2.drag-and-drop-v2.d0.u0'
,
'input'
:
None
,
'is_correct'
:
True
,
'is_correct_location'
:
True
,
'item_id'
:
0
,
'location'
:
u'The Top Zone'
,
'user_id'
:
'student_1'
,
},
},
{
'name'
:
'edx.drag_and_drop_v2.feedback.opened'
,
'data'
:
{
'component_id'
:
u'drag-and-drop-v2.drag-and-drop-v2.d0.u0'
,
'content'
:
u'Correct! This one belongs to The Top Zone.'
,
'user_id'
:
'student_1'
,
'truncated'
:
False
,
},
},
{
'name'
:
'edx.drag_and_drop_v2.feedback.closed'
,
'data'
:
{
'component_id'
:
u'drag-and-drop-v2.drag-and-drop-v2.d0.u0'
,
'user_id'
:
'student_1'
,
'manually'
:
False
,
'content'
:
u'Correct! This one belongs to The Top Zone.'
,
'truncated'
:
False
,
},
},
)
def
setUp
(
self
):
mock
=
Mock
()
...
...
@@ -379,70 +436,14 @@ class EventsFiredTest(DefaultDataTestMixin, InteractionTestBase, BaseIntegration
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'
,
'user_id'
:
'student_1'
}
)
def
test_picked_up
(
self
):
self
.
parameterized_item_positive_feedback_on_good_move
(
self
.
items_map
)
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'
,
'user_id'
:
'student_1'
,
'item_id'
:
0
,
}
)
def
test_dropped
(
self
):
self
.
parameterized_item_positive_feedback_on_good_move
(
self
.
items_map
)
# 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'
)
self
.
assertEqual
(
event_data
,
{
'component_id'
:
u'drag-and-drop-v2.drag-and-drop-v2.d0.u0'
,
'input'
:
None
,
'is_correct'
:
True
,
'is_correct_location'
:
True
,
'item_id'
:
0
,
'location'
:
u'The Top Zone'
,
'user_id'
:
'student_1'
,
}
)
def
test_feedback_opened
(
self
):
self
.
parameterized_item_positive_feedback_on_good_move
(
self
.
items_map
)
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'
,
'content'
:
u'Correct! This one belongs to The Top Zone.'
,
'user_id'
:
'student_1'
,
'truncated'
:
False
,
}
)
def
test_feedback_closed
(
self
):
@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
,
event_data
=
self
.
publish
.
call_args_list
[
5
][
0
]
self
.
assertEqual
(
name
,
'edx.drag_and_drop_v2.feedback.closed'
)
dummy
,
name
,
published_data
=
self
.
publish
.
call_args_list
[
index
][
0
]
self
.
assertEqual
(
name
,
event
[
'name'
]
)
self
.
assertEqual
(
event_data
,
{
'component_id'
:
u'drag-and-drop-v2.drag-and-drop-v2.d0.u0'
,
'user_id'
:
'student_1'
,
'manually'
:
False
,
'content'
:
u'Correct! This one belongs to The Top Zone.'
,
'truncated'
:
False
,
}
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