• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python tests.get_test_system函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中xmodule.tests.get_test_system函数的典型用法代码示例。如果您正苦于以下问题:Python get_test_system函数的具体用法?Python get_test_system怎么用?Python get_test_system使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_open_ended_display

    def test_open_ended_display(self):
        """
        Test storing answer with the open ended module.
        """

        # Create a module with no state yet.  Important that this start off as a blank slate.
        test_module = OpenEndedModule(self.test_system, self.location,
                                                self.definition, self.descriptor, self.static_data, self.metadata)

        saved_response = "Saved response."
        submitted_response = "Submitted response."

        # Initially, there will be no stored answer.
        self.assertEqual(test_module.stored_answer, None)
        # And the initial answer to display will be an empty string.
        self.assertEqual(test_module.get_display_answer(), "")

        # Now, store an answer in the module.
        test_module.handle_ajax("store_answer", {'student_answer' : saved_response}, get_test_system())
        # The stored answer should now equal our response.
        self.assertEqual(test_module.stored_answer, saved_response)
        self.assertEqual(test_module.get_display_answer(), saved_response)

        # Mock out the send_to_grader function so it doesn't try to connect to the xqueue.
        test_module.send_to_grader = Mock(return_value=True)
        # Submit a student response to the question.
        test_module.handle_ajax(
            "save_answer",
            {"student_answer": submitted_response},
            get_test_system()
        )
        # Submitting an answer should clear the stored answer.
        self.assertEqual(test_module.stored_answer, None)
        # Confirm that the answer is stored properly.
        self.assertEqual(test_module.latest_answer(), submitted_response)
开发者ID:Gfirey,项目名称:edx-platform,代码行数:35,代码来源:test_combined_open_ended.py


示例2: setUp

 def setUp(self):
     super(TestPartitionService, self).setUp()
     self.partition_service = StaticPartitionService(
         [self.user_partition],
         runtime=get_test_system(),
         track_function=Mock()
     )
开发者ID:JacobWay,项目名称:edx-platform,代码行数:7,代码来源:test_partitions.py


示例3: inner_get_module

 def inner_get_module(descriptor):
     if isinstance(descriptor, Location):
         location = descriptor
         descriptor = self.modulestore.get_item(location, depth=None)
     descriptor.xmodule_runtime = get_test_system()
     descriptor.xmodule_runtime.get_module = inner_get_module
     return descriptor
开发者ID:1amongus,项目名称:edx-platform,代码行数:7,代码来源:test_conditional.py


示例4: setUp

 def setUp(self):
     """
     Create a peer grading module from a test system.
     """
     self.test_system = get_test_system()
     self.test_system.open_ended_grading_interface = None
     self.setup_modulestore(COURSE)
开发者ID:CEIT-UQ,项目名称:edx-platform,代码行数:7,代码来源:test_peer_grading.py


示例5: get_module

 def get_module(descriptor):
     """Mocks module_system get_module function"""
     sub_module_system = get_test_system(course_id=self.course.location.course_key)
     sub_module_system.get_module = get_module
     sub_module_system.descriptor_runtime = descriptor.runtime
     descriptor.bind_for_student(sub_module_system, descriptor._field_data)  # pylint: disable=protected-access
     return descriptor
开发者ID:feedbackfruits,项目名称:edx-platform,代码行数:7,代码来源:test_library_content.py


示例6: setUp

 def setUp(self):
     super(SetupTestErrorModules, self).setUp()
     self.system = get_test_system()
     self.course_id = SlashSeparatedCourseKey('org', 'course', 'run')
     self.location = self.course_id.make_usage_key('foo', 'bar')
     self.valid_xml = u"<problem>ABC \N{SNOWMAN}</problem>"
     self.error_msg = "Error"
开发者ID:10clouds,项目名称:edx-platform,代码行数:7,代码来源:test_error_module.py


示例7: setUp

 def setUp(self):
     self.test_system = get_test_system()
     self.test_system.open_ended_grading_interface = None
     self.test_system.xqueue['interface'] = Mock(
         send_to_queue=Mock(side_effect=[1, "queued"])
     )
     self.setup_modulestore(COURSE)
开发者ID:Gfirey,项目名称:edx-platform,代码行数:7,代码来源:test_combined_open_ended.py


示例8: _set_up_module_system

 def _set_up_module_system(self, block):
     """
     Sets up the test module system for the given block.
     """
     module_system = get_test_system()
     module_system.descriptor_runtime = block._runtime  # pylint: disable=protected-access
     block.xmodule_runtime = module_system
