From 90ed83c821a8010310f3d92d6a53d6a30818fccb Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Fri, 26 Feb 2016 23:48:48 +0100 Subject: [PATCH] Test copy relations --- tests/test_plugins.py | 48 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/tests/test_plugins.py b/tests/test_plugins.py index cb209f2..8a241d9 100644 --- a/tests/test_plugins.py +++ b/tests/test_plugins.py @@ -59,6 +59,24 @@ class PluginTest(BaseTest): self.assertTrue(rendered.find('
-1) self.assertTrue(rendered.find(posts[1].get_absolute_url()) > -1) + # Checking copy relations + ph = pages[0].placeholders.get(slot='content') + original = ph.get_plugins('en') + pages[0].publish('en') + published = pages[0].get_public_object() + ph = published.placeholders.get(slot='content') + new = ph.get_plugins('en') + self.assertNotEqual(original, new) + + casted_tags, __ = new[0].get_plugin_instance() + casted_categories, __ = new[1].get_plugin_instance() + + self.assertEqual(casted_tags.tags.count(), 1) + self.assertEqual(casted_tags.categories.count(), 0) + + self.assertEqual(casted_categories.tags.count(), 0) + self.assertEqual(casted_categories.categories.count(), 1) + def test_plugin_authors(self): pages = self.get_pages() posts = self.get_posts() @@ -73,6 +91,36 @@ class PluginTest(BaseTest): rendered = plugin.render_plugin(context, ph) self.assertTrue(rendered.find('No article found') > -1) + plugin.authors.add(self.user) + context = self.get_plugin_context(pages[0], 'en', plugin, edit=True) + rendered = plugin.render_plugin(context, ph) + self.assertTrue(rendered.find('/en/blog/author/admin/') > -1) + self.assertTrue(rendered.find('2 articles') > -1) + + plugin.authors.add(self.user_staff) + context = self.get_plugin_context(pages[0], 'en', plugin, edit=True) + rendered = plugin.render_plugin(context, ph) + self.assertTrue(rendered.find('/en/blog/author/staff/') > -1) + self.assertTrue(rendered.find('0 articles') > -1) + + plugin.authors.add(self.user_normal) + context = self.get_plugin_context(pages[0], 'en', plugin, edit=True) + rendered = plugin.render_plugin(context, ph) + self.assertTrue(rendered.find('/en/blog/author/normal/') > -1) + self.assertTrue(rendered.find('0 articles') > -1) + + # Checking copy relations + ph = pages[0].placeholders.get(slot='content') + original = ph.get_plugins('en') + pages[0].publish('en') + published = pages[0].get_public_object() + ph = published.placeholders.get(slot='content') + new = ph.get_plugins('en') + self.assertNotEqual(original, new) + + casted_authors, __ = new[0].get_plugin_instance() + self.assertEqual(casted_authors.authors.count(), 3) + def test_plugin_tags(self): pages = self.get_pages() posts = self.get_posts()