Commit eb7c5be0 by E. Kolpakov

Refactored tests to explicitly state with which modulestores they work

parent 4f6905ed
...@@ -25,12 +25,11 @@ from xmodule.x_module import XModuleMixin ...@@ -25,12 +25,11 @@ from xmodule.x_module import XModuleMixin
from search.search_engine_base import SearchEngine from search.search_engine_base import SearchEngine
from contentstore.courseware_index import ( from contentstore.courseware_index import CoursewareSearchIndexer, LibrarySearchIndexer, SearchIndexingError
CoursewareSearchIndexer, LibrarySearchIndexer, SearchIndexingError, get_indexer_for_location
)
from contentstore.signals import listen_for_course_publish from contentstore.signals import listen_for_course_publish
COURSE_CHILD_STRUCTURE = { COURSE_CHILD_STRUCTURE = {
"course": "chapter", "course": "chapter",
"chapter": "sequential", "chapter": "sequential",
...@@ -178,6 +177,8 @@ class MixedWithOptionsTestCase(MixedSplitTestCase): ...@@ -178,6 +177,8 @@ class MixedWithOptionsTestCase(MixedSplitTestCase):
class TestCoursewareSearchIndexer(MixedWithOptionsTestCase): class TestCoursewareSearchIndexer(MixedWithOptionsTestCase):
""" Tests the operation of the CoursewareSearchIndexer """ """ Tests the operation of the CoursewareSearchIndexer """
WORKS_WITH_STORES = (ModuleStoreEnum.Type.mongo, ModuleStoreEnum.Type.split)
def setUp(self): def setUp(self):
super(TestCoursewareSearchIndexer, self).setUp() super(TestCoursewareSearchIndexer, self).setUp()
...@@ -411,35 +412,35 @@ class TestCoursewareSearchIndexer(MixedWithOptionsTestCase): ...@@ -411,35 +412,35 @@ class TestCoursewareSearchIndexer(MixedWithOptionsTestCase):
with self.assertRaises(SearchIndexingError): with self.assertRaises(SearchIndexingError):
self.reindex_course(store) self.reindex_course(store)
@ddt.data(ModuleStoreEnum.Type.mongo, ModuleStoreEnum.Type.split) @ddt.data(*WORKS_WITH_STORES)
def test_indexing_course(self, store_type): def test_indexing_course(self, store_type):
self._perform_test_using_store(store_type, self._test_indexing_course) self._perform_test_using_store(store_type, self._test_indexing_course)
@ddt.data(ModuleStoreEnum.Type.mongo, ModuleStoreEnum.Type.split) @ddt.data(*WORKS_WITH_STORES)
def test_not_indexing_unpublished_content(self, store_type): def test_not_indexing_unpublished_content(self, store_type):
self._perform_test_using_store(store_type, self._test_not_indexing_unpublished_content) self._perform_test_using_store(store_type, self._test_not_indexing_unpublished_content)
@ddt.data(ModuleStoreEnum.Type.mongo, ModuleStoreEnum.Type.split) @ddt.data(*WORKS_WITH_STORES)
def test_deleting_item(self, store_type): def test_deleting_item(self, store_type):
self._perform_test_using_store(store_type, self._test_deleting_item) self._perform_test_using_store(store_type, self._test_deleting_item)
@ddt.data(ModuleStoreEnum.Type.mongo, ModuleStoreEnum.Type.split) @ddt.data(*WORKS_WITH_STORES)
def test_not_indexable(self, store_type): def test_not_indexable(self, store_type):
self._perform_test_using_store(store_type, self._test_not_indexable) self._perform_test_using_store(store_type, self._test_not_indexable)
@ddt.data(ModuleStoreEnum.Type.mongo, ModuleStoreEnum.Type.split) @ddt.data(*WORKS_WITH_STORES)
def test_start_date_propagation(self, store_type): def test_start_date_propagation(self, store_type):
self._perform_test_using_store(store_type, self._test_start_date_propagation) self._perform_test_using_store(store_type, self._test_start_date_propagation)
@ddt.data(ModuleStoreEnum.Type.mongo, ModuleStoreEnum.Type.split) @ddt.data(*WORKS_WITH_STORES)
def test_search_disabled(self, store_type): def test_search_disabled(self, store_type):
self._perform_test_using_store(store_type, self._test_search_disabled) self._perform_test_using_store(store_type, self._test_search_disabled)
@ddt.data(ModuleStoreEnum.Type.mongo, ModuleStoreEnum.Type.split) @ddt.data(*WORKS_WITH_STORES)
def test_time_based_index(self, store_type): def test_time_based_index(self, store_type):
self._perform_test_using_store(store_type, self._test_time_based_index) self._perform_test_using_store(store_type, self._test_time_based_index)
@ddt.data(ModuleStoreEnum.Type.mongo, ModuleStoreEnum.Type.split) @ddt.data(*WORKS_WITH_STORES)
def test_exception(self, store_type): def test_exception(self, store_type):
self._perform_test_using_store(store_type, self._test_exception) self._perform_test_using_store(store_type, self._test_exception)
...@@ -449,6 +450,8 @@ class TestCoursewareSearchIndexer(MixedWithOptionsTestCase): ...@@ -449,6 +450,8 @@ class TestCoursewareSearchIndexer(MixedWithOptionsTestCase):
class TestLargeCourseDeletions(MixedWithOptionsTestCase): class TestLargeCourseDeletions(MixedWithOptionsTestCase):
""" Tests to excerise deleting items from a course """ """ Tests to excerise deleting items from a course """
WORKS_WITH_STORES = (ModuleStoreEnum.Type.mongo, ModuleStoreEnum.Type.split)
def _clean_course_id(self): def _clean_course_id(self):
""" Clean all documents from the index that have a specific course provided """ """ Clean all documents from the index that have a specific course provided """
if self.course_id: if self.course_id:
...@@ -518,7 +521,7 @@ class TestLargeCourseDeletions(MixedWithOptionsTestCase): ...@@ -518,7 +521,7 @@ class TestLargeCourseDeletions(MixedWithOptionsTestCase):
@skip(("This test is to see how we handle very large courses, to ensure that the delete" @skip(("This test is to see how we handle very large courses, to ensure that the delete"
"procedure works smoothly - too long to run during the normal course of things")) "procedure works smoothly - too long to run during the normal course of things"))
@ddt.data(ModuleStoreEnum.Type.mongo, ModuleStoreEnum.Type.split) @ddt.data(*WORKS_WITH_STORES)
def test_large_course_deletion(self, store_type): def test_large_course_deletion(self, store_type):
self._perform_test_using_store(store_type, self._test_large_course_deletion) self._perform_test_using_store(store_type, self._test_large_course_deletion)
...@@ -583,6 +586,9 @@ class TestTaskExecution(ModuleStoreTestCase): ...@@ -583,6 +586,9 @@ class TestTaskExecution(ModuleStoreTestCase):
class TestLibrarySearchIndexer(MixedWithOptionsTestCase): class TestLibrarySearchIndexer(MixedWithOptionsTestCase):
""" Tests the operation of the CoursewareSearchIndexer """ """ Tests the operation of the CoursewareSearchIndexer """
# libraries work only with split, so do library indexer
WORKS_WITH_STORES = (ModuleStoreEnum.Type.split, )
def setUp(self): def setUp(self):
super(TestLibrarySearchIndexer, self).setUp() super(TestLibrarySearchIndexer, self).setUp()
...@@ -720,30 +726,30 @@ class TestLibrarySearchIndexer(MixedWithOptionsTestCase): ...@@ -720,30 +726,30 @@ class TestLibrarySearchIndexer(MixedWithOptionsTestCase):
with self.assertRaises(SearchIndexingError): with self.assertRaises(SearchIndexingError):
self.reindex_library(store) self.reindex_library(store)
@ddt.data(ModuleStoreEnum.Type.mongo, ModuleStoreEnum.Type.split) @ddt.data(*WORKS_WITH_STORES)
def test_indexing_library(self, store_type): def test_indexing_library(self, store_type):
self._perform_test_using_store(store_type, self._test_indexing_library) self._perform_test_using_store(store_type, self._test_indexing_library)
@ddt.data(ModuleStoreEnum.Type.mongo, ModuleStoreEnum.Type.split) @ddt.data(*WORKS_WITH_STORES)
def test_updating_item(self, store_type): def test_updating_item(self, store_type):
self._perform_test_using_store(store_type, self._test_updating_item) self._perform_test_using_store(store_type, self._test_updating_item)
@ddt.data(ModuleStoreEnum.Type.mongo, ModuleStoreEnum.Type.split) @ddt.data(*WORKS_WITH_STORES)
def test_creating_item(self, store_type): def test_creating_item(self, store_type):
self._perform_test_using_store(store_type, self._test_creating_item) self._perform_test_using_store(store_type, self._test_creating_item)
@ddt.data(ModuleStoreEnum.Type.mongo, ModuleStoreEnum.Type.split) @ddt.data(*WORKS_WITH_STORES)
def test_deleting_item(self, store_type): def test_deleting_item(self, store_type):
self._perform_test_using_store(store_type, self._test_deleting_item) self._perform_test_using_store(store_type, self._test_deleting_item)
@ddt.data(ModuleStoreEnum.Type.mongo, ModuleStoreEnum.Type.split) @ddt.data(*WORKS_WITH_STORES)
def test_not_indexable(self, store_type): def test_not_indexable(self, store_type):
self._perform_test_using_store(store_type, self._test_not_indexable) self._perform_test_using_store(store_type, self._test_not_indexable)
@ddt.data(ModuleStoreEnum.Type.mongo, ModuleStoreEnum.Type.split) @ddt.data(*WORKS_WITH_STORES)
def test_search_disabled(self, store_type): def test_search_disabled(self, store_type):
self._perform_test_using_store(store_type, self._test_search_disabled) self._perform_test_using_store(store_type, self._test_search_disabled)
@ddt.data(ModuleStoreEnum.Type.mongo, ModuleStoreEnum.Type.split) @ddt.data(*WORKS_WITH_STORES)
def test_exception(self, store_type): def test_exception(self, store_type):
self._perform_test_using_store(store_type, self._test_exception) self._perform_test_using_store(store_type, self._test_exception)
\ No newline at end of file
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