From 3cd87cd1d2b5b990de822fc2e802e32e5b9bcc6f Mon Sep 17 00:00:00 2001 From: Jonas Obrist Date: Thu, 17 Jan 2013 22:27:51 +0900 Subject: [PATCH] split cms.tests.check into two classes --- cms/tests/check.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/cms/tests/check.py b/cms/tests/check.py index 8489c282189..efcfe124104 100644 --- a/cms/tests/check.py +++ b/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) -