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
6 changed files
with
117 additions
and
30 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
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,47 @@ | ||
from plone.app.testing import PloneSandboxLayer | ||
from plone.app.testing import PLONE_FIXTURE | ||
from plone.app.testing import IntegrationTesting | ||
from plone.app.testing import FunctionalTesting | ||
from plone.app.testing import applyProfile | ||
from plone.app.testing import quickInstallProduct | ||
|
||
from plone.testing import z2 | ||
from Testing import ZopeTestCase | ||
|
||
|
||
class TestLayer(PloneSandboxLayer): | ||
|
||
default_bases = (PLONE_FIXTURE,) | ||
|
||
class Session(dict): | ||
def set(self, key, value): | ||
self[key] = value | ||
|
||
def setUpZope(self, app, configurationContext): | ||
|
||
# Set up sessioning objects | ||
app.REQUEST['SESSION'] = self.Session() | ||
ZopeTestCase.utils.setupCoreSessions(app) | ||
|
||
import seantis.dir.roadworks | ||
self.loadZCML(package=seantis.dir.roadworks) | ||
|
||
def setUpPloneSite(self, portal): | ||
quickInstallProduct(portal, 'seantis.dir.roadworks') | ||
applyProfile(portal, 'seantis.dir.roadworks:default') | ||
|
||
def tearDownZope(self, app): | ||
z2.uninstallProduct(app, 'seantis.dir.roadworks') | ||
|
||
|
||
TESTFIXTURE = TestLayer() | ||
|
||
INTEGRATION_TESTING = IntegrationTesting( | ||
bases=(TESTFIXTURE, ), | ||
name="Testfixture:Integration" | ||
) | ||
|
||
FUNCTIONAL_TESTING = FunctionalTesting( | ||
bases=(TESTFIXTURE, ), | ||
name="Testfixture:Functional" | ||
) |
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 |
---|---|---|
@@ -1,14 +1,25 @@ | ||
from seantis.dir.roadworks.tests.layer import Layer | ||
from Products.PloneTestCase.ptc import PloneTestCase | ||
from zope.security.management import newInteraction, endInteraction | ||
|
||
from seantis.plonetools.testing import TestCase | ||
from seantis.dir.roadworks.testing import ( | ||
INTEGRATION_TESTING, | ||
FUNCTIONAL_TESTING | ||
) | ||
|
||
class IntegrationTestCase(PloneTestCase): | ||
layer = Layer | ||
|
||
def add_directory(self, name='Directory'): | ||
self.folder.invokeFactory('seantis.dir.roadworks.directory', name) | ||
return self.folder[name] | ||
# to use with integration where security interactions need to be done manually | ||
class IntegrationTestCase(TestCase): | ||
layer = INTEGRATION_TESTING | ||
|
||
def add_item(self, directory, name='DirectoryItem'): | ||
directory.invokeFactory('seantis.dir.roadworks.item', name) | ||
return directory[name] | ||
def setUp(self): | ||
super(IntegrationTestCase, self).setUp() | ||
newInteraction() | ||
|
||
def tearDown(self): | ||
endInteraction() | ||
super(IntegrationTestCase, self).tearDown() | ||
|
||
|
||
# to use with the browser which does its own security interactions | ||
class FunctionalTestCase(TestCase): | ||
layer = FUNCTIONAL_TESTING |
This file was deleted.
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
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