fix: refactor MakoService to allow specifying template more explicitly (Take 2) (#33077)

* fix: refactor MakoService to allow specifying namespace per template (#33061)

* fix: instr. dashboard broken by bulk email reusing HtmlBlock studio_view

* fix: lint issue from unused import
This commit is contained in:
Braden MacDonald
2023-08-23 11:48:06 -07:00
committed by GitHub
parent d83d769c6f
commit f491f5bde8
26 changed files with 134 additions and 83 deletions

View File

@@ -56,6 +56,18 @@ class StubMakoService:
"""
return self._render_template(*args, **kwargs)
def render_lms_template(self, *args, **kwargs):
"""
Invokes the configured render_template method.
"""
return self._render_template(*args, **kwargs)
def render_cms_template(self, *args, **kwargs):
"""
Invokes the configured render_template method.
"""
return self._render_template(*args, **kwargs)
class StubUserService(UserService):
"""

View File

@@ -162,7 +162,7 @@ class ConditionalBlockBasicTest(unittest.TestCase):
# we reverse it here
html = blocks['cond_block'].render(STUDENT_VIEW).content
mako_service = blocks['cond_block'].runtime.service(blocks['cond_block'], 'mako')
expected = mako_service.render_template('conditional_ajax.html', {
expected = mako_service.render_lms_template('conditional_ajax.html', {
'ajax_url': blocks['cond_block'].ajax_url,
'element_id': 'i4x-edX-conditional_test-conditional-SampleConditional',
'depends': 'i4x-edX-conditional_test-problem-SampleProblem',
@@ -243,7 +243,7 @@ class ConditionalBlockXmlTest(unittest.TestCase):
block = self.get_block_for_location(location)
html = block.render(STUDENT_VIEW).content
mako_service = block.runtime.service(block, 'mako')
html_expect = mako_service.render_template(
html_expect = mako_service.render_lms_template(
'conditional_ajax.html',
{
# Test ajax url is just usage-id / handler_name

View File

@@ -316,7 +316,7 @@ class CourseInfoBlockTestCase(unittest.TestCase):
template_name = f"{info_block.TEMPLATE_DIR}/course_updates.html"
info_block.get_html()
# Assertion to validate that render function is called with the expected context
info_block.runtime.service(info_block, 'mako').render_template.assert_called_once_with(
info_block.runtime.service(info_block, 'mako').render_lms_template.assert_called_once_with(
template_name,
expected_context
)