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
ec1b056d
Commit
ec1b056d
authored
Mar 26, 2014
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use requests library utility method for getting json results
parent
cb93b665
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
168 additions
and
129 deletions
+168
-129
lms/djangoapps/django_comment_client/base/tests.py
+157
-110
lms/djangoapps/django_comment_client/forum/tests.py
+10
-18
lms/lib/comment_client/utils.py
+1
-1
No files found.
lms/djangoapps/django_comment_client/base/tests.py
View file @
ec1b056d
...
...
@@ -23,9 +23,16 @@ log = logging.getLogger(__name__)
CS_PREFIX
=
"http://localhost:4567/api/v1"
class
MockRequestSetupMixin
(
object
):
def
_set_mock_request_data
(
self
,
mock_request
,
data
):
mock_request
.
return_value
.
text
=
json
.
dumps
(
data
)
mock_request
.
return_value
.
json
.
return_value
=
data
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_MODULESTORE
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
)
class
ViewsTestCase
(
UrlResetMixin
,
ModuleStoreTestCase
):
class
ViewsTestCase
(
UrlResetMixin
,
ModuleStoreTestCase
,
MockRequestSetupMixin
):
@patch.dict
(
"django.conf.settings.FEATURES"
,
{
"ENABLE_DISCUSSION_SERVICE"
:
True
})
def
setUp
(
self
):
...
...
@@ -63,26 +70,35 @@ class ViewsTestCase(UrlResetMixin, ModuleStoreTestCase):
def
test_create_thread
(
self
,
mock_request
):
mock_request
.
return_value
.
status_code
=
200
mock_request
.
return_value
.
text
=
u'{"title":"Hello",
\
"body":"this is a post",
\
"course_id":"MITx/999/Robot_Super_Course",
\
"anonymous":false,
\
"anonymous_to_peers":false,
\
"commentable_id":"i4x-MITx-999-course-Robot_Super_Course",
\
"created_at":"2013-05-10T18:53:43Z",
\
"updated_at":"2013-05-10T18:53:43Z",
\
"at_position_list":[],
\
"closed":false,
\
"id":"518d4237b023791dca00000d",
\
"user_id":"1","username":"robot",
\
"votes":{"count":0,"up_count":0,
\
"down_count":0,"point":0},
\
"abuse_flaggers":[],
\
"type":"thread","group_id":null,
\
"pinned":false,
\
"endorsed":false,
\
"unread_comments_count":0,
\
"read":false,"comments_count":0}'
self
.
_set_mock_request_data
(
mock_request
,
{
"title"
:
"Hello"
,
"body"
:
"this is a post"
,
"course_id"
:
"MITx/999/Robot_Super_Course"
,
"anonymous"
:
False
,
"anonymous_to_peers"
:
False
,
"commentable_id"
:
"i4x-MITx-999-course-Robot_Super_Course"
,
"created_at"
:
"2013-05-10T18:53:43Z"
,
"updated_at"
:
"2013-05-10T18:53:43Z"
,
"at_position_list"
:
[],
"closed"
:
False
,
"id"
:
"518d4237b023791dca00000d"
,
"user_id"
:
"1"
,
"username"
:
"robot"
,
"votes"
:
{
"count"
:
0
,
"up_count"
:
0
,
"down_count"
:
0
,
"point"
:
0
},
"abuse_flaggers"
:
[],
"type"
:
"thread"
,
"group_id"
:
None
,
"pinned"
:
False
,
"endorsed"
:
False
,
"unread_comments_count"
:
0
,
"read"
:
False
,
"comments_count"
:
0
,
})
thread
=
{
"body"
:
[
"this is a post"
],
"anonymous_to_peers"
:
[
"false"
],
"auto_subscribe"
:
[
"false"
],
...
...
@@ -110,7 +126,7 @@ class ViewsTestCase(UrlResetMixin, ModuleStoreTestCase):
assert_equal
(
response
.
status_code
,
200
)
def
test_delete_comment
(
self
,
mock_request
):
mock_request
.
return_value
.
text
=
json
.
dumps
(
{
self
.
_set_mock_request_data
(
mock_request
,
{
"user_id"
:
str
(
self
.
student
.
id
),
"closed"
:
False
,
})
...
...
@@ -138,7 +154,7 @@ class ViewsTestCase(UrlResetMixin, ModuleStoreTestCase):
}
if
include_depth
:
data
[
"depth"
]
=
0
mock_request
.
return_value
.
text
=
json
.
dumps
(
data
)
self
.
_set_mock_request_data
(
mock_request
,
data
)
def
_test_request_error
(
self
,
view_name
,
view_kwargs
,
data
,
mock_request
):
"""
...
...
@@ -290,26 +306,34 @@ class ViewsTestCase(UrlResetMixin, ModuleStoreTestCase):
def
test_flag_thread
(
self
,
mock_request
):
mock_request
.
return_value
.
status_code
=
200
mock_request
.
return_value
.
text
=
u'{"title":"Hello",
\
"body":"this is a post",
\
"course_id":"MITx/999/Robot_Super_Course",
\
"anonymous":false,
\
"anonymous_to_peers":false,
\
"commentable_id":"i4x-MITx-999-course-Robot_Super_Course",
\
"created_at":"2013-05-10T18:53:43Z",
\
"updated_at":"2013-05-10T18:53:43Z",
\
"at_position_list":[],
\
"closed":false,
\
"id":"518d4237b023791dca00000d",
\
"user_id":"1","username":"robot",
\
"votes":{"count":0,"up_count":0,
\
"down_count":0,"point":0},
\
"abuse_flaggers":[1],
\
"type":"thread","group_id":null,
\
"pinned":false,
\
"endorsed":false,
\
"unread_comments_count":0,
\
"read":false,"comments_count":0}'
self
.
_set_mock_request_data
(
mock_request
,
{
"title"
:
"Hello"
,
"body"
:
"this is a post"
,
"course_id"
:
"MITx/999/Robot_Super_Course"
,
"anonymous"
:
False
,
"anonymous_to_peers"
:
False
,
"commentable_id"
:
"i4x-MITx-999-course-Robot_Super_Course"
,
"created_at"
:
"2013-05-10T18:53:43Z"
,
"updated_at"
:
"2013-05-10T18:53:43Z"
,
"at_position_list"
:
[],
"closed"
:
False
,
"id"
:
"518d4237b023791dca00000d"
,
"user_id"
:
"1"
,
"username"
:
"robot"
,
"votes"
:
{
"count"
:
0
,
"up_count"
:
0
,
"down_count"
:
0
,
"point"
:
0
},
"abuse_flaggers"
:
[
1
],
"type"
:
"thread"
,
"group_id"
:
None
,
"pinned"
:
False
,
"endorsed"
:
False
,
"unread_comments_count"
:
0
,
"read"
:
False
,
"comments_count"
:
0
,
})
url
=
reverse
(
'flag_abuse_for_thread'
,
kwargs
=
{
'thread_id'
:
'518d4237b023791dca00000d'
,
'course_id'
:
self
.
course_id
})
response
=
self
.
client
.
post
(
url
)
assert_true
(
mock_request
.
called
)
...
...
@@ -350,26 +374,35 @@ class ViewsTestCase(UrlResetMixin, ModuleStoreTestCase):
def
test_un_flag_thread
(
self
,
mock_request
):
mock_request
.
return_value
.
status_code
=
200
mock_request
.
return_value
.
text
=
u'{"title":"Hello",
\
"body":"this is a post",
\
"course_id":"MITx/999/Robot_Super_Course",
\
"anonymous":false,
\
"anonymous_to_peers":false,
\
"commentable_id":"i4x-MITx-999-course-Robot_Super_Course",
\
"created_at":"2013-05-10T18:53:43Z",
\
"updated_at":"2013-05-10T18:53:43Z",
\
"at_position_list":[],
\
"closed":false,
\
"id":"518d4237b023791dca00000d",
\
"user_id":"1","username":"robot",
\
"votes":{"count":0,"up_count":0,
\
"down_count":0,"point":0},
\
"abuse_flaggers":[],
\
"type":"thread","group_id":null,
\
"pinned":false,
\
"endorsed":false,
\
"unread_comments_count":0,
\
"read":false,"comments_count":0}'
self
.
_set_mock_request_data
(
mock_request
,
{
"title"
:
"Hello"
,
"body"
:
"this is a post"
,
"course_id"
:
"MITx/999/Robot_Super_Course"
,
"anonymous"
:
False
,
"anonymous_to_peers"
:
False
,
"commentable_id"
:
"i4x-MITx-999-course-Robot_Super_Course"
,
"created_at"
:
"2013-05-10T18:53:43Z"
,
"updated_at"
:
"2013-05-10T18:53:43Z"
,
"at_position_list"
:
[],
"closed"
:
False
,
"id"
:
"518d4237b023791dca00000d"
,
"user_id"
:
"1"
,
"username"
:
"robot"
,
"votes"
:
{
"count"
:
0
,
"up_count"
:
0
,
"down_count"
:
0
,
"point"
:
0
},
"abuse_flaggers"
:
[],
"type"
:
"thread"
,
"group_id"
:
None
,
"pinned"
:
False
,
"endorsed"
:
False
,
"unread_comments_count"
:
0
,
"read"
:
False
,
"comments_count"
:
0
})
url
=
reverse
(
'un_flag_abuse_for_thread'
,
kwargs
=
{
'thread_id'
:
'518d4237b023791dca00000d'
,
'course_id'
:
self
.
course_id
})
response
=
self
.
client
.
post
(
url
)
assert_true
(
mock_request
.
called
)
...
...
@@ -410,22 +443,29 @@ class ViewsTestCase(UrlResetMixin, ModuleStoreTestCase):
def
test_flag_comment
(
self
,
mock_request
):
mock_request
.
return_value
.
status_code
=
200
mock_request
.
return_value
.
text
=
u'{"body":"this is a comment",
\
"course_id":"MITx/999/Robot_Super_Course",
\
"anonymous":false,
\
"anonymous_to_peers":false,
\
"commentable_id":"i4x-MITx-999-course-Robot_Super_Course",
\
"created_at":"2013-05-10T18:53:43Z",
\
"updated_at":"2013-05-10T18:53:43Z",
\
"at_position_list":[],
\
"closed":false,
\
"id":"518d4237b023791dca00000d",
\
"user_id":"1","username":"robot",
\
"votes":{"count":0,"up_count":0,
\
"down_count":0,"point":0},
\
"abuse_flaggers":[1],
\
"type":"comment",
\
"endorsed":false}'
self
.
_set_mock_request_data
(
mock_request
,
{
"body"
:
"this is a comment"
,
"course_id"
:
"MITx/999/Robot_Super_Course"
,
"anonymous"
:
False
,
"anonymous_to_peers"
:
False
,
"commentable_id"
:
"i4x-MITx-999-course-Robot_Super_Course"
,
"created_at"
:
"2013-05-10T18:53:43Z"
,
"updated_at"
:
"2013-05-10T18:53:43Z"
,
"at_position_list"
:
[],
"closed"
:
False
,
"id"
:
"518d4237b023791dca00000d"
,
"user_id"
:
"1"
,
"username"
:
"robot"
,
"votes"
:
{
"count"
:
0
,
"up_count"
:
0
,
"down_count"
:
0
,
"point"
:
0
},
"abuse_flaggers"
:
[
1
],
"type"
:
"comment"
,
"endorsed"
:
False
})
url
=
reverse
(
'flag_abuse_for_comment'
,
kwargs
=
{
'comment_id'
:
'518d4237b023791dca00000d'
,
'course_id'
:
self
.
course_id
})
response
=
self
.
client
.
post
(
url
)
assert_true
(
mock_request
.
called
)
...
...
@@ -466,22 +506,29 @@ class ViewsTestCase(UrlResetMixin, ModuleStoreTestCase):
def
test_un_flag_comment
(
self
,
mock_request
):
mock_request
.
return_value
.
status_code
=
200
mock_request
.
return_value
.
text
=
u'{"body":"this is a comment",
\
"course_id":"MITx/999/Robot_Super_Course",
\
"anonymous":false,
\
"anonymous_to_peers":false,
\
"commentable_id":"i4x-MITx-999-course-Robot_Super_Course",
\
"created_at":"2013-05-10T18:53:43Z",
\
"updated_at":"2013-05-10T18:53:43Z",
\
"at_position_list":[],
\
"closed":false,
\
"id":"518d4237b023791dca00000d",
\
"user_id":"1","username":"robot",
\
"votes":{"count":0,"up_count":0,
\
"down_count":0,"point":0},
\
"abuse_flaggers":[],
\
"type":"comment",
\
"endorsed":false}'
self
.
_set_mock_request_data
(
mock_request
,
{
"body"
:
"this is a comment"
,
"course_id"
:
"MITx/999/Robot_Super_Course"
,
"anonymous"
:
False
,
"anonymous_to_peers"
:
False
,
"commentable_id"
:
"i4x-MITx-999-course-Robot_Super_Course"
,
"created_at"
:
"2013-05-10T18:53:43Z"
,
"updated_at"
:
"2013-05-10T18:53:43Z"
,
"at_position_list"
:
[],
"closed"
:
False
,
"id"
:
"518d4237b023791dca00000d"
,
"user_id"
:
"1"
,
"username"
:
"robot"
,
"votes"
:
{
"count"
:
0
,
"up_count"
:
0
,
"down_count"
:
0
,
"point"
:
0
},
"abuse_flaggers"
:
[],
"type"
:
"comment"
,
"endorsed"
:
False
})
url
=
reverse
(
'un_flag_abuse_for_comment'
,
kwargs
=
{
'comment_id'
:
'518d4237b023791dca00000d'
,
'course_id'
:
self
.
course_id
})
response
=
self
.
client
.
post
(
url
)
assert_true
(
mock_request
.
called
)
...
...
@@ -522,7 +569,7 @@ class ViewsTestCase(UrlResetMixin, ModuleStoreTestCase):
@patch
(
"lms.lib.comment_client.utils.requests.request"
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_MODULESTORE
)
class
ViewPermissionsTestCase
(
UrlResetMixin
,
ModuleStoreTestCase
):
class
ViewPermissionsTestCase
(
UrlResetMixin
,
ModuleStoreTestCase
,
MockRequestSetupMixin
):
@patch.dict
(
"django.conf.settings.FEATURES"
,
{
"ENABLE_DISCUSSION_SERVICE"
:
True
})
def
setUp
(
self
):
super
(
ViewPermissionsTestCase
,
self
)
.
setUp
()
...
...
@@ -536,7 +583,7 @@ class ViewPermissionsTestCase(UrlResetMixin, ModuleStoreTestCase):
self
.
moderator
.
roles
.
add
(
Role
.
objects
.
get
(
name
=
"Moderator"
,
course_id
=
self
.
course
.
id
))
def
test_pin_thread_as_student
(
self
,
mock_request
):
mock_request
.
return_value
.
text
=
"{}"
self
.
_set_mock_request_data
(
mock_request
,
{})
self
.
client
.
login
(
username
=
self
.
student
.
username
,
password
=
self
.
password
)
response
=
self
.
client
.
post
(
reverse
(
"pin_thread"
,
kwargs
=
{
"course_id"
:
self
.
course
.
id
,
"thread_id"
:
"dummy"
})
...
...
@@ -544,7 +591,7 @@ class ViewPermissionsTestCase(UrlResetMixin, ModuleStoreTestCase):
self
.
assertEqual
(
response
.
status_code
,
401
)
def
test_pin_thread_as_moderator
(
self
,
mock_request
):
mock_request
.
return_value
.
text
=
"{}"
self
.
_set_mock_request_data
(
mock_request
,
{})
self
.
client
.
login
(
username
=
self
.
moderator
.
username
,
password
=
self
.
password
)
response
=
self
.
client
.
post
(
reverse
(
"pin_thread"
,
kwargs
=
{
"course_id"
:
self
.
course
.
id
,
"thread_id"
:
"dummy"
})
...
...
@@ -552,7 +599,7 @@ class ViewPermissionsTestCase(UrlResetMixin, ModuleStoreTestCase):
self
.
assertEqual
(
response
.
status_code
,
200
)
def
test_un_pin_thread_as_student
(
self
,
mock_request
):
mock_request
.
return_value
.
text
=
"{}"
self
.
_set_mock_request_data
(
mock_request
,
{})
self
.
client
.
login
(
username
=
self
.
student
.
username
,
password
=
self
.
password
)
response
=
self
.
client
.
post
(
reverse
(
"un_pin_thread"
,
kwargs
=
{
"course_id"
:
self
.
course
.
id
,
"thread_id"
:
"dummy"
})
...
...
@@ -560,7 +607,7 @@ class ViewPermissionsTestCase(UrlResetMixin, ModuleStoreTestCase):
self
.
assertEqual
(
response
.
status_code
,
401
)
def
test_un_pin_thread_as_moderator
(
self
,
mock_request
):
mock_request
.
return_value
.
text
=
"{}"
self
.
_set_mock_request_data
(
mock_request
,
{})
self
.
client
.
login
(
username
=
self
.
moderator
.
username
,
password
=
self
.
password
)
response
=
self
.
client
.
post
(
reverse
(
"un_pin_thread"
,
kwargs
=
{
"course_id"
:
self
.
course
.
id
,
"thread_id"
:
"dummy"
})
...
...
@@ -569,7 +616,7 @@ class ViewPermissionsTestCase(UrlResetMixin, ModuleStoreTestCase):
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_MODULESTORE
)
class
CreateThreadUnicodeTestCase
(
ModuleStoreTestCase
,
UnicodeTestMixin
):
class
CreateThreadUnicodeTestCase
(
ModuleStoreTestCase
,
UnicodeTestMixin
,
MockRequestSetupMixin
):
def
setUp
(
self
):
self
.
course
=
CourseFactory
.
create
()
seed_permissions_roles
(
self
.
course
.
id
)
...
...
@@ -578,7 +625,7 @@ class CreateThreadUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin):
@patch
(
'lms.lib.comment_client.utils.requests.request'
)
def
_test_unicode_data
(
self
,
text
,
mock_request
):
mock_request
.
return_value
.
text
=
"{}"
self
.
_set_mock_request_data
(
mock_request
,
{})
request
=
RequestFactory
()
.
post
(
"dummy_url"
,
{
"body"
:
text
,
"title"
:
text
})
request
.
user
=
self
.
student
request
.
view_name
=
"create_thread"
...
...
@@ -591,7 +638,7 @@ class CreateThreadUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin):
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_MODULESTORE
)
class
UpdateThreadUnicodeTestCase
(
ModuleStoreTestCase
,
UnicodeTestMixin
):
class
UpdateThreadUnicodeTestCase
(
ModuleStoreTestCase
,
UnicodeTestMixin
,
MockRequestSetupMixin
):
def
setUp
(
self
):
self
.
course
=
CourseFactory
.
create
()
seed_permissions_roles
(
self
.
course
.
id
)
...
...
@@ -600,7 +647,7 @@ class UpdateThreadUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin):
@patch
(
'lms.lib.comment_client.utils.requests.request'
)
def
_test_unicode_data
(
self
,
text
,
mock_request
):
mock_request
.
return_value
.
text
=
json
.
dumps
(
{
self
.
_set_mock_request_data
(
mock_request
,
{
"user_id"
:
str
(
self
.
student
.
id
),
"closed"
:
False
,
})
...
...
@@ -616,7 +663,7 @@ class UpdateThreadUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin):
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_MODULESTORE
)
class
CreateCommentUnicodeTestCase
(
ModuleStoreTestCase
,
UnicodeTestMixin
):
class
CreateCommentUnicodeTestCase
(
ModuleStoreTestCase
,
UnicodeTestMixin
,
MockRequestSetupMixin
):
def
setUp
(
self
):
self
.
course
=
CourseFactory
.
create
()
seed_permissions_roles
(
self
.
course
.
id
)
...
...
@@ -625,7 +672,7 @@ class CreateCommentUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin):
@patch
(
'lms.lib.comment_client.utils.requests.request'
)
def
_test_unicode_data
(
self
,
text
,
mock_request
):
mock_request
.
return_value
.
text
=
json
.
dumps
(
{
self
.
_set_mock_request_data
(
mock_request
,
{
"closed"
:
False
,
})
request
=
RequestFactory
()
.
post
(
"dummy_url"
,
{
"body"
:
text
})
...
...
@@ -639,7 +686,7 @@ class CreateCommentUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin):
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_MODULESTORE
)
class
UpdateCommentUnicodeTestCase
(
ModuleStoreTestCase
,
UnicodeTestMixin
):
class
UpdateCommentUnicodeTestCase
(
ModuleStoreTestCase
,
UnicodeTestMixin
,
MockRequestSetupMixin
):
def
setUp
(
self
):
self
.
course
=
CourseFactory
.
create
()
seed_permissions_roles
(
self
.
course
.
id
)
...
...
@@ -648,7 +695,7 @@ class UpdateCommentUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin):
@patch
(
'lms.lib.comment_client.utils.requests.request'
)
def
_test_unicode_data
(
self
,
text
,
mock_request
):
mock_request
.
return_value
.
text
=
json
.
dumps
(
{
self
.
_set_mock_request_data
(
mock_request
,
{
"user_id"
:
str
(
self
.
student
.
id
),
"closed"
:
False
,
})
...
...
@@ -663,7 +710,7 @@ class UpdateCommentUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin):
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_MODULESTORE
)
class
CreateSubCommentUnicodeTestCase
(
ModuleStoreTestCase
,
UnicodeTestMixin
):
class
CreateSubCommentUnicodeTestCase
(
ModuleStoreTestCase
,
UnicodeTestMixin
,
MockRequestSetupMixin
):
def
setUp
(
self
):
self
.
course
=
CourseFactory
.
create
()
seed_permissions_roles
(
self
.
course
.
id
)
...
...
@@ -672,7 +719,7 @@ class CreateSubCommentUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin):
@patch
(
'lms.lib.comment_client.utils.requests.request'
)
def
_test_unicode_data
(
self
,
text
,
mock_request
):
mock_request
.
return_value
.
text
=
json
.
dumps
(
{
self
.
_set_mock_request_data
(
mock_request
,
{
"closed"
:
False
,
"depth"
:
1
,
})
...
...
lms/djangoapps/django_comment_client/forum/tests.py
View file @
ec1b056d
...
...
@@ -109,26 +109,18 @@ def make_mock_request_impl(text, thread_id=None):
def
mock_request_impl
(
*
args
,
**
kwargs
):
url
=
args
[
1
]
if
url
.
endswith
(
"threads"
):
return
Mock
(
status_code
=
200
,
text
=
json
.
dumps
({
"collection"
:
[
make_mock_thread_data
(
text
,
"dummy_thread_id"
,
False
)]
})
)
data
=
{
"collection"
:
[
make_mock_thread_data
(
text
,
"dummy_thread_id"
,
False
)]
}
elif
thread_id
and
url
.
endswith
(
thread_id
):
return
Mock
(
status_code
=
200
,
text
=
json
.
dumps
(
make_mock_thread_data
(
text
,
thread_id
,
True
))
)
data
=
make_mock_thread_data
(
text
,
thread_id
,
True
)
else
:
# user query
return
Mock
(
status_code
=
200
,
text
=
json
.
dumps
({
"upvoted_ids"
:
[],
"downvoted_ids"
:
[],
"subscribed_thread_ids"
:
[],
})
)
data
=
{
"upvoted_ids"
:
[],
"downvoted_ids"
:
[],
"subscribed_thread_ids"
:
[],
}
return
Mock
(
status_code
=
200
,
text
=
json
.
dumps
(
data
),
json
=
Mock
(
return_value
=
data
))
return
mock_request_impl
...
...
lms/lib/comment_client/utils.py
View file @
ec1b056d
...
...
@@ -87,7 +87,7 @@ def perform_request(method, url, data_or_params=None, raw=False):
if
raw
:
return
response
.
text
else
:
return
json
.
loads
(
response
.
text
)
return
response
.
json
(
)
class
CommentClientError
(
Exception
):
...
...
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