'Tests the {% render_placeholder %} templatetag.'

def test_edit_render_placeholder(self):

    user = self.get_staff()
    page = create_page('Test', 'col_two.html', 'en', published=True)
    ex1 = Example1(char_1='char_1', char_2='char_2', char_3='char_3', char_4='char_4')
    ex1.save()
    render_placeholder_body = "I'm    the    render    placeholder    body"
    plugin = add_plugin(ex1.placeholder, u'TextPlugin', u'en', body=render_placeholder_body)
    template_text = '{%    extends    "base.html"    %}\n{%    load    cms_tags    %}\n\n{%    block    content    %}\n<h1>{%    render_placeholder    instance.placeholder    %}</h1>\n<h2>{%    render_placeholder    instance.placeholder    as    tempvar    %}</h2>\n<h3>{{    tempvar    }}</h3>\n{%    endblock    content    %}\n'
    request = self.get_page_request(page, user, edit=True)
    response = detail_view(request, ex1.pk, template_string=template_text)
    self.assertContains(response, '<h1><div    class="cms-placeholder    cms-placeholder-{0}"></div>'.format(ex1.placeholder.pk))
    self.assertContains(response, '<script    id="cms-plugin-child-classes-{0}"    type="text/cms-template">'.format(ex1.placeholder.pk))
    self.assertContains(response, '<template    class="cms-plugin    cms-plugin-start    cms-plugin-{0}"></template>{1}<template    class="cms-plugin    cms-plugin-end    cms-plugin-{0}"></template></h1>'.format(plugin.pk, render_placeholder_body))
    self.assertContains(response, '<h2></h2>')
    self.assertContains(response, '<h3>{0}</h3>'.format(render_placeholder_body))
    self.assertContains(response, "CMS._plugins.push(['cms-plugin-{0}'".format(plugin.pk))
    self.assertContains(response, "CMS._plugins.push(['cms-placeholder-{0}'".format(ex1.placeholder.pk))