开发者ID:Lektorium-LLC,项目名称:edx-platform,代码行数:7,代码来源:test_sequence.py


示例9: setUp

    def setUp(self):
        # construct module
        course = xml.CourseFactory.build()
        sequence = xml.SequenceFactory.build(parent=course)
        vertical = xml.VerticalFactory.build(parent=sequence)

        self.course = self.process_xml(course)
        xml.HtmlFactory(parent=vertical, url_name='test-html-1', text=self.test_html_1)
        xml.HtmlFactory(parent=vertical, url_name='test-html-2', text=self.test_html_2)

        self.course = self.process_xml(course)
        course_seq = self.course.get_children()[0]
        self.module_system = get_test_system()

        def get_module(descriptor):
            """Mocks module_system get_module function"""
            module_system = get_test_system()
            module_system.get_module = get_module
            descriptor.bind_for_student(module_system, descriptor._field_data)  # pylint: disable=protected-access
            return descriptor

        self.module_system.get_module = get_module
        self.module_system.descriptor_system = self.course.runtime
        self.course.runtime.export_fs = MemoryFS()

        self.vertical = course_seq.get_children()[0]
        self.vertical.xmodule_runtime = self.module_system
开发者ID:PaoloC68,项目名称:edx-platform,代码行数:27,代码来源:test_vertical.py


示例10: get_module_system

 def get_module_system(self, descriptor):
     test_system = get_test_system()
     test_system.open_ended_grading_interface = None
     test_system.xqueue['interface'] = Mock(
         send_to_queue=Mock(side_effect=[1, "queued"])
     )
     return test_system
开发者ID:DavidGrahamFL,项目名称:edx-platform,代码行数:7,代码来源:test_combined_open_ended.py


示例11: setUp

 def setUp(self):
     self.system = get_test_system()
     self.org = "org"
     self.course = "course"
     self.location = Location(['i4x', self.org, self.course, None, None])
     self.valid_xml = u"<problem>ABC \N{SNOWMAN}</problem>"
     self.error_msg = "Error"
开发者ID:AzizYosofi,项目名称:edx-platform,代码行数:7,代码来源:test_error_module.py


示例12: get_module

 def get_module(descriptor):
     """Mocks module_system get_module function"""
     sub_module_system = get_test_system(course_id=module.location.course_key)
     sub_module_system.get_module = get_module
     sub_module_system.descriptor_runtime = descriptor._runtime  # pylint: disable=protected-access
     descriptor.bind_for_student(sub_module_system, self.user_id)
     return descriptor
开发者ID:cmscom,项目名称:edx-platform,代码行数:7,代码来源:test_library_content.py


示例13: create

    def create(system, source_is_error_module=False):
        """
        return a dict of modules: the conditional with a single source and a single child.
        Keys are 'cond_module', 'source_module', and 'child_module'.

        if the source_is_error_module flag is set, create a real ErrorModule for the source.
        """
        descriptor_system = get_test_descriptor_system()

        # construct source descriptor and module:
        source_location = Location(["i4x", "edX", "conditional_test", "problem", "SampleProblem"])
        if source_is_error_module:
            # Make an error descriptor and module
            source_descriptor = NonStaffErrorDescriptor.from_xml(
                'some random xml data',
                system,
                org=source_location.org,
                course=source_location.course,
                error_msg='random error message'
            )
        else:
            source_descriptor = Mock()
            source_descriptor.location = source_location

        source_descriptor.runtime = descriptor_system
        source_descriptor.render = lambda view, context=None: descriptor_system.render(source_descriptor, view, context)

        # construct other descriptors:
        child_descriptor = Mock()
        child_descriptor._xmodule.student_view.return_value.content = u'<p>This is a secret</p>'
        child_descriptor.student_view = child_descriptor._xmodule.student_view
        child_descriptor.displayable_items.return_value = [child_descriptor]
        child_descriptor.runtime = descriptor_system
        child_descriptor.xmodule_runtime = get_test_system()
        child_descriptor.render = lambda view, context=None: descriptor_system.render(child_descriptor, view, context)

        descriptor_system.load_item = {'child': child_descriptor, 'source': source_descriptor}.get

        # construct conditional module:
        cond_location = Location(["i4x", "edX", "conditional_test", "conditional", "SampleConditional"])
        field_data = DictFieldData({
            'data': '<conditional/>',
            'xml_attributes': {'attempted': 'true'},
            'children': ['child'],
        })

        cond_descriptor = ConditionalDescriptor(
            descriptor_system,
            field_data,
            ScopeIds(None, None, cond_location, cond_location)
        )
        cond_descriptor.xmodule_runtime = system
        system.get_module = lambda desc: desc
        cond_descriptor.get_required_module_descriptors = Mock(return_value=[source_descriptor])

        # return dict:
        return {'cond_module': cond_descriptor,
                'source_module': source_descriptor,
                'child_module': child_descriptor}
