Skip to content

Commit

Permalink
Merge pull request #176 from plone/python3-testfixes
Browse files Browse the repository at this point in the history
testfixes for plone 5.2 and python 3
  • Loading branch information
petschki authored Oct 1, 2018
2 parents b765a99 + ba85502 commit d94d545
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 12 deletions.
6 changes: 6 additions & 0 deletions news/176.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
fix tests in Plone >= 5.2 and python 3.
As discussed with jensens and mauritsvanrees
we start migration tests beginning from 4.0 final
due to portal_factory property errors.

[petschki]
4 changes: 2 additions & 2 deletions plone/app/upgrade/tests/test_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ def testVersionMatch(self):

def testDoUpgrades(self):
self.setRoles(['Manager'])

self.setup.setLastVersionForProfile(_DEFAULT_PROFILE, '2.5')
self.setup.setLastVersionForProfile(_DEFAULT_PROFILE, '4013')
upgrades = self.setup.listUpgrades(_DEFAULT_PROFILE)
self.assertTrue(len(upgrades) > 0)

Expand Down
5 changes: 4 additions & 1 deletion plone/app/upgrade/v41/alphas.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ def _update_rolemap_for_siteadmin_role(portal):
roles,
permission_info['acquire'])
for permission_id in extra_permissions:
portal.manage_permission(permission_id, ['Site Administrator', ], True)
try:
portal.manage_permission(permission_id, ['Site Administrator', ], True)
except ValueError:
continue


def _update_workflows_for_siteadmin_role(portal):
Expand Down
2 changes: 1 addition & 1 deletion plone/app/upgrade/v41/final.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def fixOkapiIndexes(catalog):
for index in catalog.getIndexObjects():
index = getattr(index, 'index', index)
if isinstance(index, OkapiIndex):
index._totaldoclen = Length(long(sum(index._docweight.values())))
index._totaldoclen = Length(int(sum(index._docweight.values())))


def fixOwnerTuples(portal):
Expand Down
7 changes: 4 additions & 3 deletions plone/app/upgrade/v43/alphas.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,11 @@ def _update_syndication_info(portal):
from Products.CMFPlone.interfaces.syndication import ISyndicatable
catalog = getToolByName(portal, 'portal_catalog')
# get all folder types from portal_types
at_tool = getToolByName(portal, 'archetype_tool')
at_tool = getToolByName(portal, 'archetype_tool', None)
folder_types = set([])
for _type in at_tool.listPortalTypesWithInterfaces([ISyndicatable]):
folder_types.add(_type.getId())
if at_tool is not None:
for _type in at_tool.listPortalTypesWithInterfaces([ISyndicatable]):
folder_types.add(_type.getId())
folder_types = folder_types | _getDexterityFolderTypes(portal)
for brain in catalog(portal_type=tuple(folder_types)):
try:
Expand Down
12 changes: 8 additions & 4 deletions plone/app/upgrade/v50/alphas.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ def migrate_registry_settings(portal):
site_props = portal.portal_properties.site_properties
registry = portal.portal_registry
portal_types = portal.portal_types
registry['plone.site_title'] = portal.title.decode('utf8')
registry['plone.site_title'] = safe_unicode(portal.title)
if site_props.hasProperty('webstats_js'):
registry['plone.webstats_js'] = site_props.webstats_js.decode('utf8')
registry['plone.webstats_js'] = safe_unicode(site_props.webstats_js)
if site_props.hasProperty('enable_sitemap'):
registry['plone.enable_sitemap'] = site_props.enable_sitemap

Expand Down Expand Up @@ -264,8 +264,12 @@ def upgrade_editing_controlpanel_settings(context):
IEditingSchema['default_editor'].validate(
site_properties.default_editor)
except ConstraintNotSatisfied:
logger.warn('Ignoring invalid site_properties.default_editor %r.',
site_properties.default_editor)
logger.warning(
'Ignoring invalid site_properties.default_editor %r.',
site_properties.default_editor)
except AttributeError:
logger.warning(
'Ignoring non existing attribute site_properties.default_editor.')
else:
settings.default_editor = site_properties.default_editor
settings.lock_on_ttw_edit = get_property(
Expand Down
2 changes: 1 addition & 1 deletion plone/app/upgrade/v50/betas.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def upgrade_mail_controlpanel_settings(context):
portal = getSite()

smtp_host = getattr(portal.MailHost, 'smtp_host', '')
mail_settings.smtp_host = unicode(smtp_host)
mail_settings.smtp_host = safe_unicode(smtp_host)

smtp_port = getattr(portal.MailHost, 'smtp_port', 25)
# It may happen that smtp_port is a string, maybe empty,
Expand Down

0 comments on commit d94d545

Please sign in to comment.