Skip to content

Commit

Permalink
Merge branch 'volto_3294' into volto_3294_new_fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
mauritsvanrees authored May 9, 2022
2 parents f6b98c3 + 6ac8cdd commit c2cc096
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 24 deletions.
1 change: 1 addition & 0 deletions src/plone/app/robotframework/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ def zodb_setup(self, layer_dotted_name=None):
from zope.testrunner.runner import order_by_bases

layers = order_by_bases([self.zope_layer])
print(WAIT(layers))
for layer in layers:
if hasattr(layer, "testSetUp"):
if HAS_VERBOSE_CONSOLE:
Expand Down
64 changes: 40 additions & 24 deletions src/plone/app/robotframework/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from plone.app.robotframework.remote import RemoteLibraryLayer
from plone.app.robotframework.server import Zope2ServerRemote
from plone.app.robotframework.users import Users
from plone.app.robotframework.server import WAIT
from plone.app.testing import applyProfile
from plone.app.testing import FunctionalTesting
from plone.app.testing import IntegrationTesting
Expand Down Expand Up @@ -137,30 +138,6 @@ def tearDown(self):
# />
#

class TestScopeWSGIServer(WSGIServer):

# Layer where WSGI server is shutdown on testTearDown to prevent requests
# being processed between tests (which could lead to unexpected database
# state).

# Still starts with WSGI server being started at first on suite setUp
# for convenience and similar "RobotServer" experience to the default
# layer.

def testSetUp(self):
if hasattr(self, "server") and self.server.was_shutdown:
super(TestScopeWSGIServer, self).setUp()

def tearDown(self):
pass

def testTearDown(self):
super(TestScopeWSGIServer, self).tearDown()


TEST_SCOPE_WSGI_SERVER_FIXTURE = TestScopeWSGIServer()


RobotRemote = type(
"RobotRemote",
(
Expand Down Expand Up @@ -306,6 +283,45 @@ def __nonzero__(x):
name="PloneRobot:Integration",
)


class WSGIServerTestScope(WSGIServer):

# Layer where WSGI server is shutdown on testTearDown to prevent requests
# being processed between tests (which could lead to unexpected database
# state).

# Still starts with WSGI server being started at first on suite setUp
# for convenience and similar "RobotServer" experience to the default
# layer.

bases = (PLONE_FIXTURE,)

def setUp(self):
print(WAIT("WSGIServerTestScope:setUp"))
super(WSGIServerTestScope, self).setUp()

def testSetUp(self):
print(WAIT("WSGIServerTestScope:testSetUp"))
if hasattr(self, "server") and self.server.was_shutdown:
super(WSGIServerTestScope, self).setUp()

def tearDown(self):
print(WAIT("WSGIServerTestScope:tearDown"))
pass

def testTearDown(self):
print(WAIT("WSGIServerTestScope:testTearDown"))
super(WSGIServerTestScope, self).tearDown()
# Try to wait until server no longer responds.
if hasattr(self, "server"):
for i in range(10):
# There is implicit 0.3 second sleep per try.
if not self.server.wait(0):
return


WSGI_SERVER_TEST_SCOPE_FIXTURE = WSGIServerTestScope()

PLONE_ROBOT_TESTING = FunctionalTesting(
bases=(
PLONE_ROBOT_FIXTURE,
Expand Down

0 comments on commit c2cc096

Please sign in to comment.