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


Python tests.get_test_system函数代码示例

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


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


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