Commit b64aa813 by Calen Pennington

Make render_template mocking clearer

parent e43dbd29
...@@ -66,7 +66,7 @@ class TestXBlockWrapper(object): ...@@ -66,7 +66,7 @@ class TestXBlockWrapper(object):
@property @property
def leaf_module_runtime(self): def leaf_module_runtime(self):
runtime = Mock() runtime = Mock()
runtime.render_template = lambda *args, **kwargs: unicode((args, kwargs)) runtime.render_template = lambda *args, **kwargs: u'{!r}, {!r}'.format(args, kwargs)
runtime.anonymous_student_id = 'dummy_anonymous_student_id' runtime.anonymous_student_id = 'dummy_anonymous_student_id'
runtime.open_ended_grading_interface = {} runtime.open_ended_grading_interface = {}
runtime.seed = 5 runtime.seed = 5
...@@ -78,7 +78,7 @@ class TestXBlockWrapper(object): ...@@ -78,7 +78,7 @@ class TestXBlockWrapper(object):
@property @property
def leaf_descriptor_runtime(self): def leaf_descriptor_runtime(self):
runtime = Mock() runtime = Mock()
runtime.render_template = lambda *args, **kwargs: unicode((args, kwargs)) runtime.render_template = lambda *args, **kwargs: u'{!r}, {!r}'.format(args, kwargs)
return runtime return runtime
def leaf_descriptor(self, descriptor_cls): def leaf_descriptor(self, descriptor_cls):
...@@ -102,7 +102,7 @@ class TestXBlockWrapper(object): ...@@ -102,7 +102,7 @@ class TestXBlockWrapper(object):
@property @property
def container_descriptor_runtime(self): def container_descriptor_runtime(self):
runtime = Mock() runtime = Mock()
runtime.render_template = lambda *args, **kwargs: unicode((args, kwargs)) runtime.render_template = lambda *args, **kwargs: u'{!r}, {!r}'.format(args, kwargs)
return runtime return runtime
def container_descriptor(self, descriptor_cls): def container_descriptor(self, descriptor_cls):
......
...@@ -80,7 +80,7 @@ class BaseTestXmodule(ModuleStoreTestCase): ...@@ -80,7 +80,7 @@ class BaseTestXmodule(ModuleStoreTestCase):
self.runtime = get_test_system() self.runtime = get_test_system()
# Allow us to assert that the template was called in the same way from # 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 # different code paths while maintaining the type returned by render_template
self.runtime.render_template = lambda template, context: unicode((template, sorted(context.items()))) self.runtime.render_template = lambda template, context: u'{!r}, {!r}'.format(template, sorted(context.items()))
model_data = {'location': self.item_descriptor.location} model_data = {'location': self.item_descriptor.location}
model_data.update(self.MODEL_DATA) model_data.update(self.MODEL_DATA)
......
...@@ -104,7 +104,7 @@ class VideoAlphaModuleUnitTest(unittest.TestCase): ...@@ -104,7 +104,7 @@ class VideoAlphaModuleUnitTest(unittest.TestCase):
def test_videoalpha_constructor(self): def test_videoalpha_constructor(self):
"""Make sure that all parameters extracted correclty from xml""" """Make sure that all parameters extracted correclty from xml"""
module = VideoAlphaFactory.create() module = VideoAlphaFactory.create()
module.runtime.render_template = lambda template, context: unicode((template, sorted(context.items()))) module.runtime.render_template = lambda template, context: u'{!r}, {!r}'.format(template, sorted(context.items()))
fragment = module.runtime.render(module, None, 'student_view') fragment = module.runtime.render(module, None, 'student_view')
expected_context = { expected_context = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment