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
03aee3ed
Commit
03aee3ed
authored
Jun 27, 2013
by
Adam Palay
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add tests
parent
af75e1f7
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
97 additions
and
0 deletions
+97
-0
cms/djangoapps/contentstore/tests/test_request_event.py
+35
-0
cms/envs/test.py
+3
-0
common/djangoapps/track/tests.py
+55
-0
common/djangoapps/track/views.py
+1
-0
lms/envs/test.py
+3
-0
No files found.
cms/djangoapps/contentstore/tests/test_request_event.py
0 → 100644
View file @
03aee3ed
from
django.test
import
TestCase
from
django.core.urlresolvers
import
reverse
from
contentstore.views.requests
import
event
as
cms_user_track
class
CMSLogTest
(
TestCase
):
"""
Tests that request to logs from CMS return 204s
"""
def
test_post_answers_to_log
(
self
):
"""
Checks that student answer requests submitted to cms's "/event" url
via POST are correctly returned as 204s
"""
requests
=
[
{
"event"
:
"my_event"
,
"event_type"
:
"my_event_type"
,
"page"
:
"my_page"
},
{
"event"
:
"{'json': 'object'}"
,
"event_type"
:
unichr
(
512
),
"page"
:
"my_page"
}
]
for
request_params
in
requests
:
response
=
self
.
client
.
post
(
reverse
(
cms_user_track
),
request_params
)
self
.
assertEqual
(
response
.
status_code
,
204
)
def
test_get_answers_to_log
(
self
):
"""
Checks that student answer requests submitted to cms's "/event" url
via GET are correctly returned as 204s
"""
requests
=
[
{
"event"
:
"my_event"
,
"event_type"
:
"my_event_type"
,
"page"
:
"my_page"
},
{
"event"
:
"{'json': 'object'}"
,
"event_type"
:
unichr
(
512
),
"page"
:
"my_page"
}
]
for
request_params
in
requests
:
response
=
self
.
client
.
get
(
reverse
(
cms_user_track
),
request_params
)
self
.
assertEqual
(
response
.
status_code
,
204
)
cms/envs/test.py
View file @
03aee3ed
...
...
@@ -140,3 +140,6 @@ SEGMENT_IO_KEY = '***REMOVED***'
MITX_FEATURES
[
'STUDIO_NPS_SURVEY'
]
=
False
MITX_FEATURES
[
'ENABLE_SERVICE_STATUS'
]
=
True
# Enabling SQL tracking logs for testing on common/djangoapps/track
MITX_FEATURES
[
'ENABLE_SQL_TRACKING_LOGS'
]
=
True
common/djangoapps/track/tests.py
0 → 100644
View file @
03aee3ed
from
django.test
import
TestCase
from
django.core.urlresolvers
import
reverse
,
NoReverseMatch
from
track.models
import
TrackingLog
from
track.views
import
user_track
from
nose.plugins.skip
import
SkipTest
class
TrackingTest
(
TestCase
):
"""
Tests that tracking logs correctly handle events
"""
def
test_post_answers_to_log
(
self
):
"""
Checks that student answer requests submitted to track.views via POST
are correctly logged in the TrackingLog db table
"""
requests
=
[
{
"event"
:
"my_event"
,
"event_type"
:
"my_event_type"
,
"page"
:
"my_page"
},
{
"event"
:
"{'json': 'object'}"
,
"event_type"
:
unichr
(
512
),
"page"
:
"my_page"
}
]
for
request_params
in
requests
:
try
:
# because /event maps to two different views in lms and cms, we're only going to test lms here
response
=
self
.
client
.
post
(
reverse
(
user_track
),
request_params
)
except
NoReverseMatch
:
raise
SkipTest
()
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
content
,
'success'
)
tracking_logs
=
TrackingLog
.
objects
.
order_by
(
'-dtcreated'
)
log
=
tracking_logs
[
0
]
self
.
assertEqual
(
log
.
event
,
request_params
[
"event"
])
self
.
assertEqual
(
log
.
event_type
,
request_params
[
"event_type"
])
self
.
assertEqual
(
log
.
page
,
request_params
[
"page"
])
def
test_get_answers_to_log
(
self
):
"""
Checks that student answer requests submitted to track.views via GET
are correctly logged in the TrackingLog db table
"""
requests
=
[
{
"event"
:
"my_event"
,
"event_type"
:
"my_event_type"
,
"page"
:
"my_page"
},
{
"event"
:
"{'json': 'object'}"
,
"event_type"
:
unichr
(
512
),
"page"
:
"my_page"
}
]
for
request_params
in
requests
:
try
:
# because /event maps to two different views in lms and cms, we're only going to test lms here
response
=
self
.
client
.
get
(
reverse
(
user_track
),
request_params
)
except
NoReverseMatch
:
raise
SkipTest
()
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
content
,
'success'
)
tracking_logs
=
TrackingLog
.
objects
.
order_by
(
'-dtcreated'
)
log
=
tracking_logs
[
0
]
self
.
assertEqual
(
log
.
event
,
request_params
[
"event"
])
self
.
assertEqual
(
log
.
event_type
,
request_params
[
"event_type"
])
self
.
assertEqual
(
log
.
page
,
request_params
[
"page"
])
common/djangoapps/track/views.py
View file @
03aee3ed
...
...
@@ -67,6 +67,7 @@ def user_track(request):
"time"
:
datetime
.
datetime
.
now
(
UTC
)
.
isoformat
(),
"host"
:
request
.
META
[
'SERVER_NAME'
],
}
log_event
(
event
)
return
HttpResponse
(
'success'
)
...
...
lms/envs/test.py
View file @
03aee3ed
...
...
@@ -29,6 +29,9 @@ MITX_FEATURES['ENABLE_SERVICE_STATUS'] = True
MITX_FEATURES
[
'ENABLE_HINTER_INSTRUCTOR_VIEW'
]
=
True
# Enabling SQL tracking logs for testing on common/djangoapps/track
MITX_FEATURES
[
'ENABLE_SQL_TRACKING_LOGS'
]
=
True
# Need wiki for courseware views to work. TODO (vshnayder): shouldn't need it.
WIKI_ENABLED
=
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