Skip to content

Commit

Permalink
Merge pull request #23 from plone/revert-22-tomgross-noptc
Browse files Browse the repository at this point in the history
Revert "Ported to plone.app.testing"
  • Loading branch information
tisto committed Jan 7, 2015
2 parents d484e8d + 2be4aa9 commit 8de8c57
Show file tree
Hide file tree
Showing 11 changed files with 2,220 additions and 12 deletions.
7 changes: 1 addition & 6 deletions CHANGES.rst
@@ -1,7 +1,7 @@
Changelog
=========

2.0 (unreleased)
1.3.9 (unreleased)
------------------

- Add upgrade step for the security control panel.
Expand All @@ -13,11 +13,6 @@ Changelog
- Add upgrade steps for markup control panel.
[thet]

- Ported tests to plone.app.testing
[tomgross]

- Removed all tests for migrations older than 4.3 -> 5.0
[tomgross]

1.3.8 (2014-11-01)
------------------
Expand Down
20 changes: 18 additions & 2 deletions plone/app/upgrade/tests/base.py
Expand Up @@ -9,14 +9,19 @@
import transaction
from zope.site.hooks import setSite

from plone.app.testing.bbb import PloneTestCase
from Testing.ZopeTestCase.sandbox import Sandboxed
from Products.PloneTestCase.layer import PloneSiteLayer
from Products.PloneTestCase.ptc import PloneTestCase
from Products.PloneTestCase.ptc import setupPloneSite

from Products.CMFCore.interfaces import IActionCategory
from Products.CMFCore.interfaces import IActionInfo
from Products.CMFCore.utils import getToolByName
from Products.CMFCore.tests.base.testcase import WarningInterceptor
from Products.GenericSetup.context import TarballImportContext

setupPloneSite()


class MigrationTest(PloneTestCase):

Expand Down Expand Up @@ -106,10 +111,21 @@ def removeSkinLayer(self, layer, skin='Plone Default'):
skins.addSkinSelection(skin, ','.join(path))


class FunctionalUpgradeLayer(PloneSiteLayer):

@classmethod
def setUp(cls):
pass

@classmethod
def tearDown(cls):
pass


class FunctionalUpgradeTestCase(PloneTestCase, WarningInterceptor):
class FunctionalUpgradeTestCase(Sandboxed, PloneTestCase, WarningInterceptor):

_setup_fixture = 0
layer = FunctionalUpgradeLayer
site_id = 'test'

def afterSetUp(self):
Expand Down
124 changes: 124 additions & 0 deletions plone/app/upgrade/v25/tests.py
@@ -0,0 +1,124 @@
from Products.CMFPlone.UnicodeSplitter import Splitter
from Products.CMFPlone.UnicodeSplitter import CaseNormalizer

from plone.app.upgrade.tests.base import FunctionalUpgradeTestCase
from plone.app.upgrade.tests.base import MigrationTest
from plone.app.upgrade.utils import loadMigrationProfile

from plone.app.upgrade.v25 import fixupPloneLexicon
from plone.app.upgrade.v25 import setLoginFormInCookieAuth
from plone.app.upgrade.v25 import addMissingMimeTypes


class TestMigrations_v2_5_0(MigrationTest):

def afterSetUp(self):
self.profile = 'profile-plone.app.upgrade.v25:2.5final-2.5.1'
self.actions = self.portal.portal_actions
self.css = self.portal.portal_css

def tesFixObjDeleteAction(self):
# Prepare delete actions test
editActions = ('delete',)
for a in editActions:
self.removeActionFromTool(a, category='object_buttons')
loadMigrationProfile(self.portal, self.profile, ('actions', ))
# delete action tests
actions = [x.id for x in self.actions.object_buttons.listActions()
if x.id in editActions]
# check that all of our deleted actions are now present
for a in editActions:
self.assertTrue(a in actions)
# ensure that they are present only once
self.assertEqual(len(editActions), len(actions))

def testFixupPloneLexicon(self):
# Should update the plone_lexicon pipeline
lexicon = self.portal.portal_catalog.plone_lexicon
lexicon._pipeline = (object(), object())
# Test it twice
for i in range(2):
fixupPloneLexicon(self.portal)
self.assertTrue(isinstance(lexicon._pipeline[0], Splitter))
self.assertTrue(isinstance(lexicon._pipeline[1], CaseNormalizer))


class TestMigrations_v2_5_1(MigrationTest):

def afterSetUp(self):
self.actions = self.portal.portal_actions
self.memberdata = self.portal.portal_memberdata
self.catalog = self.portal.portal_catalog
self.skins = self.portal.portal_skins
self.types = self.portal.portal_types
self.workflow = self.portal.portal_workflow
self.css = self.portal.portal_css

def testSetLoginFormInCookieAuth(self):
setLoginFormInCookieAuth(self.portal)
cookie_auth = self.portal.acl_users.credentials_cookie_auth
self.assertEqual(cookie_auth.getProperty('login_path'),
'require_login')

def testSetLoginFormNoCookieAuth(self):
# Shouldn't error
uf = self.portal.acl_users
uf._delOb('credentials_cookie_auth')
setLoginFormInCookieAuth(self.portal)

def testSetLoginFormAlreadyChanged(self):
# Shouldn't change the value if it's not the default
cookie_auth = self.portal.acl_users.credentials_cookie_auth
cookie_auth.manage_changeProperties(login_path='foo')
setLoginFormInCookieAuth(self.portal)
self.assertTrue(cookie_auth.getProperty('login_path') != 'require_login')

class TestMigrations_v2_5_2(MigrationTest):

def afterSetUp(self):
self.mimetypes = self.portal.mimetypes_registry

def testMissingMimeTypes(self):
# we're testing for 'text/x-web-markdown' and 'text/x-web-textile'
missing_types = ['text/x-web-markdown', 'text/x-web-textile']
# since we're running a full 2.5.4 instance in this test, the missing
# types might in fact already be there:
current_types = self.mimetypes.list_mimetypes()
types_to_delete = []
for mtype in missing_types:
if mtype in current_types:
types_to_delete.append(mtype)
if types_to_delete:
self.mimetypes.manage_delObjects(types_to_delete)
# now they're gone:
self.assertFalse(set(self.mimetypes.list_mimetypes()).issuperset(set(missing_types)))
addMissingMimeTypes(self.portal)
# now they're back:
self.assertTrue(set(self.mimetypes.list_mimetypes()).issuperset(set(missing_types)))


class TestFunctionalMigrations(FunctionalUpgradeTestCase):

def testUpgrade(self):
self.importFile(__file__, 'test-base.zexp')
oldsite, result = self.migrate()

mig = oldsite.portal_migration
self.assertFalse(mig.needUpgrading())

def testDCMIStorageUpdated(self):
self.importFile(__file__, 'test-base.zexp')
oldsite, result = self.migrate()

dcmi = getattr(oldsite.portal_metadata, 'DCMI', None)
self.assertFalse(dcmi is None)


def test_suite():
from unittest import TestSuite, makeSuite
suite = TestSuite()
suite.addTest(makeSuite(TestMigrations_v2_5_0))
suite.addTest(makeSuite(TestMigrations_v2_5_1))
suite.addTest(makeSuite(TestMigrations_v2_5_2))
suite.addTest(makeSuite(TestFunctionalMigrations))
return suite

1 comment on commit 8de8c57

@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=73bb8f98a54746be906ef714cd6cac96
plone-4.3-python-2.6 [FAILURE]
plone-4.3-python-2.7 [SUCCESS]
plone-5.0-python-2.7 [SUCCESS]

Please sign in to comment.