Skip to content

Commit

Permalink
config
Browse files Browse the repository at this point in the history
  • Loading branch information
loechel committed Apr 23, 2018
1 parent acb94b0 commit ea9c4f1
Showing 28 changed files with 4,543 additions and 9 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -15,7 +15,6 @@
/pip-selfcheck.json
/include
/lib
/src
/.project
/.pydevproject
/.mr.developer.cfg
6 changes: 3 additions & 3 deletions buildout.cfg
Original file line number Diff line number Diff line change
@@ -16,13 +16,13 @@ versions = versions

auto-checkout =
plone.testing
Products.GenericSetup
# Products.GenericSetup

sources-dir = src-mrd

develop =
src-mrd/plone.testing
src-mrd/Products.GenericSetup
# src-mrd/Products.GenericSetup

[remotes]
plone = git://github.com/plone
@@ -37,7 +37,7 @@ Products.GenericSetup =

[sources]
plone.testing = git ${remotes:plone}/plone.testing.git pushurl=${remotes:plone_push}/plone.testing.git branch=py3
Products.GenericSetup = git ${remotes:zope}/Products.GenericSetup.git pushurl=${remotes:plone_push}/Products.GenericSetup branch=master
#Products.GenericSetup = git ${remotes:zope}/Products.GenericSetup.git pushurl=${remotes:plone_push}/Products.GenericSetup branch=master

[test]
recipe = collective.xmltestreport
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@

# General information about the project.
project = u'plone.app.testing'
copyright = u'2015, Plone Foundation'
copyright = u'2018, Plone Foundation'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@
'zope.interface',
'zope.publisher',
'zope.testrunner',
'zope.testing',
# XXX unspecified dependency of plone.app.upgrade XXX
# 'Products.ATContentTypes',
]
@@ -34,7 +35,7 @@ def read(*rnames):


long_description = \
read('docs', 'source', 'README.rst') + \
read('docs', 'README.rst') + \
'\n\n' +\
read('CHANGES.rst')

1,979 changes: 1,979 additions & 0 deletions src/plone.app.testing.egg-info/PKG-INFO

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions src/plone.app.testing.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
CHANGES.rst
CONTRIBUTING.rst
MANIFEST.in
README.rst
setup.cfg
setup.py
docs/LICENSE.GPL
docs/LICENSE.txt
docs/README.rst
docs/conf.py
docs/index.rst
docs/isolation.rst
docs/views.rst
docs/zope-testbrowser.rst
src/plone/__init__.py
src/plone.app.testing.egg-info/PKG-INFO
src/plone.app.testing.egg-info/SOURCES.txt
src/plone.app.testing.egg-info/dependency_links.txt
src/plone.app.testing.egg-info/namespace_packages.txt
src/plone.app.testing.egg-info/not-zip-safe
src/plone.app.testing.egg-info/requires.txt
src/plone.app.testing.egg-info/top_level.txt
src/plone/app/__init__.py
src/plone/app/testing/__init__.py
src/plone/app/testing/bbb.py
src/plone/app/testing/cleanup.py
src/plone/app/testing/helpers.py
src/plone/app/testing/interfaces.py
src/plone/app/testing/layers.py
src/plone/app/testing/selenium_layers.py
src/plone/app/testing/tests.py
src/plone/app/testing/utils.py
1 change: 1 addition & 0 deletions src/plone.app.testing.egg-info/dependency_links.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

2 changes: 2 additions & 0 deletions src/plone.app.testing.egg-info/namespace_packages.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
plone
plone.app
1 change: 1 addition & 0 deletions src/plone.app.testing.egg-info/not-zip-safe
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

29 changes: 29 additions & 0 deletions src/plone.app.testing.egg-info/requires.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
setuptools
zope.configuration
zope.component
zope.dottedname
zope.testing
five.localsitemanager
plone.memoize
plone.testing[security,z2,zca,zodb]
Products.CMFPlone
Products.GenericSetup
Zope2

[robot]
robotsuite>=1.4.0
robotframework-selenium2library
decorator
selenium

