Skip to content

Commit

Permalink
Fix E266 (too many # for comment)
Browse files Browse the repository at this point in the history
  • Loading branch information
marksweb committed Aug 2, 2021
1 parent f8e1cd7 commit c89b31c
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 43 deletions.
24 changes: 15 additions & 9 deletions cms/signals/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from django.conf import settings
from django.contrib.auth.models import Group

#################### Our own signals ###################
# ---------------- Our own signals ---------------- #

# fired after page location is changed - is moved from one node to other
page_moved = Signal(providing_args=["instance"])
Expand Down Expand Up @@ -66,7 +66,7 @@
)


################### apphook reloading ###################
# ---------------- apphook reloading ---------------- #

if settings.DEBUG:
urls_need_reloading.connect(debug_server_restart)
Expand All @@ -77,7 +77,7 @@
dispatch_uid='aldryn-apphook-reload-handle-urls-need-reloading'
)

###################### permissions #######################
# ---------------- permissions ---------------- #

if get_cms_setting('PERMISSION'):
# only if permissions are in use
Expand All @@ -96,10 +96,16 @@
signals.pre_delete.connect(pre_delete_group, sender=PageUserGroup, dispatch_uid='cms_pre_delete_pageusergroup')

signals.pre_save.connect(pre_save_pagepermission, sender=PagePermission, dispatch_uid='cms_pre_save_pagepermission')
signals.pre_delete.connect(pre_delete_pagepermission, sender=PagePermission,
dispatch_uid='cms_pre_delete_pagepermission')

