当前位置: 首页>>代码示例>>Python>>正文


Python CoursewareSearchIndexer.do_course_reindex方法代码示例

本文整理汇总了Python中contentstore.courseware_index.CoursewareSearchIndexer.do_course_reindex方法的典型用法代码示例。如果您正苦于以下问题:Python CoursewareSearchIndexer.do_course_reindex方法的具体用法?Python CoursewareSearchIndexer.do_course_reindex怎么用?Python CoursewareSearchIndexer.do_course_reindex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在contentstore.courseware_index.CoursewareSearchIndexer的用法示例。


在下文中一共展示了CoursewareSearchIndexer.do_course_reindex方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _do_test_large_course_deletion

# 需要导入模块: from contentstore.courseware_index import CoursewareSearchIndexer [as 别名]
# 或者: from contentstore.courseware_index.CoursewareSearchIndexer import do_course_reindex [as 别名]
    def _do_test_large_course_deletion(self, store, load_factor):
        """ Test that deleting items from a course works even when present within a very large course """
        def id_list(top_parent_object):
            """ private function to get ids from object down the tree """
            list_of_ids = [unicode(top_parent_object.location)]
            for child in top_parent_object.get_children():
                list_of_ids.extend(id_list(child))
            return list_of_ids

        course, course_size = create_large_course(store, load_factor)
        self.course_id = unicode(course.id)

        # index full course
        CoursewareSearchIndexer.do_course_reindex(store, course.id)

        self.assert_search_count(course_size)

        # reload course to allow us to delete one single unit
        course = store.get_course(course.id, depth=1)

        # delete the first chapter
        chapter_to_delete = course.get_children()[0]
        self.delete_item(store, chapter_to_delete.location)

        # index and check correctness
        CoursewareSearchIndexer.do_course_reindex(store, course.id)
        deleted_count = 1 + load_factor + (load_factor ** 2) + (load_factor ** 3)
        self.assert_search_count(course_size - deleted_count)
开发者ID:HowestX,项目名称:edx-platform,代码行数:30,代码来源:test_courseware_index.py

示例2: test_indexing_responses

# 需要导入模块: from contentstore.courseware_index import CoursewareSearchIndexer [as 别名]
# 或者: from contentstore.courseware_index.CoursewareSearchIndexer import do_course_reindex [as 别名]
    def test_indexing_responses(self):
        """
        Test do_course_reindex response with real data
        """
        # results are indexed because they are published from ItemFactory
        response = perform_search(
            "unique",
            user=self.user,
            size=10,
            from_=0,
            course_id=unicode(self.course.id))
        self.assertEqual(response['total'], 1)

        # Start manual reindex
        CoursewareSearchIndexer.do_course_reindex(modulestore(),
                                                  self.course.id)

        # Check results are the same following reindex
        response = perform_search(
            "unique",
            user=self.user,
            size=10,
            from_=0,
            course_id=unicode(self.course.id))
        self.assertEqual(response['total'], 1)
开发者ID:moonshot,项目名称:edx-platform,代码行数:27,代码来源:test_course_index.py

示例3: test_indexing_no_item

# 需要导入模块: from contentstore.courseware_index import CoursewareSearchIndexer [as 别名]
# 或者: from contentstore.courseware_index.CoursewareSearchIndexer import do_course_reindex [as 别名]
    def test_indexing_no_item(self, mock_get_course):
        """
        Test system logs an error if no item found.
        """
        # set mocked exception response
        err = ItemNotFoundError
        mock_get_course.return_value = err

        # Start manual reindex and check error in response
        with self.assertRaises(SearchIndexingError):
            CoursewareSearchIndexer.do_course_reindex(modulestore(), self.course.id)
开发者ID:LeslieZhu,项目名称:edx-platform,代码行数:13,代码来源:test_course_index.py

示例4: handle

# 需要导入模块: from contentstore.courseware_index import CoursewareSearchIndexer [as 别名]
# 或者: from contentstore.courseware_index.CoursewareSearchIndexer import do_course_reindex [as 别名]
    def handle(self, *args, **options):
        """
        By convention set by Django developers, this method actually executes command's actions.
        So, there could be no better docstring than emphasize this once again.
        """
        course_ids = options['course_ids']
        all_option = options['all']
        setup_option = options['setup']
        index_all_courses_option = all_option or setup_option

        if (not len(course_ids) and not index_all_courses_option) or \
                (len(course_ids) and index_all_courses_option):
            raise CommandError("reindex_course requires one or more <course_id>s OR the --all or --setup flags.")

        store = modulestore()

        if index_all_courses_option:
            index_name = CoursewareSearchIndexer.INDEX_NAME
            doc_type = CoursewareSearchIndexer.DOCUMENT_TYPE
            if setup_option:
                try:
                    # try getting the ElasticSearch engine
                    searcher = SearchEngine.get_search_engine(index_name)
                except exceptions.ElasticsearchException as exc:
                    logging.exception(u'Search Engine error - %s', exc)
                    return

                index_exists = searcher._es.indices.exists(index=index_name)  # pylint: disable=protected-access
                doc_type_exists = searcher._es.indices.exists_type(  # pylint: disable=protected-access
                    index=index_name,
                    doc_type=doc_type
                )

                index_mapping = searcher._es.indices.get_mapping(  # pylint: disable=protected-access
                    index=index_name,
                    doc_type=doc_type
                ) if index_exists and doc_type_exists else {}

                if index_exists and index_mapping:
                    return

            # if reindexing is done during devstack setup step, don't prompt the user
            if setup_option or query_yes_no(self.CONFIRMATION_PROMPT, default="no"):
                # in case of --setup or --all, get the list of course keys from all courses
                # that are stored in the modulestore
                course_keys = [course.id for course in modulestore().get_courses()]
            else:
                return
        else:
            # in case course keys are provided as arguments
            course_keys = map(self._parse_course_key, course_ids)

        for course_key in course_keys:
            CoursewareSearchIndexer.do_course_reindex(store, course_key)
开发者ID:cpennington,项目名称:edx-platform,代码行数:56,代码来源:reindex_course.py

示例5: test_indexing_seq_error_responses

# 需要导入模块: from contentstore.courseware_index import CoursewareSearchIndexer [as 别名]
# 或者: from contentstore.courseware_index.CoursewareSearchIndexer import do_course_reindex [as 别名]
    def test_indexing_seq_error_responses(self, mock_index_dictionary):
        """
        Test do_course_reindex response with mocked error data for sequence
        """
        # results are indexed because they are published from ItemFactory
        response = perform_search("unique", user=self.user, size=10, from_=0, course_id=unicode(self.course.id))
        self.assertEqual(response["total"], 1)

        # set mocked exception response
        err = Exception
        mock_index_dictionary.return_value = err

        # Start manual reindex and check error in response
        with self.assertRaises(SearchIndexingError):
            CoursewareSearchIndexer.do_course_reindex(modulestore(), self.course.id)
开发者ID:fjardon,项目名称:edx-platform,代码行数:17,代码来源:test_course_index.py

示例6: reindex_course

# 需要导入模块: from contentstore.courseware_index import CoursewareSearchIndexer [as 别名]
# 或者: from contentstore.courseware_index.CoursewareSearchIndexer import do_course_reindex [as 别名]
 def reindex_course(self, store):
     """ kick off complete reindex of the course """
     return CoursewareSearchIndexer.do_course_reindex(store, self.course.id)
开发者ID:HowestX,项目名称:edx-platform,代码行数:5,代码来源:test_courseware_index.py


注:本文中的contentstore.courseware_index.CoursewareSearchIndexer.do_course_reindex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。