[test]
Products.CMFCore
Products.CMFPlone
Products.PluggableAuthService
Products.CMFPlacefulWorkflow
selenium
transaction
zope.interface
zope.publisher
zope.testrunner
zope.testing
1 change: 1 addition & 0 deletions src/plone.app.testing.egg-info/top_level.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
plone
2 changes: 2 additions & 0 deletions src/plone/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
__import__('pkg_resources').declare_namespace(__name__)
2 changes: 2 additions & 0 deletions src/plone/app/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
__import__('pkg_resources').declare_namespace(__name__)
34 changes: 34 additions & 0 deletions src/plone/app/testing/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
# flake8: NOQA: F401
from plone.app.testing.cleanup import cleanUpMultiPlugins
from plone.app.testing.helpers import applyProfile
from plone.app.testing.helpers import login
from plone.app.testing.helpers import logout
from plone.app.testing.helpers import PloneSandboxLayer
from plone.app.testing.helpers import ploneSite
from plone.app.testing.helpers import PloneWithPackageLayer
from plone.app.testing.helpers import popGlobalRegistry
from plone.app.testing.helpers import pushGlobalRegistry
from plone.app.testing.helpers import quickInstallProduct
from plone.app.testing.helpers import setRoles
from plone.app.testing.helpers import tearDownMultiPluginRegistration
from plone.app.testing.interfaces import DEFAULT_LANGUAGE
from plone.app.testing.interfaces import PLONE_SITE_ID
from plone.app.testing.interfaces import PLONE_SITE_TITLE
from plone.app.testing.interfaces import ROBOT_TEST_LEVEL
from plone.app.testing.interfaces import SITE_OWNER_NAME
from plone.app.testing.interfaces import SITE_OWNER_PASSWORD
from plone.app.testing.interfaces import TEST_USER_ID
from plone.app.testing.interfaces import TEST_USER_NAME
from plone.app.testing.interfaces import TEST_USER_PASSWORD
from plone.app.testing.interfaces import TEST_USER_ROLES
from plone.app.testing.layers import FunctionalTesting
from plone.app.testing.layers import IntegrationTesting
from plone.app.testing.layers import MOCK_MAILHOST_FIXTURE
from plone.app.testing.layers import PLONE_FIXTURE
from plone.app.testing.layers import PLONE_FTP_SERVER
from plone.app.testing.layers import PLONE_FUNCTIONAL_TESTING
from plone.app.testing.layers import PLONE_INTEGRATION_TESTING
from plone.app.testing.layers import PLONE_ZSERVER
from plone.app.testing.layers import PloneFixture
from plone.app.testing.layers import PloneTestLifecycle
125 changes: 125 additions & 0 deletions src/plone/app/testing/bbb.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# -*- coding: utf-8 -*-
"""Backwards-compatibility test class for PloneTestCase."""

from AccessControl import getSecurityManager
from plone.app import testing
from plone.testing import z2
from Products.CMFPlone.utils import _createObjectByType
from Testing.ZopeTestCase.functional import Functional

import transaction
import unittest


def _createMemberarea(portal, user_id):
mtool = portal.portal_membership
members = mtool.getMembersFolder()
if members is None:
_createObjectByType('Folder', portal, id='Members')
if not mtool.getMemberareaCreationFlag():
mtool.setMemberareaCreationFlag()
mtool.createMemberArea(user_id)
if mtool.getMemberareaCreationFlag():
mtool.setMemberareaCreationFlag()


class PloneTestCaseFixture(testing.PloneSandboxLayer):

defaultBases = (testing.PLONE_FIXTURE,)

def setUpZope(self, app, configurationContext):
import Products.ATContentTypes
self.loadZCML(package=Products.ATContentTypes)

z2.installProduct(app, 'Products.Archetypes')
z2.installProduct(app, 'Products.ATContentTypes')
z2.installProduct(app, 'plone.app.blob')
z2.installProduct(app, 'plone.app.collection')

def setUpPloneSite(self, portal):
# restore default workflow
testing.applyProfile(portal, 'Products.CMFPlone:testfixture')

# add default content
testing.applyProfile(portal, 'Products.ATContentTypes:content')

# add home folder for default test user
_createMemberarea(portal, testing.TEST_USER_ID)

def tearDownZope(self, app):
z2.uninstallProduct(app, 'plone.app.collection')
z2.uninstallProduct(app, 'plone.app.blob')
z2.uninstallProduct(app, 'Products.ATContentTypes')
z2.uninstallProduct(app, 'Products.Archetypes')


