From 7c109a9b6c85a0691af5320484286fa5c38d3e60 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Wed, 11 Jun 2014 18:48:58 +0200 Subject: [PATCH] More tests --- tests/test_plugins.py | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/tests/test_plugins.py b/tests/test_plugins.py index 7461957..5ea60c1 100644 --- a/tests/test_plugins.py +++ b/tests/test_plugins.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +from datetime import date import re from cms.api import add_plugin from django.core.urlresolvers import reverse @@ -69,4 +70,38 @@ class PluginTest(BaseTest): else: rf = '\s+%s\s+\(\s+%s article' % (tag.name, 1) rx = re.compile(rf) - self.assertEqual(len(rx.findall(rendered)), 1) \ No newline at end of file + self.assertEqual(len(rx.findall(rendered)), 1) + + def test_blog_category_plugin(self): + page1, page2 = self.get_pages() + post1, post2 = self.get_posts() + post1.publish = True + post1.save() + post2.publish = True + post2.save() + ph = page1.placeholders.get(slot='placeholder') + plugin = add_plugin(ph, 'BlogCategoryPlugin', language='en') + request = self.get_page_request(page1, self.user, r'/en/blog/', lang_code='en', edit=True) + plugin_class = plugin.get_plugin_class_instance() + context = plugin_class.render(RequestContext(request, {}), plugin, ph) + self.assertTrue(context['categories']) + self.assertEqual(list(context['categories']), [self.category_1]) + + def test_blog_archive_plugin(self): + page1, page2 = self.get_pages() + post1, post2 = self.get_posts() + post1.publish = True + post1.save() + post2.publish = True + post2.save() + ph = page1.placeholders.get(slot='placeholder') + plugin = add_plugin(ph, 'BlogArchivePlugin', language='en') + request = self.get_page_request(page1, self.user, r'/en/blog/', lang_code='en', edit=True) + plugin_class = plugin.get_plugin_class_instance() + context = plugin_class.render(RequestContext(request, {}), plugin, ph) + self.assertEqual(context['dates'][0], {'date': date(year=date.today().year, month=date.today().month, day=1), 'count': 2}) + + post2.publish = False + post2.save() + context = plugin_class.render(RequestContext(request, {}), plugin, ph) + self.assertEqual(context['dates'][0], {'date': date(year=date.today().year, month=date.today().month, day=1), 'count': 1})