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
72aeb2c8
Commit
72aeb2c8
authored
Feb 11, 2016
by
wajeeha-khalid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implemented test event data for thread/comment vote
parent
3312eb2d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
4 deletions
+44
-4
lms/djangoapps/discussion_api/api.py
+7
-2
lms/djangoapps/discussion_api/tests/test_api.py
+37
-2
No files found.
lms/djangoapps/discussion_api/api.py
View file @
72aeb2c8
...
...
@@ -9,7 +9,6 @@ from django.core.exceptions import ValidationError
from
django.core.urlresolvers
import
reverse
from
django.http
import
Http404
import
itertools
from
lms.djangoapps.django_comment_client.base.views
import
track_voted_event
from
rest_framework.exceptions
import
PermissionDenied
...
...
@@ -26,7 +25,11 @@ from discussion_api.permissions import (
get_initializable_thread_fields
,
)
from
discussion_api.serializers
import
CommentSerializer
,
ThreadSerializer
,
get_context
from
django_comment_client.base.views
import
track_comment_created_event
,
track_thread_created_event
from
django_comment_client.base.views
import
(
track_comment_created_event
,
track_thread_created_event
,
track_voted_event
,
)
from
django_comment_common.signals
import
(
thread_created
,
thread_edited
,
...
...
@@ -511,6 +514,8 @@ def _do_extra_actions(api_content, cc_content, request_fields, actions_form, con
_handle_abuse_flagged_field
(
form_value
,
context
[
"cc_requester"
],
cc_content
)
elif
field
==
"voted"
:
_handle_voted_field
(
form_value
,
cc_content
,
api_content
,
request
,
context
)
else
:
raise
ValidationError
({
field
:
[
"Invalid Key"
]})
def
_handle_following_field
(
form_value
,
user
,
cc_content
):
...
...
lms/djangoapps/discussion_api/tests/test_api.py
View file @
72aeb2c8
...
...
@@ -2107,7 +2107,8 @@ class UpdateThreadTest(
@ddt.data
(
*
itertools
.
product
([
True
,
False
],
[
True
,
False
]))
@ddt.unpack
def
test_voted
(
self
,
current_vote_status
,
new_vote_status
):
@mock.patch
(
"eventtracking.tracker.emit"
)
def
test_voted
(
self
,
current_vote_status
,
new_vote_status
,
mock_emit
):
"""
Test attempts to edit the "voted" field.
...
...
@@ -2144,6 +2145,22 @@ class UpdateThreadTest(
expected_request_data
[
"value"
]
=
[
"up"
]
self
.
assertEqual
(
actual_request_data
,
expected_request_data
)
event_name
,
event_data
=
mock_emit
.
call_args
[
0
]
self
.
assertEqual
(
event_name
,
"edx.forum.thread.voted"
)
self
.
assertEqual
(
event_data
,
{
'undo_vote'
:
not
new_vote_status
,
'url'
:
''
,
'target_username'
:
self
.
user
.
username
,
'vote_value'
:
'up'
,
'user_forums_roles'
:
[
FORUM_ROLE_STUDENT
],
'user_course_roles'
:
[],
'commentable_id'
:
'original_topic'
,
'id'
:
'test_thread'
}
)
@ddt.data
(
*
itertools
.
product
([
True
,
False
],
[
True
,
False
],
[
True
,
False
]))
@ddt.unpack
def
test_vote_count
(
self
,
current_vote_status
,
first_vote
,
second_vote
):
...
...
@@ -2499,7 +2516,8 @@ class UpdateCommentTest(
@ddt.data
(
*
itertools
.
product
([
True
,
False
],
[
True
,
False
]))
@ddt.unpack
def
test_voted
(
self
,
current_vote_status
,
new_vote_status
):
@mock.patch
(
"eventtracking.tracker.emit"
)
def
test_voted
(
self
,
current_vote_status
,
new_vote_status
,
mock_emit
):
"""
Test attempts to edit the "voted" field.
...
...
@@ -2539,6 +2557,23 @@ class UpdateCommentTest(
expected_request_data
[
"value"
]
=
[
"up"
]
self
.
assertEqual
(
actual_request_data
,
expected_request_data
)
event_name
,
event_data
=
mock_emit
.
call_args
[
0
]
self
.
assertEqual
(
event_name
,
"edx.forum.response.voted"
)
self
.
assertEqual
(
event_data
,
{
'undo_vote'
:
not
new_vote_status
,
'url'
:
''
,
'target_username'
:
self
.
user
.
username
,
'vote_value'
:
'up'
,
'user_forums_roles'
:
[
FORUM_ROLE_STUDENT
],
'user_course_roles'
:
[],
'commentable_id'
:
'dummy'
,
'id'
:
'test_comment'
}
)
@ddt.data
(
*
itertools
.
product
([
True
,
False
],
[
True
,
False
],
[
True
,
False
]))
@ddt.unpack
def
test_vote_count
(
self
,
current_vote_status
,
first_vote
,
second_vote
):
...
...
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