PTC_FIXTURE = PloneTestCaseFixture()
PTC_FUNCTIONAL_TESTING = testing.FunctionalTesting(
bases=(PTC_FIXTURE,), name='PloneTestCase:Functional')


class PloneTestCase(Functional, unittest.TestCase):

layer = PTC_FUNCTIONAL_TESTING

def setUp(self):
"""Set up before each test."""
self.beforeSetUp()
self.app = self.layer['app']
self.portal = self.layer['portal']
self.folder = self.portal.portal_membership.getHomeFolder(
testing.TEST_USER_ID)
transaction.commit()
self.afterSetUp()

def beforeSetUp(self):
"""Hook to do setup before the portal is created."""
pass

def afterSetUp(self):
"""Hook to do setup after the portal is created."""

def tearDown(self):
"""Tear down after each test."""
self.beforeTearDown()
transaction.abort()
super(PloneTestCase, self).tearDown()
self.afterTearDown()

def beforeTearDown(self):
"""Hook to do teardown before the portal is removed."""

def afterTearDown(self):
"""Hook to do teardown after the portal is removed."""

def setRoles(self, roles, name=testing.TEST_USER_ID):
"""Set the effective roles of a user."""
testing.setRoles(self.portal, name, roles)

def setGroups(self, groups, name=testing.TEST_USER_ID):
'''Changes the user's groups.'''
uf = self.portal['acl_users']
uf.userSetGroups(name, list(groups))
user = getSecurityManager().getUser()
if name == user.getId():
self.login(user.getUserName())

def setPermissions(self, permissions, role='Member'):
"""Changes the permissions assigned to role."""
self.portal.manage_role(role, list(permissions))

def login(self, userName=testing.TEST_USER_NAME):
"""Log in to the portal as the given user."""
testing.login(self.portal, userName)

def loginAsPortalOwner(self, userName=testing.SITE_OWNER_NAME):
"""Log in to the portal as the user who created it."""
z2.login(self.app['acl_users'], userName)

def logout(self):
"""Log out, i.e. become anonymous."""
testing.logout()

def createMemberarea(self, name):
"""Create a minimal memberarea."""
_createMemberarea(self.portal, name)
41 changes: 41 additions & 0 deletions src/plone/app/testing/cleanup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# -*- coding: utf-8 -*-
"""Cleanup handlers for various global registries
"""

from zope.testing.cleanup import addCleanUp


# Make sure cleanup handlers from GenericSetup are registered
try:
import Products.GenericSetup.zcml
except ImportError:
pass

# Make sure cleanup handlers from PAS are registered
try:
import Products.PluggableAuthService.zcml
except ImportError:
pass


def cleanUpMultiPlugins():
try:
from Products.PluggableAuthService.PluggableAuthService import MultiPlugins # NOQA: E501
except ImportError:
pass
else:

zap = []

# Don't stomp on the things the other cleanup handler will deal with
from Products.PluggableAuthService import zcml
for plugin in MultiPlugins:
if plugin not in zcml._mt_regs:
zap.append(plugin)

for plugin in zap:
MultiPlugins.remove(plugin)


addCleanUp(cleanUpMultiPlugins)
del addCleanUp
31 changes: 31 additions & 0 deletions src/plone/app/testing/cleanup.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Cleanup functions
-----------------

When imported, this package will register a few cleanup handlers with
``zope.testing.cleanup`` to clean up global state left by various Zope, CMF
and Plone packages.

>>> import zope.testing.cleanup
>>> zope.testing.cleanup.cleanUp()

PluggableAuthService MultiPlugins list
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The ``PluggableAuthService`` package maintains a global list of so-called multi-plugins.

>>> from Products.PluggableAuthService import PluggableAuthService
>>> PluggableAuthService.MultiPlugins
[]

A new plugin can be registered using the ``registerPlugin()`` API.

>>> PluggableAuthService.registerMultiPlugin("dummy_plugin")
>>> PluggableAuthService.MultiPlugins
['dummy_plugin']

On cleanup, this list is emptied.

>>> zope.testing.cleanup.cleanUp()

>>> PluggableAuthService.MultiPlugins
[]
Loading

0 comments on commit ea9c4f1

Please sign in to comment.