'Validate a textplugin with a nested link plugin
mptt values are correctly showing a parent child relationship
of a nested plugin'

def test_nested_plugin_on_page(self):

    with self.settings(CMS_PERMISSION=False):
        page_one = create_page(u'Three    Placeholder', u'col_three.html', u'en', position=u'last-child', published=True, in_navigation=True)
        page_one_ph_two = page_one.placeholders.get(slot=u'col_left')
        pre_nesting_body = u'<p>the    nested    text    plugin    with    a    link    inside</p>'
        text_plugin = add_plugin(page_one_ph_two, u'TextPlugin', u'en', body=pre_nesting_body)
        page_one_ph_two = self.reload(page_one_ph_two)
        text_plugin = self.reload(text_plugin)
        link_plugin = add_plugin(page_one_ph_two, u'LinkPlugin', u'en', target=text_plugin)
        link_plugin.name = u'django-cms    Link'
        link_plugin.external_link = u'https://www.django-cms.org'
        link_plugin.parent = text_plugin
        link_plugin.save()
        link_plugin = self.reload(link_plugin)
        text_plugin = self.reload(text_plugin)
        msg = u'parent    plugin    right    is    not    updated,    child    not    inserted    correctly'
        self.assertTrue((text_plugin.position == link_plugin.position), msg=msg)
        msg = u'link    has    no    parent'
        self.assertFalse((link_plugin.parent is None), msg=msg)
        msg = u'parent    plugin    path    is    not    updated,    child    not    inserted    correctly'
        self.assertTrue((text_plugin.path == link_plugin.path[:4]), msg=msg)
        msg = u'child    level    is    not    bigger    than    parent    level'
        self.assertTrue((text_plugin.depth < link_plugin.depth), msg=msg)
        in_txt = u'<img    id="plugin_obj_%s"    title="Link"    alt="Link"    src="/static/cms/img/icons/plugins/link.png">'
        nesting_body = (u'%s<p>%s</p>' % (text_plugin.body, (in_txt % link_plugin.id)))
        text_plugin.body = nesting_body
        text_plugin.save()
        text_plugin = self.reload(text_plugin)
        self.assertEqual(text_plugin.get_descendants().exclude(placeholder=text_plugin.placeholder).count(), 0)
        post_add_plugin_count = CMSPlugin.objects.count()
        self.assertEqual(post_add_plugin_count, 2)
