def test_render_inner_html(self): """ Test the ``render_inner_html`` function """ root_tree_node = RootTreeNode() tree_node_l1 = root_tree_node.new_child('level1', get_test_node('level1-1')) root_tree_node.new_child('level1', get_test_node('level1-2')) tree_node_l2 = tree_node_l1.new_child('level2', get_test_node('level2-1')) tree_node_l1.new_child('level2', get_test_node('level2-2')) root_tree_node.new_child('level1', get_test_node('level1-3')) tree_node_l2.new_child('level3', get_test_node('level3-1')) tree_node_l2.new_child('level3', get_test_node('level3-2')) tree_node_l1.new_child('level2', get_test_node('level2-3')) output = render_inner_html(tree_node_l2, some_custom_kwarg='foobar') expected_output = '[HTML+level3-1][/HTML]' \ '[HTML+level3-2][/HTML]' self.assertEqual(expected_output, output)
def test_render_inner_html_with_errors_suppressed(self): """ Test the ``render_inner_html`` function with erroneous node (error suppressed) """ root_tree_node = RootTreeNode() tree_node_l1 = root_tree_node.new_child('level1', get_test_node('level1-1')) root_tree_node.new_child('level1', get_test_node('level1-2')) tree_node_l2 = tree_node_l1.new_child('level2', get_test_node('level2-1')) tree_node_l1.new_child('level2', get_test_node('level2-2')) root_tree_node.new_child('level1', get_test_node('level1-3')) tree_node_l2.new_child('level3', get_test_node('level3-1')) tree_node_l2.new_child('level3', get_test_node('level3-2'), source_open_tag='[test]', source_close_tag='[/test]', error_message='foo') tree_node_l1.new_child('level2', get_test_node('level2-3')) output = render_inner_html(tree_node_l2, html_error_template=SUPPRESS_ERROR_HTML_TEMPLATE, some_custom_kwarg='foobar') expected_output = '[HTML+level3-1][/HTML]' \ '<!-- foo --> [test]\n<!-- foo --> [/test]' self.assertEqual(expected_output, output)
def test_render_inner_html_with_errors(self): """ Test the ``render_inner_html`` function with erroneous node """ root_tree_node = RootTreeNode() tree_node_l1 = root_tree_node.new_child('level1', get_test_node('level1-1')) root_tree_node.new_child('level1', get_test_node('level1-2')) tree_node_l2 = tree_node_l1.new_child('level2', get_test_node('level2-1')) tree_node_l1.new_child('level2', get_test_node('level2-2')) root_tree_node.new_child('level1', get_test_node('level1-3')) tree_node_l2.new_child('level3', get_test_node('level3-1')) tree_node_l2.new_child('level3', get_test_node('level3-2'), source_open_tag='[test]', source_close_tag='[/test]', error_message='foo') tree_node_l1.new_child('level2', get_test_node('level2-3')) output = render_inner_html(tree_node_l2, html_error_template='<error={error_message}>{source}</error>', some_custom_kwarg='foobar') expected_output = '[HTML+level3-1][/HTML]' \ '<error=foo>[test]</error>\n<error=foo>[/test]</error>' self.assertEqual(expected_output, output)
def test_render_inner_html_with_errors_suppressed(self): """ Test the ``render_inner_html`` function with erroneous node (error suppressed) """ root_tree_node = RootTreeNode() tree_node_l1 = root_tree_node.new_child('level1', get_test_node('level1-1')) root_tree_node.new_child('level1', get_test_node('level1-2')) tree_node_l2 = tree_node_l1.new_child('level2', get_test_node('level2-1')) tree_node_l1.new_child('level2', get_test_node('level2-2')) root_tree_node.new_child('level1', get_test_node('level1-3')) tree_node_l2.new_child('level3', get_test_node('level3-1')) tree_node_l2.new_child('level3', get_test_node('level3-2'), source_open_tag='[test]', source_close_tag='[/test]', error_message='foo') tree_node_l1.new_child('level2', get_test_node('level2-3')) output = render_inner_html( tree_node_l2, html_error_template=SUPPRESS_ERROR_HTML_TEMPLATE, some_custom_kwarg='foobar') expected_output = '[HTML+level3-1][/HTML]' \ '<!-- foo --> [test]\n<!-- foo --> [/test]' self.assertEqual(expected_output, output)
def test_render_inner_html_with_errors(self): """ Test the ``render_inner_html`` function with erroneous node """ root_tree_node = RootTreeNode() tree_node_l1 = root_tree_node.new_child('level1', get_test_node('level1-1')) root_tree_node.new_child('level1', get_test_node('level1-2')) tree_node_l2 = tree_node_l1.new_child('level2', get_test_node('level2-1')) tree_node_l1.new_child('level2', get_test_node('level2-2')) root_tree_node.new_child('level1', get_test_node('level1-3')) tree_node_l2.new_child('level3', get_test_node('level3-1')) tree_node_l2.new_child('level3', get_test_node('level3-2'), source_open_tag='[test]', source_close_tag='[/test]', error_message='foo') tree_node_l1.new_child('level2', get_test_node('level2-3')) output = render_inner_html( tree_node_l2, html_error_template='<error={error_message}>{source}</error>', some_custom_kwarg='foobar') expected_output = '[HTML+level3-1][/HTML]' \ '<error=foo>[test]</error>\n<error=foo>[/test]</error>' self.assertEqual(expected_output, output)