Commit e9378881 by David Ormsbee

Use SharedModuleStoreTestCase in Discussion API serializer tests.

parent 406c9bc5
...@@ -27,13 +27,19 @@ from lms.lib.comment_client.comment import Comment ...@@ -27,13 +27,19 @@ from lms.lib.comment_client.comment import Comment
from lms.lib.comment_client.thread import Thread from lms.lib.comment_client.thread import Thread
from student.tests.factories import UserFactory from student.tests.factories import UserFactory
from util.testing import UrlResetMixin from util.testing import UrlResetMixin
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory from xmodule.modulestore.tests.factories import CourseFactory
from openedx.core.djangoapps.course_groups.tests.helpers import CohortFactory from openedx.core.djangoapps.course_groups.tests.helpers import CohortFactory
@ddt.ddt @ddt.ddt
class SerializerTestMixin(CommentsServiceMockMixin, UrlResetMixin): class SerializerTestMixin(CommentsServiceMockMixin, UrlResetMixin):
@classmethod
@mock.patch.dict("django.conf.settings.FEATURES", {"ENABLE_DISCUSSION_SERVICE": True})
def setUpClass(cls):
super(SerializerTestMixin, cls).setUpClass()
cls.course = CourseFactory.create()
@mock.patch.dict("django.conf.settings.FEATURES", {"ENABLE_DISCUSSION_SERVICE": True}) @mock.patch.dict("django.conf.settings.FEATURES", {"ENABLE_DISCUSSION_SERVICE": True})
def setUp(self): def setUp(self):
super(SerializerTestMixin, self).setUp() super(SerializerTestMixin, self).setUp()
...@@ -45,7 +51,6 @@ class SerializerTestMixin(CommentsServiceMockMixin, UrlResetMixin): ...@@ -45,7 +51,6 @@ class SerializerTestMixin(CommentsServiceMockMixin, UrlResetMixin):
self.register_get_user_response(self.user) self.register_get_user_response(self.user)
self.request = RequestFactory().get("/dummy") self.request = RequestFactory().get("/dummy")
self.request.user = self.user self.request.user = self.user
self.course = CourseFactory.create()
self.author = UserFactory.create() self.author = UserFactory.create()
def create_role(self, role_name, users, course=None): def create_role(self, role_name, users, course=None):
...@@ -128,7 +133,7 @@ class SerializerTestMixin(CommentsServiceMockMixin, UrlResetMixin): ...@@ -128,7 +133,7 @@ class SerializerTestMixin(CommentsServiceMockMixin, UrlResetMixin):
@ddt.ddt @ddt.ddt
class ThreadSerializerSerializationTest(SerializerTestMixin, ModuleStoreTestCase): class ThreadSerializerSerializationTest(SerializerTestMixin, SharedModuleStoreTestCase):
"""Tests for ThreadSerializer serialization.""" """Tests for ThreadSerializer serialization."""
def make_cs_content(self, overrides): def make_cs_content(self, overrides):
""" """
...@@ -245,7 +250,7 @@ class ThreadSerializerSerializationTest(SerializerTestMixin, ModuleStoreTestCase ...@@ -245,7 +250,7 @@ class ThreadSerializerSerializationTest(SerializerTestMixin, ModuleStoreTestCase
@ddt.ddt @ddt.ddt
class CommentSerializerTest(SerializerTestMixin, ModuleStoreTestCase): class CommentSerializerTest(SerializerTestMixin, SharedModuleStoreTestCase):
"""Tests for CommentSerializer.""" """Tests for CommentSerializer."""
def setUp(self): def setUp(self):
super(CommentSerializerTest, self).setUp() super(CommentSerializerTest, self).setUp()
...@@ -402,15 +407,20 @@ class CommentSerializerTest(SerializerTestMixin, ModuleStoreTestCase): ...@@ -402,15 +407,20 @@ class CommentSerializerTest(SerializerTestMixin, ModuleStoreTestCase):
@ddt.ddt @ddt.ddt
class ThreadSerializerDeserializationTest(CommentsServiceMockMixin, UrlResetMixin, ModuleStoreTestCase): class ThreadSerializerDeserializationTest(CommentsServiceMockMixin, UrlResetMixin, SharedModuleStoreTestCase):
"""Tests for ThreadSerializer deserialization.""" """Tests for ThreadSerializer deserialization."""
@classmethod
@mock.patch.dict("django.conf.settings.FEATURES", {"ENABLE_DISCUSSION_SERVICE": True})
def setUpClass(cls):
super(ThreadSerializerDeserializationTest, cls).setUpClass()
cls.course = CourseFactory.create()
@mock.patch.dict("django.conf.settings.FEATURES", {"ENABLE_DISCUSSION_SERVICE": True}) @mock.patch.dict("django.conf.settings.FEATURES", {"ENABLE_DISCUSSION_SERVICE": True})
def setUp(self): def setUp(self):
super(ThreadSerializerDeserializationTest, self).setUp() super(ThreadSerializerDeserializationTest, self).setUp()
httpretty.reset() httpretty.reset()
httpretty.enable() httpretty.enable()
self.addCleanup(httpretty.disable) self.addCleanup(httpretty.disable)
self.course = CourseFactory.create()
self.user = UserFactory.create() self.user = UserFactory.create()
self.register_get_user_response(self.user) self.register_get_user_response(self.user)
self.request = RequestFactory().get("/dummy") self.request = RequestFactory().get("/dummy")
...@@ -592,14 +602,18 @@ class ThreadSerializerDeserializationTest(CommentsServiceMockMixin, UrlResetMixi ...@@ -592,14 +602,18 @@ class ThreadSerializerDeserializationTest(CommentsServiceMockMixin, UrlResetMixi
@ddt.ddt @ddt.ddt
class CommentSerializerDeserializationTest(CommentsServiceMockMixin, ModuleStoreTestCase): class CommentSerializerDeserializationTest(CommentsServiceMockMixin, SharedModuleStoreTestCase):
"""Tests for ThreadSerializer deserialization.""" """Tests for ThreadSerializer deserialization."""
@classmethod
def setUpClass(cls):
super(CommentSerializerDeserializationTest, cls).setUpClass()
cls.course = CourseFactory.create()
def setUp(self): def setUp(self):
super(CommentSerializerDeserializationTest, self).setUp() super(CommentSerializerDeserializationTest, self).setUp()
httpretty.reset() httpretty.reset()
httpretty.enable() httpretty.enable()
self.addCleanup(httpretty.disable) self.addCleanup(httpretty.disable)
self.course = CourseFactory.create()
self.user = UserFactory.create() self.user = UserFactory.create()
self.register_get_user_response(self.user) self.register_get_user_response(self.user)
self.request = RequestFactory().get("/dummy") self.request = RequestFactory().get("/dummy")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment