- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
4,543 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
plone | ||
plone.app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
plone |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# -*- coding: utf-8 -*- | ||
__import__('pkg_resources').declare_namespace(__name__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# -*- coding: utf-8 -*- | ||
__import__('pkg_resources').declare_namespace(__name__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
[] |
Oops, something went wrong.