Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

trying to create check_plugin_instances tests

  • Loading branch information...
commit 29f2c913d4a8a8a638470b93bbf8fdeed89b37f4 1 parent 71fddb5
@evildmp evildmp authored
Showing with 31 additions and 1 deletion.
  1. +31 −1 cms/tests/check.py
View
32 cms/tests/check.py
@@ -1,9 +1,13 @@
# -*- coding: utf-8 -*-
from __future__ import with_statement
+from StringIO import StringIO
from unittest import TestCase
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
class TestOutput(FileOutputWrapper):
def __init__(self):
@@ -79,3 +83,29 @@ def test_cms_site_languages_deprecated(self):
def test_cms_frontend_languages_deprecated(self):
with SettingsOverride(CMS_FRONTEND_LANGUAGES=True):
self.assertCheck(True, warnings=1, errors=0 )
+
+ def test_check_plugin_instances(self):
+ self.assertCheck(True, warnings=0, errors=0 )
+
+ out = StringIO()
+ apps = ["cms", "menus", "sekizai", "cms.test_utils.project.sampleapp"]
+ with SettingsOverride(INSTALLED_APPS=apps):
+ placeholder = Placeholder.objects.create(slot="test")
+ add_plugin(placeholder, TextPlugin, "en", body="en body")
+ add_plugin(placeholder, TextPlugin, "en", body="en body")
+ link_plugin = add_plugin(placeholder, "LinkPlugin", "en",
+ name="A Link", url="https://www.django-cms.org")
+
+ # create a CMSPlugin with an unsaved instance
+ instanceless_plugin = CMSPlugin(language="en", plugin_type="TextPlugin")
+ instanceless_plugin.save()
+
+ self.assertCheck(False, warnings=0, errors=2)
+
+ # 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)
+
Please sign in to comment.
Something went wrong with that request. Please try again.