'When a placeholder is aliased, it shouldn\'t render as editable
in the structure mode.'

def test_alias_placeholder_is_not_editable(self):

    source_page = api.create_page('Home', 'col_two.html', 'en', published=True, in_navigation=True)
    source_placeholder = source_page.placeholders.get(slot='col_left')
    style = api.add_plugin(source_placeholder, 'StylePlugin', 'en', tag_type='div', class_name='info')
    target_page = api.create_page('Target', 'col_two.html', 'en', published=True, in_navigation=True)
    target_placeholder = target_page.placeholders.get(slot='col_left')
    alias = api.add_plugin(target_placeholder, 'AliasPlugin', 'en', alias_placeholder=source_placeholder)
    with self.login_user_context(self.get_superuser()):
        context = self.get_context(path=target_page.get_absolute_url(), page=target_page)
        context['request'].toolbar = CMSToolbar(context['request'])
        context['request'].toolbar.edit_mode = True
        context['cms_content_renderer']._placeholders_are_editable = True
        context[get_varname()] = defaultdict(UniqueSequence)
        content_renderer = context['cms_content_renderer']
        output = content_renderer.render_placeholder(target_placeholder, context=context, language='en', page=target_page, editable=True)
        tag_format = '<template    class="cms-plugin    cms-plugin-start    cms-plugin-{}">'
        expected_plugins = [alias]
        unexpected_plugins = [style]
        for plugin in expected_plugins:
            start_tag = tag_format.format(plugin.pk)
            self.assertIn(start_tag, output)
        for plugin in unexpected_plugins:
            start_tag = tag_format.format(plugin.pk)
            self.assertNotIn(start_tag, output)
        editable_placeholders = content_renderer.get_rendered_editable_placeholders()
        self.assertNotIn(source_placeholder, editable_placeholders)
