Separate testcases
This commit is contained in:
parent
b0bb317be5
commit
547cd9e988
3 changed files with 49 additions and 47 deletions
|
@ -14,7 +14,6 @@ from parler.utils.context import smart_override
|
||||||
from djangocms_blog.cms_appconfig import BlogConfig
|
from djangocms_blog.cms_appconfig import BlogConfig
|
||||||
from djangocms_blog.models import BlogCategory, Post
|
from djangocms_blog.models import BlogCategory, Post
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from filer.models import ThumbnailOption # NOQA
|
from filer.models import ThumbnailOption # NOQA
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|
|
@ -77,50 +77,6 @@ class PluginTest(BaseTest):
|
||||||
self.assertEqual(casted_categories.tags.count(), 0)
|
self.assertEqual(casted_categories.tags.count(), 0)
|
||||||
self.assertEqual(casted_categories.categories.count(), 1)
|
self.assertEqual(casted_categories.categories.count(), 1)
|
||||||
|
|
||||||
def test_plugin_authors(self):
|
|
||||||
pages = self.get_pages()
|
|
||||||
posts = self.get_posts()
|
|
||||||
posts[0].publish = True
|
|
||||||
posts[0].save()
|
|
||||||
posts[1].publish = True
|
|
||||||
posts[1].save()
|
|
||||||
ph = pages[0].placeholders.get(slot='content')
|
|
||||||
plugin = add_plugin(ph, 'BlogAuthorPostsPlugin', language='en', app_config=self.app_config_1)
|
|
||||||
|
|
||||||
context = self.get_plugin_context(pages[0], 'en', plugin, edit=True)
|
|
||||||
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):
|
def test_plugin_tags(self):
|
||||||
pages = self.get_pages()
|
pages = self.get_pages()
|
||||||
posts = self.get_posts()
|
posts = self.get_posts()
|
||||||
|
@ -196,3 +152,50 @@ class PluginTest(BaseTest):
|
||||||
self.assertEqual(plugin_class.get_render_template(context, plugin, ph), os.path.join('whatever', plugin_class.base_render_template))
|
self.assertEqual(plugin_class.get_render_template(context, plugin, ph), os.path.join('whatever', plugin_class.base_render_template))
|
||||||
self.app_config_1.app_data.config.template_prefix = ''
|
self.app_config_1.app_data.config.template_prefix = ''
|
||||||
self.app_config_1.save()
|
self.app_config_1.save()
|
||||||
|
|
||||||
|
|
||||||
|
class PluginTest2(BaseTest):
|
||||||
|
|
||||||
|
def test_plugin_authors(self):
|
||||||
|
pages = self.get_pages()
|
||||||
|
posts = self.get_posts()
|
||||||
|
posts[0].publish = True
|
||||||
|
posts[0].save()
|
||||||
|
posts[1].publish = True
|
||||||
|
posts[1].save()
|
||||||
|
ph = pages[0].placeholders.get(slot='content')
|
||||||
|
plugin = add_plugin(ph, 'BlogAuthorPostsPlugin', language='en', app_config=self.app_config_1)
|
||||||
|
|
||||||
|
context = self.get_plugin_context(pages[0], 'en', plugin, edit=True)
|
||||||
|
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)
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
from __future__ import absolute_import, print_function, unicode_literals
|
from __future__ import absolute_import, print_function, unicode_literals
|
||||||
|
|
||||||
import os.path
|
import os.path
|
||||||
from django.utils.encoding import force_text
|
|
||||||
|
|
||||||
from aldryn_apphooks_config.utils import get_app_instance
|
from aldryn_apphooks_config.utils import get_app_instance
|
||||||
from cms.toolbar.items import ModalItem
|
from cms.toolbar.items import ModalItem
|
||||||
|
@ -10,13 +9,14 @@ from django.contrib.auth.models import AnonymousUser
|
||||||
from django.core.exceptions import ImproperlyConfigured
|
from django.core.exceptions import ImproperlyConfigured
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from django.http import Http404
|
from django.http import Http404
|
||||||
|
from django.utils.encoding import force_text
|
||||||
from django.utils.timezone import now
|
from django.utils.timezone import now
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from parler.tests.utils import override_parler_settings
|
from parler.tests.utils import override_parler_settings
|
||||||
from parler.utils.conf import add_default_language_settings
|
from parler.utils.conf import add_default_language_settings
|
||||||
from parler.utils.context import smart_override, switch_language
|
from parler.utils.context import smart_override, switch_language
|
||||||
|
|
||||||
from djangocms_blog.feeds import LatestEntriesFeed, TagFeed, FBInstantArticles
|
from djangocms_blog.feeds import FBInstantArticles, LatestEntriesFeed, TagFeed
|
||||||
from djangocms_blog.models import BLOG_CURRENT_NAMESPACE
|
from djangocms_blog.models import BLOG_CURRENT_NAMESPACE
|
||||||
from djangocms_blog.settings import get_setting
|
from djangocms_blog.settings import get_setting
|
||||||
from djangocms_blog.sitemaps import BlogSitemap
|
from djangocms_blog.sitemaps import BlogSitemap
|
||||||
|
|
Loading…
Add table
Reference in a new issue