Skip to content

Commit

Permalink
Flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
hvelarde committed Jun 29, 2015
1 parent c2a4be1 commit 4efb8de
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 57 deletions.
63 changes: 33 additions & 30 deletions src/webcouturier/dropdownmenu/browser/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,54 +9,57 @@ class IDropdownConfiguration(Interface):
"""This interface defines the configlet for dropdown menus."""

dropdown_depth = schema.Int(
title=_(u"label_dropdown_depth", default=u'Depth of dropdown menus'),
description=_(u"help_dropdown_depth",
title=_(u'label_dropdown_depth', default=u'Depth of dropdown menus'),
description=_(u'help_dropdown_depth',
default=u'How many levels to list after the top level.'),
required=True,
default=3)
default=3
)

enable_caching = schema.Bool(
title=_(u"label_enable_caching", default=u"Enable caching"),
title=_(u'label_enable_caching', default=u'Enable caching'),
description=_(
u"help_enable_caching",
default=(u"WARNING! This is an experimental feature. "
u"This is using RAM to store cached template for "
u"dropdown menus. Technically every user and "
u"every visited section gets its own instance "
u'help_enable_caching',
default=(u'WARNING! This is an experimental feature. '
u'This is using RAM to store cached template for '
u'dropdown menus. Technically every user and '
u'every visited section gets its own instance '
u"in the ram.cache. Don't enable this if you don't "
u"know what this is about. Disable this option "
u"if you get unexpected behavior of your global tabs.")),
u'know what this is about. Disable this option '
u'if you get unexpected behavior of your global tabs.')),
default=False,
required=False)
required=False
)

enable_parent_clickable = schema.Bool(
title=_(u"label_enable_parent_clickable",
default=u"Enable clicking menu items that have children"),
title=_(u'label_enable_parent_clickable',
default=u'Enable clicking menu items that have children'),
description=_(
u"help_enable_parent_clickable",
default=(u"With this option enabled, every menu item is "
u"clickable. With this option disabled, an item is only "
u"clickable when it is not a parent so it has no "
u"children.")),
u'help_enable_parent_clickable',
default=(u'With this option enabled, every menu item is '
u'clickable. With this option disabled, an item is only '
u'clickable when it is not a parent so it has no '
u'children.')),
default=True,
required=False)
required=False
)

enable_desc = schema.Bool(
title=_(u"label_enable_desc",
default=u"Show Description"),
title=_(u'label_enable_desc',
default=u'Show Description'),
description=_(
u"help_desc",
default=(u"With this option enabled, description is also shown.")),
u'help_desc',
default=(u'With this option enabled, description is also shown.')),
default=True,
required=False)
required=False
)

enable_thumbs = schema.Choice(
title=_(u"label_size", default=u"Size"),
description=_(u"description_size",
default=u"The size of the icon"),
title=_(u'label_size', default=u'Size'),
description=_(u'description_size', default=u'The size of the icon'),
default='None',
vocabulary="webcouturier.dropdownmenu.SizeVocabulary",
)
vocabulary='webcouturier.dropdownmenu.SizeVocabulary',
)


class IDropdownSpecific(IDefaultPloneLayer):
Expand Down
64 changes: 39 additions & 25 deletions src/webcouturier/dropdownmenu/tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,21 @@ def setUp(self):
self.ps = propertiesTool

def test_control_panel(self):
cp = getToolByName(self.portal, "portal_controlpanel")
self.assertIn('DropdownConfiguration', [a.getAction(self)['id']
for a in cp.listActions()])
cp = getToolByName(self.portal, 'portal_controlpanel')
self.assertIn(
'DropdownConfiguration',
[a.getAction(self)['id'] for a in cp.listActions()]
)

def test_property_sheet_availability(self):
self.assertIn('dropdown_properties', self.ps.objectIds())

