This upgrades XBlock, which now contains a default index_dictionary method.
This commit is contained in:
@@ -178,8 +178,7 @@ class SearchIndexerBase(object, metaclass=ABCMeta):
|
||||
Returns:
|
||||
item_content_groups - content groups assigned to indexed item
|
||||
"""
|
||||
is_indexable = hasattr(item, "index_dictionary")
|
||||
item_index_dictionary = item.index_dictionary() if is_indexable else None
|
||||
item_index_dictionary = item.index_dictionary()
|
||||
# if it's not indexable and it does not have children, then ignore
|
||||
if not item_index_dictionary and not item.has_children:
|
||||
return
|
||||
|
||||
@@ -56,9 +56,6 @@ from xmodule.tests import DATA_DIR
|
||||
from xmodule.x_module import XModuleMixin
|
||||
|
||||
|
||||
class NonIndexableXBlock(XBlock):
|
||||
"""XBlock for testing indexibility"""
|
||||
|
||||
COURSE_CHILD_STRUCTURE = {
|
||||
"course": "chapter",
|
||||
"chapter": "sequential",
|
||||
@@ -353,33 +350,6 @@ class TestCoursewareSearchIndexer(MixedWithOptionsTestCase):
|
||||
response = self.search()
|
||||
self.assertEqual(response["total"], 3)
|
||||
|
||||
@XBlock.register_temp_plugin(NonIndexableXBlock)
|
||||
def _test_not_indexable(self, store):
|
||||
""" test not indexable items """
|
||||
# Publish the vertical to start with
|
||||
self.publish_item(store, self.vertical.location)
|
||||
self.reindex_course(store)
|
||||
response = self.search()
|
||||
self.assertEqual(response["total"], 4)
|
||||
|
||||
# Add a non-indexable item
|
||||
ItemFactory.create(
|
||||
parent_location=self.vertical.location,
|
||||
category="nonindexablexblock",
|
||||
display_name="Some other content",
|
||||
publish_item=False,
|
||||
modulestore=store,
|
||||
)
|
||||
self.reindex_course(store)
|
||||
response = self.search()
|
||||
self.assertEqual(response["total"], 4)
|
||||
|
||||
# even after publishing, we should not find the non-indexable item
|
||||
self.publish_item(store, self.vertical.location)
|
||||
self.reindex_course(store)
|
||||
response = self.search()
|
||||
self.assertEqual(response["total"], 4)
|
||||
|
||||
def _test_start_date_propagation(self, store):
|
||||
""" make sure that the start date is applied at the right level """
|
||||
early_date = self.course.start
|
||||
@@ -566,10 +536,6 @@ class TestCoursewareSearchIndexer(MixedWithOptionsTestCase):
|
||||
def test_deleting_item(self, store_type):
|
||||
self._perform_test_using_store(store_type, self._test_deleting_item)
|
||||
|
||||
@ddt.data(*WORKS_WITH_STORES)
|
||||
def test_not_indexable(self, store_type):
|
||||
self._perform_test_using_store(store_type, self._test_not_indexable)
|
||||
|
||||
@ddt.data(*WORKS_WITH_STORES)
|
||||
def test_start_date_propagation(self, store_type):
|
||||
self._perform_test_using_store(store_type, self._test_start_date_propagation)
|
||||
@@ -903,25 +869,6 @@ class TestLibrarySearchIndexer(MixedWithOptionsTestCase):
|
||||
response = self.search()
|
||||
self.assertEqual(response["total"], 1)
|
||||
|
||||
@XBlock.register_temp_plugin(NonIndexableXBlock)
|
||||
def _test_not_indexable(self, store):
|
||||
""" test not indexable items """
|
||||
self.reindex_library(store)
|
||||
response = self.search()
|
||||
self.assertEqual(response["total"], 2)
|
||||
|
||||
# Add a non-indexable item
|
||||
ItemFactory.create(
|
||||
parent_location=self.library.location,
|
||||
category="nonindexablexblock",
|
||||
display_name="Assessment",
|
||||
publish_item=False,
|
||||
modulestore=store,
|
||||
)
|
||||
self.reindex_library(store)
|
||||
response = self.search()
|
||||
self.assertEqual(response["total"], 2)
|
||||
|
||||
@patch('django.conf.settings.SEARCH_ENGINE', None)
|
||||
def _test_search_disabled(self, store):
|
||||
""" if search setting has it as off, confirm that nothing is indexed """
|
||||
@@ -950,10 +897,6 @@ class TestLibrarySearchIndexer(MixedWithOptionsTestCase):
|
||||
def test_deleting_item(self, store_type):
|
||||
self._perform_test_using_store(store_type, self._test_deleting_item)
|
||||
|
||||
@ddt.data(*WORKS_WITH_STORES)
|
||||
def test_not_indexable(self, store_type):
|
||||
self._perform_test_using_store(store_type, self._test_not_indexable)
|
||||
|
||||
@ddt.data(*WORKS_WITH_STORES)
|
||||
def test_search_disabled(self, store_type):
|
||||
self._perform_test_using_store(store_type, self._test_search_disabled)
|
||||
|
||||
Reference in New Issue
Block a user