开发者ID:Codeyelp,项目名称:edx-platform,代码行数:59,代码来源:test_conditional.py


示例14: inner_get_module

 def inner_get_module(descriptor):
     if isinstance(descriptor, Location):
         location = descriptor
         descriptor = self.modulestore.get_item(location, depth=None)
     descriptor.xmodule_runtime = get_test_system()
     descriptor.xmodule_runtime.descriptor_runtime = descriptor._runtime  # pylint: disable=protected-access
     descriptor.xmodule_runtime.get_module = inner_get_module
     return descriptor
开发者ID:10clouds,项目名称:edx-platform,代码行数:8,代码来源:test_conditional.py


示例15: create

    def create(system, source_is_error_module=False):
        """
        return a dict of modules: the conditional with a single source and a single child.
        Keys are 'cond_module', 'source_module', and 'child_module'.

        if the source_is_error_module flag is set, create a real ErrorModule for the source.
        """
        descriptor_system = get_test_descriptor_system()

        # construct source descriptor and module:
        source_location = Location("edX", "conditional_test", "test_run", "problem", "SampleProblem", None)
        if source_is_error_module:
            # Make an error descriptor and module
            source_descriptor = NonStaffErrorDescriptor.from_xml(
                "some random xml data",
                system,
                id_generator=CourseLocationManager(source_location.course_key),
                error_msg="random error message",
            )
        else:
            source_descriptor = Mock(name="source_descriptor")
            source_descriptor.location = source_location

        source_descriptor.runtime = descriptor_system
        source_descriptor.render = lambda view, context=None: descriptor_system.render(source_descriptor, view, context)

        # construct other descriptors:
        child_descriptor = Mock(name="child_descriptor")
        child_descriptor._xmodule.student_view.return_value.content = u"<p>This is a secret</p>"
        child_descriptor.student_view = child_descriptor._xmodule.student_view
        child_descriptor.displayable_items.return_value = [child_descriptor]
        child_descriptor.runtime = descriptor_system
        child_descriptor.xmodule_runtime = get_test_system()
        child_descriptor.render = lambda view, context=None: descriptor_system.render(child_descriptor, view, context)
        child_descriptor.location = source_location.replace(category="html", name="child")

        descriptor_system.load_item = {
            child_descriptor.location: child_descriptor,
            source_location: source_descriptor,
        }.get

        system.descriptor_runtime = descriptor_system

        # construct conditional module:
        cond_location = Location("edX", "conditional_test", "test_run", "conditional", "SampleConditional", None)
        field_data = DictFieldData(
            {"data": "<conditional/>", "xml_attributes": {"attempted": "true"}, "children": [child_descriptor.location]}
        )

        cond_descriptor = ConditionalDescriptor(
            descriptor_system, field_data, ScopeIds(None, None, cond_location, cond_location)
        )
        cond_descriptor.xmodule_runtime = system
        system.get_module = lambda desc: desc
        cond_descriptor.get_required_module_descriptors = Mock(return_value=[source_descriptor])

        # return dict:
        return {"cond_module": cond_descriptor, "source_module": source_descriptor, "child_module": child_descriptor}
开发者ID:fjardon,项目名称:edx-platform,代码行数:58,代码来源:test_conditional.py