def test_settings_available(self):
settings = ['dropdown_depth',
'enable_caching',
'enable_parent_clickable']
settings = [
'dropdown_depth',
'enable_caching',
'enable_parent_clickable'
]
for setting in settings:
self.assertTrue(self.dmprops.hasProperty(setting))

Expand All @@ -59,8 +63,10 @@ def setUp(self):
viewlet.update()

for folder_id in self.root_folders_ids:
self.assertIn(folder_id, [tab['id'] for tab in
viewlet.portal_tabs])
self.assertIn(
folder_id,
[tab['id'] for tab in viewlet.portal_tabs]
)

setRoles(portal, TEST_USER_ID, ['Member'])
self.portal = portal
Expand All @@ -84,23 +90,27 @@ def test_no_subfolders_without_content(self):

def test_dropdownmenus_available(self):
rf_url = self.addSubFolders()
self.assertNotEqual(self.viewlet.getTabObject(rf_url), '',
"We don't have the sub-folders available in the \
global navigation")
self.assertNotEqual(
self.viewlet.getTabObject(rf_url),
'',
"We don't have the sub-folders available in the global navigation"
)

def test_subfolders_in_dropdownmenus(self):
rf_url = self.addSubFolders()
self.assertIn('<a href="http://nohost/plone/folder-0/sub-0"',
self.viewlet.getTabObject(rf_url),
"The sub-folder's URL is not available in the \
global navigation")
self.assertIn(
'<a href="http://nohost/plone/folder-0/sub-0"',
self.viewlet.getTabObject(rf_url),
"The sub-folder's URL is not available in the global navigation"
)

def test_leaks_in_dropdownmenus(self):
rf_url = self.addSubFolders()
self.assertNotIn('<a href="http://nohost/plone/folder-0"',
self.viewlet.getTabObject(rf_url),
"We have the leakage of the top level folders in the \
dropdownmenus")
self.assertNotIn(
'<a href="http://nohost/plone/folder-0"',
self.viewlet.getTabObject(rf_url),
'We have the leakage of the top level folders in the dropdownmenus'
)


class TestINavigationRootDropdownmenu(unittest.TestCase):
Expand All @@ -127,12 +137,16 @@ def setUp(self):
self.rf_url = self.f1.absolute_url()

def test_no_root_folder(self):
self.assertNotIn('<a href="http://nohost/plone/folder-0"',
self.viewlet.getTabObject(self.rf_url),
"The root folder itself is in the globalnavigation")
self.assertNotIn(
'<a href="http://nohost/plone/folder-0"',
self.viewlet.getTabObject(self.rf_url),
'The root folder itself is in the globalnavigation'
)

def test_dropdownmenus_content(self):
# Tests the tree builder to aply nice with the INavigationRoot
self.assertNotIn('<a href="http://nohost/plone/folder-1"',
self.viewlet.getTabObject(self.rf_url),
"The dropdown menus don't respect the iNavigationRoot.")
self.assertNotIn(
'<a href="http://nohost/plone/folder-1"',
self.viewlet.getTabObject(self.rf_url),
"The dropdown menus don't respect the iNavigationRoot."
)
2 changes: 1 addition & 1 deletion src/webcouturier/dropdownmenu/upgrades.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def upgrade_1000_to_1010(context):
dds = layers.index('dropdownmenu_sunburst')
dd = layers.index('dropdownmenu')
if dds > dd:
#switch them
# switch them
layers[dd] = 'dropdownmenu_sunburst'
layers[dds] = 'dropdownmenu'
path = ','.join(layers)
Expand Down
2 changes: 1 addition & 1 deletion src/webcouturier/dropdownmenu/vocabularies.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ def SizeVocabulary(context):
token=format_size(pair),
title=pair) for pair in sizes
if not format_size(pair) in ['preview', 'large']]
image_terms =image_terms + terms
image_terms = image_terms + terms

return SimpleVocabulary(image_terms)

0 comments on commit 4efb8de

Please sign in to comment.