Browse files

Minor tidy of source code (remove spaces at end of lines, …).

  • Loading branch information...
1 parent 593422e commit bf3cc87f891d36b40834d0fa22f8068c3b4d4989 @richardbarran committed Oct 8, 2012
Showing with 57 additions and 57 deletions.
  1. +57 −57 cms/tests/plugins.py
View
114 cms/tests/plugins.py
@@ -12,13 +12,13 @@
from cms.plugins.link.forms import LinkForm
from cms.plugins.link.models import Link
from cms.plugins.text.models import Text
-from cms.plugins.text.utils import (plugin_tags_to_id_list,
+from cms.plugins.text.utils import (plugin_tags_to_id_list,
plugin_tags_to_admin_html)
from cms.plugins.twitter.models import TwitterRecentEntries
from cms.test_utils.project.pluginapp.models import Article, Section
from cms.test_utils.project.pluginapp.plugins.manytomany_rel.models import (
ArticlePluginModel)
-from cms.test_utils.testcases import (CMSTestCase, URL_CMS_PAGE,
+from cms.test_utils.testcases import (CMSTestCase, URL_CMS_PAGE,
URL_CMS_PAGE_ADD, URL_CMS_PLUGIN_ADD, URL_CMS_PLUGIN_EDIT, URL_CMS_PAGE_CHANGE, URL_CMS_PLUGIN_REMOVE, URL_CMS_PLUGIN_HISTORY_EDIT)
from cms.sitemaps.cms_sitemap import CMSSitemap
from cms.test_utils.util.context_managers import SettingsOverride
@@ -46,7 +46,7 @@ def render(self, context, instance, placeholder):
class PluginsTestBaseCase(CMSTestCase):
def setUp(self):
- self.super_user = User(username="test", is_staff = True, is_active = True, is_superuser = True)
+ self.super_user = User(username="test", is_staff=True, is_active=True, is_superuser=True)
self.super_user.set_password("test")
self.super_user.save()
@@ -57,10 +57,10 @@ def setUp(self):
self.FIRST_LANG = settings.LANGUAGES[0][0]
self.SECOND_LANG = settings.LANGUAGES[1][0]
-
+
self._login_context = self.login_user_context(self.super_user)
self._login_context.__enter__()
-
+
def tearDown(self):
self._login_context.__exit__(None, None, None)
@@ -91,7 +91,7 @@ def _create_text_plugin_on_page(self, page):
return created_plugin_id
def _edit_text_plugin(self, plugin_id, text):
- edit_url = "%s%s/" % (URL_CMS_PLUGIN_EDIT, plugin_id)
+ edit_url = "%s%s/" % (URL_CMS_PLUGIN_EDIT, plugin_id)
response = self.client.get(edit_url)
self.assertEquals(response.status_code, 200)
data = {
@@ -156,7 +156,7 @@ def test_plugin_order(self):
Test that plugin position is saved after creation
"""
page_en = create_page("PluginOrderPage", "col_two.html", "en",
- slug="page1",published=True, in_navigation=True)
+ slug="page1", published=True, in_navigation=True)
ph_en = page_en.placeholders.get(slot="col_left")
# We check created objects and objects from the DB to be sure the position value
@@ -167,13 +167,13 @@ def test_plugin_order(self):
db_plugin_2 = CMSPlugin.objects.get(pk=text_plugin_2.pk)
with SettingsOverride(CMS_MODERATOR=False, CMS_PERMISSION=False):
- self.assertEqual(text_plugin_1.position,1)
- self.assertEqual(db_plugin_1.position,1)
- self.assertEqual(text_plugin_2.position,2)
- self.assertEqual(db_plugin_2.position,2)
+ self.assertEqual(text_plugin_1.position, 1)
+ self.assertEqual(db_plugin_1.position, 1)
+ self.assertEqual(text_plugin_2.position, 2)
+ self.assertEqual(db_plugin_2.position, 2)
## Finally we render the placeholder to test the actual content
- rendered_placeholder = ph_en.render(self.get_context(page_en.get_absolute_url()),None)
- self.assertEquals(rendered_placeholder,"I'm the firstI'm the second")
+ rendered_placeholder = ph_en.render(self.get_context(page_en.get_absolute_url()), None)
+ self.assertEquals(rendered_placeholder, "I'm the firstI'm the second")
def test_add_cancel_plugin(self):
"""
@@ -269,54 +269,54 @@ def test_copy_plugins(self):
page_de = create_page("CopyPluginTestPage (DE)", "nav_playground.html", "de")
ph_en = page_en.placeholders.get(slot="body")
ph_de = page_de.placeholders.get(slot="body")
-
+
# add the text plugin
text_plugin_en = add_plugin(ph_en, "TextPlugin", "en", body="Hello World")
self.assertEquals(text_plugin_en.pk, CMSPlugin.objects.all()[0].pk)
-
+
# add a *nested* link plugin
link_plugin_en = add_plugin(ph_en, "LinkPlugin", "en", target=text_plugin_en,
name="A Link", url="https://www.django-cms.org")
-
+
# the call above to add a child makes a plugin reload required here.
text_plugin_en = self.reload(text_plugin_en)
-
+
# check the relations
self.assertEquals(text_plugin_en.get_children().count(), 1)
self.assertEqual(link_plugin_en.parent.pk, text_plugin_en.pk)
-
+
# just sanity check that so far everything went well
self.assertEqual(CMSPlugin.objects.count(), 2)
-
+
# copy the plugins to the german placeholder
copy_plugins_to(ph_en.cmsplugin_set.all(), ph_de, 'de')
-
+
self.assertEqual(ph_de.cmsplugin_set.filter(parent=None).count(), 1)
text_plugin_de = ph_de.cmsplugin_set.get(parent=None).get_plugin_instance()[0]
self.assertEqual(text_plugin_de.get_children().count(), 1)
link_plugin_de = text_plugin_de.get_children().get().get_plugin_instance()[0]
-
-
+
+
# check we have twice as many plugins as before
self.assertEqual(CMSPlugin.objects.count(), 4)
-
+
# check language plugins
self.assertEqual(CMSPlugin.objects.filter(language='de').count(), 2)
self.assertEqual(CMSPlugin.objects.filter(language='en').count(), 2)
-
-
+
+
text_plugin_en = self.reload(text_plugin_en)
link_plugin_en = self.reload(link_plugin_en)
-
+
# check the relations in english didn't change
self.assertEquals(text_plugin_en.get_children().count(), 1)
self.assertEqual(link_plugin_en.parent.pk, text_plugin_en.pk)
-
+
self.assertEqual(link_plugin_de.name, link_plugin_en.name)
self.assertEqual(link_plugin_de.url, link_plugin_en.url)
-
+
self.assertEqual(text_plugin_de.body, text_plugin_en.body)
-
+
def test_remove_plugin_before_published(self):
"""
@@ -452,7 +452,7 @@ def test_unregister_non_existing_plugin_should_raise(self):
# Let's count, to make sure we didn't remove a plugin accidentally.
number_of_plugins_after = len(plugin_pool.get_all_plugins())
self.assertEqual(number_of_plugins_before, number_of_plugins_after)
-
+
def test_inheritplugin_media(self):
"""
Test case for InheritPagePlaceholder
@@ -461,34 +461,34 @@ def test_inheritplugin_media(self):
inheritfrompage = create_page('page to inherit from',
'nav_playground.html',
'en')
-
+
body = inheritfrompage.placeholders.get(slot="body")
-
+
plugin = TwitterRecentEntries(
plugin_type='TwitterRecentEntriesPlugin',
- placeholder=body,
- position=1,
+ placeholder=body,
+ position=1,
language=settings.LANGUAGE_CODE,
twitter_user='djangocms',
)
plugin.insert_at(None, position='last-child', save=True)
-
+
page = create_page('inherit from page',
'nav_playground.html',
'en',
published=True)
-
+
inherited_body = page.placeholders.get(slot="body")
-
+
inherit_plugin = InheritPagePlaceholder(
plugin_type='InheritPagePlaceholderPlugin',
- placeholder=inherited_body,
- position=1,
+ placeholder=inherited_body,
+ position=1,
language=settings.LANGUAGE_CODE,
from_page=inheritfrompage,
from_language=settings.LANGUAGE_CODE)
inherit_plugin.insert_at(None, position='last-child', save=True)
-
+
self.client.logout()
response = self.client.get(page.get_absolute_url())
self.assertTrue('%scms/js/libs/jquery.tweet.js' % settings.STATIC_URL in response.content, response.content)
@@ -531,7 +531,7 @@ def test_copy_textplugin(self):
Test that copying of textplugins replaces references to copied plugins
"""
page = create_page("page", "nav_playground.html", "en")
-
+
placeholder = page.placeholders.get(slot='body')
plugin_base = CMSPlugin(
@@ -639,7 +639,7 @@ class FileSystemPluginTests(PluginsTestBaseCase):
def setUp(self):
super(FileSystemPluginTests, self).setUp()
call_command('collectstatic', interactive=False, verbosity=0, link=True)
-
+
def tearDown(self):
for directory in [settings.STATIC_ROOT, settings.MEDIA_ROOT]:
for root, dirs, files in os.walk(directory, topdown=False):
@@ -652,10 +652,10 @@ def tearDown(self):
# Now all directories we walked...
os.rmdir(os.path.join(root, name))
super(FileSystemPluginTests, self).tearDown()
-
+
def test_fileplugin_icon_uppercase(self):
page = create_page('testpage', 'nav_playground.html', 'en')
- body = page.placeholders.get(slot="body")
+ body = page.placeholders.get(slot="body")
plugin = File(
plugin_type='FilePlugin',
placeholder=body,
@@ -672,22 +672,22 @@ def test_fileplugin_icon_uppercase(self):
class PluginManyToManyTestCase(PluginsTestBaseCase):
def setUp(self):
- self.super_user = User(username="test", is_staff = True, is_active = True, is_superuser = True)
+ self.super_user = User(username="test", is_staff=True, is_active=True, is_superuser=True)
self.super_user.set_password("test")
self.super_user.save()
self.slave = User(username="slave", is_staff=True, is_active=True, is_superuser=False)
self.slave.set_password("slave")
self.slave.save()
-
+
self._login_context = self.login_user_context(self.super_user)
self._login_context.__enter__()
-
+
# create 3 sections
self.sections = []
self.section_pks = []
for i in range(3):
- section = Section.objects.create(name="section %s" %i)
+ section = Section.objects.create(name="section %s" % i)
self.sections.append(section)
self.section_pks.append(section.pk)
self.section_count = len(self.sections)
@@ -700,7 +700,7 @@ def setUp(self):
)
self.FIRST_LANG = settings.LANGUAGES[0][0]
self.SECOND_LANG = settings.LANGUAGES[1][0]
-
+
def test_add_plugin_with_m2m(self):
# add a new text plugin
page_data = self.get_new_page_data()
@@ -779,7 +779,7 @@ def test_add_plugin_with_m2m_and_publisher(self):
def test_copy_plugin_with_m2m(self):
page = create_page("page", "nav_playground.html", "en")
-
+
placeholder = page.placeholders.get(slot='body')
plugin = ArticlePluginModel(
@@ -899,7 +899,7 @@ class Meta:
class SekizaiTests(TestCase):
def test_post_patch_check(self):
post_patch_check()
-
+
def test_fail(self):
with SettingsOverride(CMS_TEMPLATES=[('fail.html', 'fail')]):
self.assertRaises(ImproperlyConfigured, post_patch_check)
@@ -948,28 +948,28 @@ def test_render_meta_is_unique(self):
text = Text()
link = Link()
self.assertNotEqual(id(text._render_meta), id(link._render_meta))
-
+
def test_render_meta_does_not_leak(self):
text = Text()
link = Link()
-
+
text._render_meta.text_enabled = False
link._render_meta.text_enabled = False
-
+
self.assertFalse(text._render_meta.text_enabled)
self.assertFalse(link._render_meta.text_enabled)
-
+
link._render_meta.text_enabled = True
self.assertFalse(text._render_meta.text_enabled)
self.assertTrue(link._render_meta.text_enabled)
-
+
def test_db_table_hack(self):
# TODO: Django tests seem to leak models from test methods, somehow
# we should clear django.db.models.loading.app_cache in tearDown.
plugin_class = PluginModelBase('TestPlugin', (CMSPlugin,), {'__module__': 'cms.tests.plugins'})
self.assertEqual(plugin_class._meta.db_table, 'cmsplugin_testplugin')
-
+
def test_db_table_hack_with_mixin(self):
class LeftMixin: pass
class RightMixin: pass

0 comments on commit bf3cc87

Please sign in to comment.