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


Python ErrorDescriptor.from_xml方法代码示例

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


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

示例1: test_error_module_xml_rendering

# 需要导入模块: from xmodule.error_module import ErrorDescriptor [as 别名]
# 或者: from xmodule.error_module.ErrorDescriptor import from_xml [as 别名]
 def test_error_module_xml_rendering(self):
     descriptor = ErrorDescriptor.from_xml(
         self.valid_xml, self.system, self.org, self.course, self.error_msg)
     self.assertIsInstance(descriptor, ErrorDescriptor)
     descriptor.xmodule_runtime = self.system
     context_repr = self.system.render(descriptor, 'student_view').content
     self.assertIn(self.error_msg, context_repr)
     self.assertIn(repr(self.valid_xml), context_repr)
开发者ID:DavidGrahamFL,项目名称:edx-platform,代码行数:10,代码来源:test_error_module.py

示例2: test_error_module_xml_rendering

# 需要导入模块: from xmodule.error_module import ErrorDescriptor [as 别名]
# 或者: from xmodule.error_module.ErrorDescriptor import from_xml [as 别名]
 def test_error_module_xml_rendering(self):
     descriptor = ErrorDescriptor.from_xml(
         self.valid_xml,
         self.system,
         CourseLocationManager(self.course_id),
         self.error_msg
     )
     self.assertIsInstance(descriptor, ErrorDescriptor)
     descriptor.xmodule_runtime = self.system
     context_repr = self.system.render(descriptor, STUDENT_VIEW).content
     self.assertIn(self.error_msg, context_repr)
     self.assertIn(repr(self.valid_xml), context_repr)
开发者ID:10clouds,项目名称:edx-platform,代码行数:14,代码来源:test_error_module.py

示例3: test_course_error

# 需要导入模块: from xmodule.error_module import ErrorDescriptor [as 别名]
# 或者: from xmodule.error_module.ErrorDescriptor import from_xml [as 别名]
    def test_course_error(self):
        """
        Ensure the view still returns results even if get_courses() returns an ErrorDescriptor. The ErrorDescriptor
        should be filtered out.
        """

        error_descriptor = ErrorDescriptor.from_xml(
            '<course></course>',
            get_test_system(),
            CourseLocationManager(CourseLocator(org='org', course='course', run='run')),
            None
        )

        descriptors = [error_descriptor, self.empty_course, self.course]

        with patch('xmodule.modulestore.mixed.MixedModuleStore.get_courses', Mock(return_value=descriptors)):
            self.test_get()
开发者ID:CraftAcademy,项目名称:edx-platform,代码行数:19,代码来源:tests.py

示例4: test_has_staff_access_to_preview_mode

# 需要导入模块: from xmodule.error_module import ErrorDescriptor [as 别名]
# 或者: from xmodule.error_module.ErrorDescriptor import from_xml [as 别名]
    def test_has_staff_access_to_preview_mode(self):
        """
        Tests users have right access to content in preview mode.
        """
        course_key = self.course.id
        usage_key = self.course.scope_ids.usage_id
        chapter = ItemFactory.create(category="chapter", parent_location=self.course.location)
        overview = CourseOverview.get_from_id(course_key)
        test_system = get_test_system()

        ccx = CcxFactory(course_id=course_key)
        ccx_locator = CCXLocator.from_course_locator(course_key, ccx.id)

        error_descriptor = ErrorDescriptor.from_xml(
            u"<problem>ABC \N{SNOWMAN}</problem>",
            test_system,
            CourseLocationManager(course_key),
            "error msg"
        )
        # Enroll student to the course
        CourseEnrollmentFactory(user=self.student, course_id=self.course.id)

        modules = [
            self.course,
            overview,
            chapter,
            ccx_locator,
            error_descriptor,
            course_key,
            usage_key,
        ]
        # Course key is not None
        self.assertTrue(
            bool(access.has_staff_access_to_preview_mode(self.global_staff, obj=self.course, course_key=course_key))
        )

        for user in [self.global_staff, self.course_staff, self.course_instructor]:
            for obj in modules:
                self.assertTrue(bool(access.has_staff_access_to_preview_mode(user, obj=obj)))
                self.assertFalse(bool(access.has_staff_access_to_preview_mode(self.student, obj=obj)))
开发者ID:PomegranitesUnite,项目名称:edx-platform,代码行数:42,代码来源:test_access.py


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