本文整理匯總了Python中xblock.test.tools.TestRuntime.render方法的典型用法代碼示例。如果您正苦於以下問題:Python TestRuntime.render方法的具體用法?Python TestRuntime.render怎麽用?Python TestRuntime.render使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類xblock.test.tools.TestRuntime
的用法示例。
在下文中一共展示了TestRuntime.render方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_sub_service
# 需要導入模塊: from xblock.test.tools import TestRuntime [as 別名]
# 或者: from xblock.test.tools.TestRuntime import render [as 別名]
def test_sub_service():
runtime = TestRuntime(id_reader=Mock(), services={
'secret_service': 17,
'field-data': DictFieldData({}),
})
tester = SubXBlockWithServices(runtime, scope_ids=Mock(spec=ScopeIds))
# Call the student_view to run its assertions.
runtime.render(tester, 'student_view')
示例2: test_service
# 需要導入模塊: from xblock.test.tools import TestRuntime [as 別名]
# 或者: from xblock.test.tools.TestRuntime import render [as 別名]
def test_service():
runtime = TestRuntime(services={"secret_service": 17, "field-data": DictFieldData({})})
block_type = "test"
def_id = runtime.id_generator.create_definition(block_type)
usage_id = runtime.id_generator.create_usage(def_id)
tester = XBlockWithServices(runtime, scope_ids=ScopeIds("user", block_type, def_id, usage_id))
# Call the student_view to run its assertions.
runtime.render(tester, "student_view")
示例3: test_service
# 需要導入模塊: from xblock.test.tools import TestRuntime [as 別名]
# 或者: from xblock.test.tools.TestRuntime import render [as 別名]
def test_service():
runtime = TestRuntime(services={
'secret_service': 17,
'field-data': DictFieldData({}),
})
block_type = 'test'
def_id = runtime.id_generator.create_definition(block_type)
usage_id = runtime.id_generator.create_usage(def_id)
tester = XBlockWithServices(runtime, scope_ids=ScopeIds('user', block_type, def_id, usage_id))
# Call the student_view to run its assertions.
runtime.render(tester, 'student_view')
示例4: TestAsides
# 需要導入模塊: from xblock.test.tools import TestRuntime [as 別名]
# 或者: from xblock.test.tools.TestRuntime import render [as 別名]
class TestAsides(TestCase):
"""
Tests of XBlockAsides.
"""
def setUp(self):
key_store = DictKeyValueStore()
field_data = KvsFieldData(key_store)
self.runtime = TestRuntime(services={'field-data': field_data})
block_type = 'test'
def_id = self.runtime.id_generator.create_definition(block_type)
usage_id = self.runtime.id_generator.create_usage(def_id)
self.tester = TestXBlock(self.runtime, scope_ids=ScopeIds('user', block_type, def_id, usage_id))
@XBlockAside.register_temp_plugin(TestAside)
def test_render_aside(self):
"""
Test that rendering the xblock renders its aside
"""
frag = self.runtime.render(self.tester, 'student_view', [u"ignore"])
self.assertIn(TestAside.FRAG_CONTENT, frag.body_html())
frag = self.runtime.render(self.tester, 'author_view', [u"ignore"])
self.assertNotIn(TestAside.FRAG_CONTENT, frag.body_html())
@XBlockAside.register_temp_plugin(TestAside)
@XBlockAside.register_temp_plugin(TestInheritedAside)
def test_inherited_aside_view(self):
"""
Test that rendering the xblock renders its aside (when the aside view is
inherited).
"""
frag = self.runtime.render(self.tester, 'student_view', [u"ignore"])
self.assertIn(TestAside.FRAG_CONTENT, frag.body_html())
self.assertIn(TestInheritedAside.FRAG_CONTENT, frag.body_html())
frag = self.runtime.render(self.tester, 'author_view', [u"ignore"])
self.assertNotIn(TestAside.FRAG_CONTENT, frag.body_html())
self.assertNotIn(TestInheritedAside.FRAG_CONTENT, frag.body_html())
示例5: test_service
# 需要導入模塊: from xblock.test.tools import TestRuntime [as 別名]
# 或者: from xblock.test.tools.TestRuntime import render [as 別名]
def test_service():
runtime = TestRuntime(services={'secret_service': 17})
tester = XBlockWithServices(runtime, scope_ids=Mock(spec=ScopeIds))
# Call the student_view to run its assertions.
runtime.render(tester, 'student_view')