Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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
edx
edx-platform
Commits
17a04798
Commit
17a04798
authored
Oct 02, 2013
by
Gabe Mulley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add acceptance tests for event tracking
parent
b62abe65
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
85 additions
and
0 deletions
+85
-0
lms/djangoapps/courseware/features/events.feature
+14
-0
lms/djangoapps/courseware/features/events.py
+62
-0
lms/djangoapps/courseware/features/navigation.feature
+1
-0
lms/djangoapps/courseware/features/problems.feature
+2
-0
lms/envs/acceptance.py
+6
-0
No files found.
lms/djangoapps/courseware/features/events.feature
0 → 100644
View file @
17a04798
@shard_2
Feature
:
LMS.Events
As a researcher, I want to be able to track events in the LMS
Scenario Outline
:
An
event is emitted for each request
Given
:
I
am registered for the course
"6.002x"
And
I visit the url
"<url>"
Then
a
"<url>"
server event is emitted
Examples
:
|
url
|
|
/dashboard
|
|
/courses/edx/6.002x/Test_Course/info
|
|
/courses/edx/6.002x/Test_Course/courseware
|
lms/djangoapps/courseware/features/events.py
0 → 100644
View file @
17a04798
#pylint: disable=C0111
from
lettuce
import
step
from
lettuce
import
world
from
lettuce
import
before
from
pymongo
import
MongoClient
from
nose.tools
import
assert_equals
from
nose.tools
import
assert_in
@before.all
def
connect_to_mongodb
():
world
.
mongo_client
=
MongoClient
()
world
.
event_collection
=
world
.
mongo_client
[
'track'
][
'events'
]
@before.each_scenario
def
reset_captured_events
(
_scenario
):
world
.
event_collection
.
drop
()
@before.outline
def
reset_between_outline_scenarios
(
_scenario
,
order
,
outline
,
reasons_to_fail
):
world
.
event_collection
.
drop
()
@step
(
'[aA]n? "(.*)" (server|browser) event is emitted'
)
def
event_is_emitted
(
_step
,
event_type
,
event_source
):
# Ensure all events are written out to mongo before querying.
world
.
mongo_client
.
fsync
()
# Note that splinter makes 2 requests when you call browser.visit('/foo')
# the first just checks to see if the server responds with a status
# code of 200, the next actually uses the browser to submit the request.
# We filter out events associated with the status code checks by ignoring
# events that come directly from splinter.
criteria
=
{
'event_type'
:
event_type
,
'event_source'
:
event_source
,
'agent'
:
{
'$ne'
:
'python/splinter'
}
}
cursor
=
world
.
event_collection
.
find
(
criteria
)
assert_equals
(
cursor
.
count
(),
1
)
event
=
cursor
.
next
()
# These fields should be present in the event, but we won't bother
# validating them since it is difficult to predict their values.
for
expected_field
in
[
'host'
,
'time'
,
'agent'
,
'ip'
,
'event_source'
,
'event'
,
'page'
]:
assert_in
(
expected_field
,
event
,
msg
=
'Expected field {} not found in event'
.
format
(
expected_field
))
expected_field_values
=
{
"username"
:
world
.
scenario_dict
[
'USER'
]
.
username
,
"event_type"
:
event_type
,
}
for
key
,
value
in
expected_field_values
.
iteritems
():
assert_equals
(
event
[
key
],
value
)
# Note that the event may contain other fields, which is fine!
lms/djangoapps/courseware/features/navigation.feature
View file @
17a04798
...
@@ -18,6 +18,7 @@ Feature: LMS.Navigate Course
...
@@ -18,6 +18,7 @@ Feature: LMS.Navigate Course
Given
I am viewing a section with multiple sequences
Given
I am viewing a section with multiple sequences
When
I navigate to an item in a sequence
When
I navigate to an item in a sequence
Then
I see the content of the sequence item
Then
I see the content of the sequence item
And
a
"seq_goto"
browser event is emitted
Scenario
:
I
can return to the last section I visited
Scenario
:
I
can return to the last section I visited
Given
I am viewing a course with multiple sections
Given
I am viewing a course with multiple sections
...
...
lms/djangoapps/courseware/features/problems.feature
View file @
17a04798
...
@@ -10,6 +10,8 @@ Feature: LMS.Answer problems
...
@@ -10,6 +10,8 @@ Feature: LMS.Answer problems
When
I answer a
"<ProblemType>"
problem
"correctly"
When
I answer a
"<ProblemType>"
problem
"correctly"
Then
my
"<ProblemType>"
answer is marked
"correct"
Then
my
"<ProblemType>"
answer is marked
"correct"
And
The
"<ProblemType>"
problem displays a
"correct"
answer
And
The
"<ProblemType>"
problem displays a
"correct"
answer
And
a
"problem_check"
server event is emitted
And
a
"problem_check"
browser event is emitted
Examples
:
Examples
:
|
ProblemType
|
|
ProblemType
|
...
...
lms/envs/acceptance.py
View file @
17a04798
...
@@ -74,6 +74,12 @@ DATABASES = {
...
@@ -74,6 +74,12 @@ DATABASES = {
}
}
}
}
TRACKING_BACKENDS
.
update
({
'mongo'
:
{
'ENGINE'
:
'track.backends.mongodb.MongoBackend'
}
})
# Forums are disabled in test.py to speed up unit tests, but we do not have
# Forums are disabled in test.py to speed up unit tests, but we do not have
# per-test control for acceptance tests
# per-test control for acceptance tests
MITX_FEATURES
[
'ENABLE_DISCUSSION_SERVICE'
]
=
True
MITX_FEATURES
[
'ENABLE_DISCUSSION_SERVICE'
]
=
True
...
...
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