Skip to content
Browse files

split cms.tests.check into two classes

  • Loading branch information...
1 parent 29f2c91 commit 3cd87cd1d2b5b990de822fc2e802e32e5b9bcc6f @ojii ojii committed Jan 17, 2013
Showing with 11 additions and 8 deletions.
  1. +11 −8 cms/tests/check.py
View
19 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):
@@ -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
@@ -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)
@@ -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")
@@ -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 3cd87cd

Please sign in to comment.
Something went wrong with that request. Please try again.