Skip to content

Commit

Permalink
ported tests to plone.app.testing
Browse files Browse the repository at this point in the history
  • Loading branch information
tomgross committed Dec 10, 2014
1 parent 52588a0 commit b5045ec
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 53 deletions.
23 changes: 10 additions & 13 deletions src/plone/app/folder/tests/base.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
# -*- coding: utf-8 -*-
from Products.PloneTestCase import PloneTestCase as ptc
from Products.Five.testbrowser import Browser
from plone.app.testing.bbb import PloneTestCase
from plone.app.testing import TEST_USER_NAME
from plone.app.testing import TEST_USER_PASSWORD
from plone.testing.z2 import Browser

ptc.setupPloneSite()


class IntegrationTestCase(ptc.PloneTestCase):
""" base class for integration tests """


class FunctionalTestCase(ptc.FunctionalTestCase):
class FunctionalTestCase(PloneTestCase):
""" base class for functional tests """

def getBrowser(self, loggedIn=True):
""" instantiate and return a testbrowser for convenience """
browser = Browser()
browser = Browser(self.layer['app'])
if loggedIn:
user = ptc.default_user
pwd = ptc.default_password
browser.addHeader('Authorization', 'Basic %s:%s' % (user, pwd))
browser.addHeader('Authorization', 'Basic %s:%s' % (
TEST_USER_NAME, TEST_USER_PASSWORD))
return browser

IntegrationTestCase = FunctionalTestCase
13 changes: 2 additions & 11 deletions src/plone/app/folder/tests/benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# to run individual tests using:
# $ bin/test -s plone.app.folder --tests-pattern=benchmarks -t <testName>
# where <testName> is something like "testObjectValuesOrdered"
from Products.PloneTestCase import PloneTestCase as ptc
from plone.app.testing.bbb import PloneTestCase
from Testing import ZopeTestCase as ztc
from plone.app.folder.tests.content import _createObjectByType
from plone.app.folder.tests.content import create as createNonBTreeFolder
Expand All @@ -13,8 +13,6 @@
from profilehooks import timecall
from random import randint
from transaction import commit
from unittest import defaultTestLoader
from unittest import main

# setup plone site
ptc.setupPloneSite()
Expand All @@ -23,7 +21,7 @@
SIZE = 500


class TestBenchmarkCase(ptc.PloneTestCase):
class TestBenchmarkCase(PloneTestCase):

class layer(IntegrationLayer):

Expand Down Expand Up @@ -176,10 +174,3 @@ def testRandomUnordered(self):
def testRandomOrdered(self):
for x in range(1000):
self.ordered['doc.%d' % randint(0, SIZE-1)]


def test_suite():
return defaultTestLoader.loadTestsFromName(__name__)

if __name__ == '__main__':
main(defaultTest='test_suite')
46 changes: 17 additions & 29 deletions src/plone/app/folder/tests/layer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-
from Products.CMFCore.utils import getToolByName
from Products.PloneTestCase.layer import PloneSite
from plone.app.testing import PloneSandboxLayer
from plone.app.testing import applyProfile
from plone.app.testing.bbb import PTC_FUNCTIONAL_TESTING
from Testing.ZopeTestCase import app
from Testing.ZopeTestCase import close
from Testing.ZopeTestCase import installPackage
Expand All @@ -19,42 +21,28 @@
from Products.Five import fiveconfigure as metaconfigure


class IntegrationLayer(PloneSite):
class IntegrationLayer(PloneSandboxLayer):
""" layer for integration tests using the folder replacement type """

@classmethod
def setUp(cls):
root = app()
portal = root.plone
# load zcml & install the package
metaconfigure.debug_mode = True
defaultBases = (PTC_FUNCTIONAL_TESTING,)

def setUpZope(self, app, configurationContext):
from plone.app.folder import tests
load_config('testing.zcml', tests)
metaconfigure.debug_mode = False
installPackage('plone.app.folder', quiet=True)
# import replacement profile
profile = 'profile-plone.app.folder:default'
tool = getToolByName(portal, 'portal_setup')
tool.runAllImportStepsFromProfile(profile, purge_old=False)
# make sure it's loaded...
self.loadZCML('testing.zcml', tests)
z2.installProduct(app, 'plone.app.blob')


def setUpPloneSite(self, portal):
# restore default workflow
applyProfile(portal, 'profile-plone.app.folder:default')

types = getToolByName(portal, 'portal_types')
assert types.getTypeInfo('Folder').product == 'plone.app.folder'
# and commit the changes
commit()
close(root)

@classmethod
def tearDown(cls):
pass


class PartialOrderingIntegrationLayer(IntegrationLayer):
""" layer for integration tests using the partial ordering adapter """

@classmethod
def setUp(cls):
def setUpZope(self, app, configurationContext):
IntegrationLayer.setUpZope(self, app, configurationContext)
provideAdapter(PartialOrdering)

@classmethod
def tearDown(cls):
pass

0 comments on commit b5045ec

Please sign in to comment.