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:
Greg Price
2015-04-29 17:00:55 -04:00
parent 73bbb89297
commit 90f28dce31
12 changed files with 756 additions and 18 deletions

View 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)