Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #1 from ojii/evildmp-check-plugins
split cms.tests.check into two classes
  • Loading branch information
evildmp committed Jan 17, 2013
2 parents 29f2c91 + 3cd87cd commit 646d65b
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions cms/tests/check.py
@@ -1,13 +1,13 @@
# -*- coding: utf-8 -*-
from __future__ import with_statement
from StringIO import StringIO
from unittest import TestCase
import unittest
from cms.test_utils.util.context_managers import SettingsOverride
from cms.utils.check import FileOutputWrapper, check, FileSectionWrapper
from cms.models.pluginmodel import CMSPlugin
from cms.models.placeholdermodel import Placeholder
from cms.plugins.text.cms_plugins import TextPlugin
from cms.api import add_plugin
from django.test import TestCase

class TestOutput(FileOutputWrapper):
def __init__(self):
Expand All @@ -29,7 +29,7 @@ def write_stderr(self, message):
pass


class CheckTests(TestCase):
class CheckAssertMixin(object):
def assertCheck(self, successful, **assertions):
"""
asserts that checks are successful or not
Expand All @@ -41,6 +41,8 @@ def assertCheck(self, successful, **assertions):
for key, value in assertions.items():
self.assertEqual(getattr(output, key), value, "%s %s expected, got %s" % (value, key, getattr(output, key)))


class CheckTests(unittest.TestCase, CheckAssertMixin):
def test_test_confs(self):
self.assertCheck(True, errors=0, warnings=0)

Expand Down Expand Up @@ -84,10 +86,12 @@ def test_cms_frontend_languages_deprecated(self):
with SettingsOverride(CMS_FRONTEND_LANGUAGES=True):
self.assertCheck(True, warnings=1, errors=0 )


class CheckWithDatabaseTests(TestCase, CheckAssertMixin):

def test_check_plugin_instances(self):
self.assertCheck(True, warnings=0, errors=0 )

out = StringIO()
self.assertCheck(True, warnings=0, errors=0 )

apps = ["cms", "menus", "sekizai", "cms.test_utils.project.sampleapp"]
with SettingsOverride(INSTALLED_APPS=apps):
placeholder = Placeholder.objects.create(slot="test")
Expand All @@ -102,10 +106,9 @@ def test_check_plugin_instances(self):

self.assertCheck(False, warnings=0, errors=2)

# create a bogus CMSPlugin to simulate one which used to exist but
# create a bogus CMSPlugin to simulate one which used to exist but
# is no longer installed
bogus_plugin = CMSPlugin(language="en", plugin_type="BogusPlugin")
bogus_plugin.save()

self.assertCheck(False, warnings=0, errors=3)

0 comments on commit 646d65b

Please sign in to comment.