signals.pre_save.connect(pre_save_globalpagepermission, sender=GlobalPagePermission,
dispatch_uid='cms_pre_save_globalpagepermission')
signals.pre_delete.connect(pre_delete_globalpagepermission, sender=GlobalPagePermission,
dispatch_uid='cms_pre_delete_globalpagepermission')
signals.pre_delete.connect(
pre_delete_pagepermission, sender=PagePermission,
dispatch_uid='cms_pre_delete_pagepermission'
)
signals.pre_save.connect(
pre_save_globalpagepermission, sender=GlobalPagePermission,
dispatch_uid='cms_pre_save_globalpagepermission'
)
signals.pre_delete.connect(
pre_delete_globalpagepermission, sender=GlobalPagePermission,
dispatch_uid='cms_pre_delete_globalpagepermission'
)
32 changes: 16 additions & 16 deletions cms/tests/test_placeholder.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,9 @@ def test_nested_plugin_escapejs(self):
)
ex.save()
ph1 = ex.placeholder
###
#
# add the test plugin
###
#
test_plugin = add_plugin(ph1, "EmptyPlugin", "en")
test_plugin.save()
endpoint = self.get_change_plugin_uri(test_plugin, container=Example1)
Expand All @@ -288,9 +288,9 @@ def test_nested_plugin_escapejs_page(self):
"""
page = create_page('page', 'col_two.html', 'en')
ph1 = page.placeholders.get(slot='col_left')
###
#
# add the test plugin
###
#
test_plugin = add_plugin(ph1, "EmptyPlugin", "en")
test_plugin.save()

Expand Down Expand Up @@ -491,11 +491,11 @@ def test_plugins_language_fallback(self):
context_de['request'] = self.get_request(language="de", page=page_en)

# First test the default (fallback) behavior)
## English page should have the text plugin
# English page should have the text plugin
content_en = _render_placeholder(placeholder_en, context_en)
self.assertRegexpMatches(content_en, "^en body$")

## Deutsch page have text due to fallback
# Deutsch page have text due to fallback
content_de = _render_placeholder(placeholder_de, context_de)
self.assertRegexpMatches(content_de, "^en body$")
self.assertEqual(len(content_de), 7)
Expand All @@ -507,11 +507,11 @@ def test_plugins_language_fallback(self):
}
# configure non fallback
with self.settings(CMS_PLACEHOLDER_CONF=conf):
## Deutsch page should have no text
# Deutsch page should have no text
del(placeholder_de._plugins_cache)
cache.clear()
content_de = _render_placeholder(placeholder_de, context_de)
## Deutsch page should inherit english content
# Deutsch page should inherit english content
self.assertNotRegex(content_de, "^en body$")
context_de2 = SekizaiContext()
request = self.get_request(language="de", page=page_en)
Expand Down Expand Up @@ -594,12 +594,12 @@ def test_plugins_non_default_language_fallback(self):
context_de['request'] = self.get_request(language="de", page=page_en)

# First test the default (fallback) behavior)
## Deutsch page should have the text plugin
# Deutsch page should have the text plugin
content_de = _render_placeholder(placeholder_en, context_de)
self.assertRegexpMatches(content_de, "^de body$")
del(placeholder_en._plugins_cache)
cache.clear()
## English page should have no text
# English page should have no text
content_en = _render_placeholder(placeholder_en, context_en)
self.assertRegexpMatches(content_en, "^de body$")
self.assertEqual(len(content_en), 7)
Expand All @@ -612,7 +612,7 @@ def test_plugins_non_default_language_fallback(self):
}
# configure non-fallback
with self.settings(CMS_PLACEHOLDER_CONF=conf):
## English page should have deutsch text
# English page should have deutsch text
content_en = _render_placeholder(placeholder_en, context_en)
self.assertNotRegex(content_en, "^de body$")

Expand Down Expand Up @@ -774,14 +774,14 @@ def test_placeholder_languages_model(self):
char_4='four'
)
ex.save()
###
#
# add the test plugin
###
#
for lang in avail_langs:
add_plugin(ex.placeholder, "EmptyPlugin", lang)
# reload instance from database
ex = Example1.objects.get(pk=ex.pk)
#get languages
# get languages
langs = [lang['code'] for lang in ex.placeholder.get_filled_languages()]
self.assertEqual(avail_langs, set(langs))

Expand All @@ -797,9 +797,9 @@ def test_placeholder_languages_page(self):
if lang != 'en':
create_title(lang, 'test page %s' % lang, page)
placeholder = page.placeholders.get(slot='col_sidebar')
###
#
# add the test plugin
###
#
for lang in avail_langs:
add_plugin(placeholder, "EmptyPlugin", lang)
# reload placeholder from database
Expand Down
47 changes: 29 additions & 18 deletions cms/tests/test_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def test_plugin_order(self):
self.assertEqual(db_plugin_1.position, 0)
self.assertEqual(text_plugin_2.position, 1)
self.assertEqual(db_plugin_2.position, 1)
## Finally we render the placeholder to test the actual content
# Finally we render the placeholder to test the actual content
context = self.get_context(page_en.get_absolute_url(), page=page_en)
rendered_placeholder = _render_placeholder(ph_en, context)
self.assertEqual(rendered_placeholder, "I'm the firstI'm the second")
Expand Down Expand Up @@ -346,7 +346,7 @@ def test_plugin_order_alt(self):
self.assertEqual(CMSPlugin.objects.get(pk=text_plugin_2.pk).position, 1)
self.assertEqual(CMSPlugin.objects.get(pk=text_plugin_3.pk).position, 2)

## Finally we render the placeholder to test the actual content
# Finally we render the placeholder to test the actual content
draft_page_context = self.get_context(draft_page.get_absolute_url(), page=draft_page)
rendered_placeholder = _render_placeholder(placeholder, draft_page_context)
self.assertEqual(rendered_placeholder, "I'm the firstI'm the secondI'm the third")
Expand Down Expand Up @@ -1030,13 +1030,15 @@ def test_plugin_toolbar_struct_permissions(self):
def test_plugin_child_classes_from_settings(self):
page = api.create_page("page", "nav_playground.html", "en", published=True)
placeholder = page.placeholders.get(slot='body')
ChildClassesPlugin = type('ChildClassesPlugin', (CMSPluginBase,),
dict(child_classes=['TextPlugin'], render_template='allow_children_plugin.html'))
ChildClassesPlugin = type(
'ChildClassesPlugin', (CMSPluginBase,),
dict(child_classes=['TextPlugin'], render_template='allow_children_plugin.html')
)

with register_plugins(ChildClassesPlugin):
plugin = api.add_plugin(placeholder, ChildClassesPlugin, settings.LANGUAGES[0][0])
plugin = plugin.get_plugin_class_instance()
## assert baseline
# assert baseline
self.assertEqual(['TextPlugin'], plugin.get_child_classes(placeholder.slot, page))

CMS_PLACEHOLDER_CONF = {
Expand All @@ -1053,13 +1055,15 @@ def test_plugin_child_classes_from_settings(self):
def test_plugin_parent_classes_from_settings(self):
page = api.create_page("page", "nav_playground.html", "en", published=True)
placeholder = page.placeholders.get(slot='body')
ParentClassesPlugin = type('ParentClassesPlugin', (CMSPluginBase,),
dict(parent_classes=['TextPlugin'], render_plugin=False))
ParentClassesPlugin = type(
'ParentClassesPlugin', (CMSPluginBase,),
dict(parent_classes=['TextPlugin'], render_plugin=False)
)

with register_plugins(ParentClassesPlugin):
plugin = api.add_plugin(placeholder, ParentClassesPlugin, settings.LANGUAGES[0][0])
plugin = plugin.get_plugin_class_instance()
## assert baseline
# assert baseline
self.assertEqual(['TextPlugin'], plugin.get_parent_classes(placeholder.slot, page))

CMS_PLACEHOLDER_CONF = {
Expand All @@ -1076,31 +1080,38 @@ def test_plugin_parent_classes_from_settings(self):
def test_plugin_parent_classes_from_object(self):
page = api.create_page("page", "nav_playground.html", "en", published=True)
placeholder = page.placeholders.get(slot='body')
ParentPlugin = type('ParentPlugin', (CMSPluginBase,),
dict(render_plugin=False))
ChildPlugin = type('ChildPlugin', (CMSPluginBase,),
dict(parent_classes=['ParentPlugin'], render_plugin=False))
ParentPlugin = type(
'ParentPlugin', (CMSPluginBase,), dict(render_plugin=False)
)
ChildPlugin = type(
'ChildPlugin', (CMSPluginBase,),
dict(parent_classes=['ParentPlugin'], render_plugin=False)
)

with register_plugins(ParentPlugin, ChildPlugin):
plugin = api.add_plugin(placeholder, ParentPlugin, settings.LANGUAGES[0][0])
plugin = plugin.get_plugin_class_instance()
## assert baseline
# assert baseline
child_classes = plugin.get_child_classes(placeholder.slot, page)
self.assertIn('ChildPlugin', child_classes)
self.assertIn('ParentPlugin', child_classes)

def test_plugin_require_parent_from_object(self):
page = api.create_page("page", "nav_playground.html", "en", published=True)
placeholder = page.placeholders.get(slot='body')
ParentPlugin = type('ParentPlugin', (CMSPluginBase,),
dict(render_plugin=False))
ChildPlugin = type('ChildPlugin', (CMSPluginBase,),
dict(require_parent=True, render_plugin=False))
ParentPlugin = type(
'ParentPlugin', (CMSPluginBase,),
dict(render_plugin=False)
)
ChildPlugin = type(
'ChildPlugin', (CMSPluginBase,),
dict(require_parent=True, render_plugin=False)
)

with register_plugins(ParentPlugin, ChildPlugin):
plugin = api.add_plugin(placeholder, ParentPlugin, settings.LANGUAGES[0][0])
plugin = plugin.get_plugin_class_instance()
## assert baseline
# assert baseline
child_classes = plugin.get_child_classes(placeholder.slot, page)
self.assertIn('ChildPlugin', child_classes)
self.assertIn('ParentPlugin', child_classes)
Expand Down

0 comments on commit c89b31c

Please sign in to comment.