Add thread list endpoint to the new discussion API
This is an initial implementation that only allows retrieval of all threads for a course and only returns an easily computed subset of the fields that are needed, in order to keep this change from getting too large. JIRA: MA-641
This commit is contained in:
30
lms/djangoapps/discussion_api/tests/utils.py
Normal file
30
lms/djangoapps/discussion_api/tests/utils.py
Normal file
@@ -0,0 +1,30 @@
|
||||
"""
|
||||
Discussion API test utilities
|
||||
"""
|
||||
import json
|
||||
|
||||
import httpretty
|
||||
|
||||
|
||||
class CommentsServiceMockMixin(object):
|
||||
"""Mixin with utility methods for mocking the comments service"""
|
||||
def register_get_threads_response(self, threads, page, num_pages):
|
||||
"""Register a mock response for GET on the CS thread list endpoint"""
|
||||
httpretty.register_uri(
|
||||
httpretty.GET,
|
||||
"http://localhost:4567/api/v1/threads",
|
||||
body=json.dumps({
|
||||
"collection": threads,
|
||||
"page": page,
|
||||
"num_pages": num_pages,
|
||||
}),
|
||||
status=200
|
||||
)
|
||||
|
||||
def assert_last_query_params(self, expected_params):
|
||||
"""
|
||||
Assert that the last mock request had the expected query parameters
|
||||
"""
|
||||
actual_params = dict(httpretty.last_request().querystring)
|
||||
actual_params.pop("request_id") # request_id is random
|
||||
self.assertEqual(actual_params, expected_params)
|
||||
Reference in New Issue
Block a user