示例16: setUp

    def setUp(self):

        self.course = CourseFactory.create(data=self.COURSE_DATA)

        # Turn off cache.
        modulestore().request_cache = None
        modulestore().metadata_inheritance_cache_subsystem = None

        chapter = ItemFactory.create(
            parent_location=self.course.location,
            category="sequential",
        )
        section = ItemFactory.create(
            parent_location=chapter.location,
            category="sequential"
        )

        # username = robot{0}, password = 'test'
        self.users = [
            UserFactory.create(username='robot%d' % i, email='robot+test+%[email protected]' % i)
            for i in range(self.USER_COUNT)
        ]

        for user in self.users:
            CourseEnrollmentFactory.create(user=user, course_id=self.course.id)

        self.item_descriptor = ItemFactory.create(
            parent_location=section.location,
            category=self.CATEGORY,
            data=self.DATA
        )

        self.runtime = get_test_system()
        # Allow us to assert that the template was called in the same way from
        # different code paths while maintaining the type returned by render_template
        self.runtime.render_template = lambda template, context: u'{!r}, {!r}'.format(template, sorted(context.items()))

        model_data = {'location': self.item_descriptor.location}
        model_data.update(self.MODEL_DATA)

        self.item_module = self.item_descriptor.module_class(
            self.runtime,
            self.item_descriptor,
            model_data
        )

        self.item_url = Location(self.item_module.location).url()

        # login all users for acces to Xmodule
        self.clients = {user.username: Client() for user in self.users}
        self.login_statuses = [
            self.clients[user.username].login(
                username=user.username, password='test')
            for user in self.users
        ]

        self.assertTrue(all(self.login_statuses))
开发者ID:NikolayStrekalov,项目名称:edx-platform,代码行数:57,代码来源:__init__.py


示例17: create

    def create():
        """Method return Video Xmodule instance."""
        location = Location(["i4x", "edX", "video", "default",
                             "SampleProblem1"])
        field_data = {'data': VideoFactory.sample_problem_xml_youtube,
                      'location': location}

        system = get_test_descriptor_system()

        descriptor = VideoDescriptor(system, DictFieldData(field_data), ScopeIds(None, None, None, None))
        descriptor.xmodule_runtime = get_test_system()
        return descriptor
开发者ID:chenkaigithub,项目名称:edx-platform,代码行数:12,代码来源:test_video_xml.py


示例18: create

    def create():
        """Method return Video Xmodule instance."""
        location = Location(["i4x", "edX", "video", "default",
                             "SampleProblem1"])
        model_data = {'data': VideoFactory.sample_problem_xml_youtube, 'location': location}

        descriptor = Mock(weight="1", url_name="SampleProblem1")

        system = get_test_system()
        system.render_template = lambda template, context: context
        module = VideoModule(system, descriptor, model_data)

        return module
开发者ID:burngeek8,项目名称:edx-platform,代码行数:13,代码来源:test_video_xml.py


示例19: setUp

    def setUp(self):

        self.course = CourseFactory.create()

        # Turn off cache.
        modulestore().request_cache = None
        modulestore().metadata_inheritance_cache_subsystem = None

        chapter = ItemFactory.create(
            parent_location=self.course.location,
            category="sequential",
        )
        section = ItemFactory.create(
            parent_location=chapter.location,
            category="sequential"
        )

        # username = robot{0}, password = 'test'
        self.users = [
            UserFactory.create(username='robot%d' % i, email='robot+test+%[email protected]' % i)
            for i in range(self.USER_COUNT)
        ]

        for user in self.users:
            CourseEnrollmentFactory.create(user=user, course_id=self.course.id)

        self.item_descriptor = ItemFactory.create(
            parent_location=section.location,
            category=self.CATEGORY,
            data=self.DATA
        )

        system = get_test_system()
        system.render_template = lambda template, context: context
        model_data = {'location': self.item_descriptor.location}
        model_data.update(self.MODEL_DATA)

        self.item_module = self.item_descriptor.module_class(
            system, self.item_descriptor, model_data
        )
        self.item_url = Location(self.item_module.location).url()

        # login all users for acces to Xmodule
        self.clients = {user.username: Client() for user in self.users}
        self.login_statuses = [
            self.clients[user.username].login(
                username=user.username, password='test')
            for user in self.users
        ]

        self.assertTrue(all(self.login_statuses))
开发者ID:NakarinTalikan,项目名称:edx-platform,代码行数:51,代码来源:__init__.py


示例20: setUp

    def setUp(self):
        class EmptyClass:
            """Empty object."""
            pass

        self.system = get_test_system()
        self.descriptor = EmptyClass()

        self.xmodule_class = self.descriptor_class.module_class
        self.xmodule = self.xmodule_class(
            self.system,
            self.descriptor,
            self.raw_model_data
        )
开发者ID:dfoulser,项目名称:edx-platform,代码行数:14,代码来源:test_logic.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python factories.CourseFactory类代码示例发布时间:2022-05-26
下一篇:
Python tests.get_test_descriptor_system函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap