Skip to content

Commit

Permalink
make code-analysis happy
Browse files Browse the repository at this point in the history
Conflicts:
	plone/app/contenttypes/tests/test_setup.py
  • Loading branch information
pbauer committed Jan 22, 2015
1 parent 318e778 commit 849727d
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 23 deletions.
1 change: 1 addition & 0 deletions plone/app/contenttypes/browser/file.py
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from plone.app.contenttypes.browser.utils import Utils


Expand Down
1 change: 1 addition & 0 deletions plone/app/contenttypes/migration/__init__.py
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import pytz


Expand Down
6 changes: 3 additions & 3 deletions plone/app/contenttypes/migration/browser.py
Expand Up @@ -516,7 +516,8 @@ class FolderishCollection(Container):
<?xml version="1.0"?>
<object name="Collection" meta_type="Dexterity FTI">
<property name="klass">my.package.content.FolderishCollection</property>
<property name="klass">my.package.content.FolderishCollection
</property>
</object>
"""
Expand All @@ -528,7 +529,7 @@ class FolderishCollection(Container):
behavior = 'plone.app.contenttypes.behaviors.collection.ICollection'
if fti and behavior in fti.behaviors:
logger.warn("You are trying to migrate topic to collection. "
"Instead you need a type 'Collection'.")
"Instead you need a type 'Collection'.")

def has_contentleadimage(self):
return HAS_CONTENTLEADIMAGE
Expand All @@ -540,7 +541,6 @@ def installed_types(self):
results['installed_without_behavior'] = []
results['not_installed'] = []
behavior = 'plone.app.contenttypes.behaviors.leadimage.ILeadImage'
portal_types = getToolByName(self.context, 'portal_types')
for type_name in DEFAULT_TYPES:
fti = queryUtility(IDexterityFTI, name=type_name)
if fti:
Expand Down
2 changes: 0 additions & 2 deletions plone/app/contenttypes/migration/dxmigration.py
Expand Up @@ -6,8 +6,6 @@
from plone.app.contenttypes.interfaces import IEvent
from plone.app.contenttypes.migration import datetime_fixer
from plone.app.contenttypes.migration.utils import HAS_MULTILINGUAL
from plone.dexterity.content import Container
from plone.dexterity.content import Item
from plone.dexterity.interfaces import IDexterityContent
from plone.dexterity.interfaces import IDexterityFTI
from plone.event.utils import default_timezone
Expand Down
5 changes: 3 additions & 2 deletions plone/app/contenttypes/migration/migration.py
Expand Up @@ -63,7 +63,7 @@ def migrate_portlets(src_obj, dst_obj):
"""

# also take custom portlet managers into account
managers = [reg.name for reg in getSiteManager().registeredUtilities() \
managers = [reg.name for reg in getSiteManager().registeredUtilities()
if reg.provided == IPortletManager]
# faster, but no custom managers
# managers = [u'plone.leftcolumn', u'plone.rightcolumn']
Expand All @@ -86,7 +86,8 @@ def migrate_portlets(src_obj, dst_obj):
if not hasattr(assignment, '__Broken_state__'):
add_portlet(dst_obj, assignment, key, manager)
else:
logger.warn(u'skipping broken portlet assignment {0} for manager {1}'.format(key, manager))
logger.warn(u'skipping broken portlet assignment {0} '
'for manager {1}'.format(key, manager))


def refs(obj):
Expand Down
5 changes: 1 addition & 4 deletions plone/app/contenttypes/migration/topics.py
Expand Up @@ -9,7 +9,6 @@
"""

from DateTime import DateTime
from Products.CMFCore.interfaces._content import IFolderish
from Products.CMFCore.utils import getToolByName
from Products.contentmigration.inplace import InplaceCMFFolderMigrator
from Products.contentmigration.inplace import InplaceCMFItemMigrator
Expand All @@ -30,8 +29,8 @@

INVALID_OPERATION = 'Invalid operation %s for criterion: %s'

# Converters

# Converters
class CriterionConverter(object):

# Last part of the code for the dotted operation method,
Expand Down Expand Up @@ -536,7 +535,6 @@ def migrate_criteria(self):
if self._collection_query is not None:
adapted.query = self._collection_query


def migrate_atctmetadata(self):
field = self.old.getField('excludeFromNav')
self.new.exclude_from_nav = field.get(self.old)
Expand Down Expand Up @@ -649,7 +647,6 @@ def migrate_criteria(self):
if self._collection_query is not None:
adapted.query = self._collection_query


def migrate_atctmetadata(self):
field = self.old.getField('excludeFromNav')
self.new.exclude_from_nav = field.get(self.old)
Expand Down
3 changes: 3 additions & 0 deletions plone/app/contenttypes/migration/utils.py
Expand Up @@ -129,6 +129,7 @@ def add_portlet(context, assignment, portlet_key, columnName):
IPortletAssignmentMapping)
assignmentmapping[portlet_key] = assignment


def move_comments(source_object, target_object):
"""Move comments by copying the annotation to the target
and then removing the comments from the source (not the annotation).
Expand All @@ -146,6 +147,7 @@ def move_comments(source_object, target_object):
del source_conversation[comment.comment_id]
del source_annotations[DISCUSSION_KEY]


def copy_contentrules(source_object, target_object):
"""Copy contentrules.
"""
Expand All @@ -160,6 +162,7 @@ def copy_contentrules(source_object, target_object):
for rule_id in source_assignable:
assign_rule(target_object, rule_id)


def migrate_leadimage(source_object, target_object):
""" Migrate images added using collective.contentleadimage to the
ILeadImage-behavior of plone.app.contenttypes if it is enabled.
Expand Down
3 changes: 2 additions & 1 deletion plone/app/contenttypes/migration/vocabularies.py
Expand Up @@ -225,6 +225,7 @@ def __call__(self, context):
return SimpleVocabulary(
[SimpleVocabulary.createTerm(
class_name, class_name,
'{0} ({1})'.format(class_name, list_of_class_names[class_name]))
'{0} ({1})'.format(
class_name, list_of_class_names[class_name]))
for class_name in list_of_class_names.keys()]
)
9 changes: 5 additions & 4 deletions plone/app/contenttypes/testing.py
Expand Up @@ -45,12 +45,13 @@ def setUpZope(self, app, configurationContext):
def setUpPloneSite(self, portal):
applyProfile(portal, 'plone.app.contenttypes:default')

# install and enable referenceablebehavior on Documents to be able to test
# controlpanel to enable plone.app.linkintegrity checks
# install and enable referenceablebehavior on Documents to be able to
# test controlpanel to enable plone.app.linkintegrity checks
# XXX Disabled as it is causing test errors in comments
# see https://github.com/plone/Products.CMFPlone/issues/255
#applyProfile(portal, 'plone.app.referenceablebehavior:default')
#portal.portal_types.Document.behaviors += ('plone.app.referenceablebehavior.referenceable.IReferenceable',)
# applyProfile(portal, 'plone.app.referenceablebehavior:default')
# portal.portal_types.Document.behaviors += \
# ('plone.app.referenceablebehavior.referenceable.IReferenceable',)

mtr = portal.mimetypes_registry
mime_doc = mtr.lookup('application/msword')[0]
Expand Down
9 changes: 5 additions & 4 deletions plone/app/contenttypes/tests/test_migration.py
Expand Up @@ -1293,7 +1293,6 @@ def test_migration_view_confirmation(self):
results = migration_view()
self.assertIn('@@migrate_from_atct?migrate=1', results)


def test_portlets_are_migrated(self):
"""add portlets and see if they're still available on the migrated
content including portlet settings.
Expand Down Expand Up @@ -1350,7 +1349,7 @@ def get_portlets(context, columnName):

# add a portlet to the folder
portlet2 = StaticAssignment(u"Sample Folder Portlet",
"<p>Do I get migrated?</p>")
"<p>Do I get migrated?</p>")
add_portlet(at_folder, portlet2, 'static-portlet',
u'plone.rightcolumn')

Expand Down Expand Up @@ -1473,14 +1472,16 @@ def test_dxmigration_migrate_item_to_container_add_object_inside(self):
migrate_base_class_to_new_class
migrate_base_class_to_new_class(self.portal.item)
self.portal.item.invokeFactory('Document', 'doc')
self.assertEqual(len(self.portal.item.folderlistingFolderContents()), 1)
self.assertEqual(
len(self.portal.item.folderlistingFolderContents()), 1)

def test_dxmigration_migrate_list_of_objects_with_changed_base_class(self):
"""Check list of objects with changed classes."""
from plone.app.contenttypes.migration.dxmigration import \
list_of_objects_with_changed_base_class
# We have already one changed object
objects = [i for i in list_of_objects_with_changed_base_class(self.portal)]
objects = [i for i in
list_of_objects_with_changed_base_class(self.portal)]
self.assertEqual(len(objects), 1)

def test_dxmigration_migrate_list_of_changed_base_class_names(self):
Expand Down
7 changes: 4 additions & 3 deletions plone/app/contenttypes/tests/test_migration_topic.py
Expand Up @@ -17,8 +17,8 @@

@implementer(ICollection)
class FolderishCollection(Container):
"""Test subclass for folderish ``Collections``.
"""
"""Test subclass for folderish ``Collections``.
"""


class MigrateTopicsIntegrationTest(unittest.TestCase):
Expand Down Expand Up @@ -102,7 +102,8 @@ def test_migrate_nested_topic(self):
# the content_meta_type attribute when klass has changed
fti._updateProperty(
'klass',
'plone.app.contenttypes.tests.test_migration_topic.FolderishCollection')
'plone.app.contenttypes.tests.test_migration_topic.'
'FolderishCollection')
fti._updateProperty('allowed_content_types', ['Document', 'Folder'])
fti._updateProperty('filter_content_types', False)
self.run_migration()
Expand Down

1 comment on commit 849727d

@mister-roboto
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TESTS FAILED
Mr.Roboto url : http://jenkins.plone.org/roboto/get_info?push=94489ed9e2fa4feea458eb7363575f52
plone-4.3-python-2.6 [FAILURE]
plone-4.3-python-2.7 [SUCCESS]

Please sign in to comment.