'Test that copying plugins works as expected.'

def test_copy_plugins(self):

    page_en = api.create_page('CopyPluginTestPage    (EN)', 'nav_playground.html', 'en')
    page_de = api.create_page('CopyPluginTestPage    (DE)', 'nav_playground.html', 'de')
    ph_en = page_en.placeholders.get(slot='body')
    ph_de = page_de.placeholders.get(slot='body')
    text_plugin_en = api.add_plugin(ph_en, 'TextPlugin', 'en', body='Hello    World')
    self.assertEqual(text_plugin_en.pk, CMSPlugin.objects.all()[0].pk)
    link_plugin_en = api.add_plugin(ph_en, 'LinkPlugin', 'en', target=text_plugin_en, name='A    Link', external_link='https://www.django-cms.org')
    text_plugin_en = self.reload(text_plugin_en)
    self.assertEqual(text_plugin_en.get_children().count(), 1)
    self.assertEqual(link_plugin_en.parent.pk, text_plugin_en.pk)
    self.assertEqual(CMSPlugin.objects.count(), 2)
    copy_plugins_to(ph_en.get_plugins(), ph_de, 'de')
    self.assertEqual(ph_de.cmsplugin_set.filter(parent=None).count(), 1)
    text_plugin_de = ph_de.cmsplugin_set.get(parent=None).get_plugin_instance()[0]
    self.assertEqual(text_plugin_de.get_children().count(), 1)
    link_plugin_de = text_plugin_de.get_children().get().get_plugin_instance()[0]
    self.assertEqual(CMSPlugin.objects.count(), 4)
    self.assertEqual(CMSPlugin.objects.filter(language='de').count(), 2)
    self.assertEqual(CMSPlugin.objects.filter(language='en').count(), 2)
    text_plugin_en = self.reload(text_plugin_en)
    link_plugin_en = self.reload(link_plugin_en)
    self.assertEqual(text_plugin_en.get_children().count(), 1)
    self.assertEqual(link_plugin_en.parent.pk, text_plugin_en.pk)
    self.assertEqual(link_plugin_de.name, link_plugin_en.name)
    self.assertEqual(link_plugin_de.external_link, link_plugin_en.external_link)
    self.assertEqual(text_plugin_de.body, text_plugin_en.body)
    copy_plugins_to([link_plugin_en], ph_de, 'de')
