defaultBases = (z2.STARTUP, ) def setUp(self): self['configurationContext'] = context = \ zca.stackConfigurationContext(self.get('configurationContext')) import plone.z3cform xmlconfig.file('testing.zcml', plone.z3cform, context=context) import z3c.form xmlconfig.file('configure.zcml', z3c.form, context=context) def tearDown(self): del self['configurationContext'] P3F_FIXTURE = P3FLayer() FUNCTIONAL_TESTING = z2.FunctionalTesting(bases=(P3F_FIXTURE, ), name="plone.z3cform:Functional") def test_suite(): layout_txt = doctest.DocFileSuite('layout.txt') layout_txt.layer = FUNCTIONAL_TESTING inputs_txt = doctest.DocFileSuite('inputs.txt') inputs_txt.layer = FUNCTIONAL_TESTING fieldsets_txt = doctest.DocFileSuite('fieldsets/README.txt') fieldsets_txt.layer = FUNCTIONAL_TESTING traversal_txt = doctest.DocFileSuite('traversal.txt') traversal_txt.layer = FUNCTIONAL_TESTING
context=configurationContext) def setUpPloneSite(self, portal): portal.portal_workflow.setDefaultChain( 'simple_publication_workflow') if HAVE_PLONE_5: self.applyProfile(portal, 'plone.app.contenttypes:default') #self.applyProfile(portal, 'collective.taskqueue.pasplugin:default') TASK_QUEUE_FORM_FIXTURE = TaskQueueFormLayer() TASK_QUEUE_ROBOT_TESTING = z2.FunctionalTesting( bases=(TASK_QUEUE_ZSERVER_FIXTURE, MOCK_MAILHOST_FIXTURE, REMOTE_LIBRARY_BUNDLE_FIXTURE, TASK_QUEUE_FORM_FIXTURE, ZSERVER_FIXTURE), name='TaskQueue:Robot') REDIS_TASK_QUEUE_ROBOT_TESTING = z2.FunctionalTesting( bases=(REDIS_TASK_QUEUE_ZSERVER_FIXTURE, MOCK_MAILHOST_FIXTURE, REMOTE_LIBRARY_BUNDLE_FIXTURE, TASK_QUEUE_FORM_FIXTURE, ZSERVER_FIXTURE), name='RedisTaskQueue:Robot') class ITaskQueueForm(Interface):
class LocalTaskQueueServerLayer(TaskQueueServerLayer): def setUp(self): queue = taskqueue.LocalVolatileTaskQueue() sm = getSiteManager() sm.registerUtility(queue, provided=ITaskQueue, name='test-queue') super(LocalTaskQueueServerLayer, self).setUp() TASK_QUEUE_FIXTURE = LocalTaskQueueServerLayer(queue='test-queue') TASK_QUEUE_ZSERVER_FIXTURE =\ LocalTaskQueueServerLayer(queue='test-queue', zserver_enabled=True) TASK_QUEUE_INTEGRATION_TESTING = z2.IntegrationTesting( bases=(TASK_QUEUE_FIXTURE, ), name='TaskQueue:Integration') TASK_QUEUE_FUNCTIONAL_TESTING = z2.FunctionalTesting( bases=(TASK_QUEUE_FIXTURE, ), name='TaskQueue:Functional') class RedisTaskQueueServerLayer(TaskQueueServerLayer): def setUp(self): queue = redisqueue.RedisTaskQueue() sm = getSiteManager() sm.registerUtility(queue, provided=ITaskQueue, name='test-queue') super(RedisTaskQueueServerLayer, self).setUp() REDIS_TASK_QUEUE_FIXTURE = RedisTaskQueueServerLayer(queue='test-queue') REDIS_TASK_QUEUE_ZSERVER_FIXTURE =\ RedisTaskQueueServerLayer(queue='test-queue', zserver_enabled=True) REDIS_TASK_QUEUE_INTEGRATION_TESTING = z2.IntegrationTesting(
# Zap the stacked configuration context zca.popGlobalRegistry() del self['configurationContext'] # Zap the stacked ZODB self['zodbDB'].close() del self['zodbDB'] class PloneSubrequestLifecycle(z2.IntegrationTesting): def testSetUp(self): super(PloneSubrequestLifecycle, self).testSetUp() request = self['request'] request['PARENTS'] = [self['app']] setRequest(request) def testTearDown(self): super(PloneSubrequestLifecycle, self).testTearDown() setRequest(None) INTEGRATION_TESTING = PloneSubrequestLifecycle( bases=(PLONE_SUBREQEST_FIXTURE,), name='PloneSubrequest:Integration' ) FUNCTIONAL_TESTING = z2.FunctionalTesting( bases=(PLONE_SUBREQEST_FIXTURE,), name='PloneSubrequest:Functional' )
def tearDown(self): try: self['rabbit'].cleanUp() except OSError as e: if e.errno == 3: # [Errno 3] No such process # Rabbit may have already died because of KeyboardInterrupt pass else: raise RABBIT_FIXTURE = Rabbit() RABBIT_APP_INTEGRATION_TESTING = z2.IntegrationTesting( bases=(RABBIT_FIXTURE, z2.STARTUP), name='RabbitAppFixture:Integration') RABBIT_APP_FUNCTIONAL_TESTING = z2.FunctionalTesting( bases=(RABBIT_FIXTURE, z2.STARTUP), name='RabbitAppFixture:Functional') class Testing(Layer): defaultBases = (RABBIT_FIXTURE, z2.STARTUP) def setUp(self): import collective.zamqp xmlconfig.file('testing.zcml', collective.zamqp, context=self['configurationContext']) TESTING_FIXTURE = Testing()
# The STARTUP fixture has already been run, and Products.ZServerViews # didn't find a ZServer to initialize, so rerun its initialization now: import Products.ZServerViews Products.ZServerViews.initialize(None) def tearDownServer(self): getConfiguration().servers.remove(self.zserver) super(ZServer, self).tearDownServer() ZSERVER_FIXTURE = ZServer() MUNIN_ZOPE_INTEGRATION_TESTING = z2.IntegrationTesting( bases=(MUNIN_ZOPE_FIXTURE, ), name='MuninZope:Integration') MUNIN_ZOPE_ZSERVER = z2.FunctionalTesting(bases=(ZSERVER_FIXTURE, ), name='MuninZope:ZServer') class HolderView(BrowserView): _lock = Lock() green_light = Event() # view is non-blocked at first green_light.set() def __call__(self): with self._lock: self.green_light.wait() return 'OK' @classmethod
apply_patches() def setUpDefaultContent(self, app): # do not create plone site with z2.zopeApp() as app: app['acl_users'].userFolderAddUser(SITE_OWNER_NAME, SITE_OWNER_PASSWORD, ['Manager'], []) def tearDown(self): super(ZopeLayer, self).tearDown() clear_transmogrifier_registry() ZOPE_LAYER = ZopeLayer() ZOPE_FUNCTIONAL_TESTING = z2.FunctionalTesting( bases=(ZOPE_LAYER, ), name='ftw.inflator:ZOPE_FUNCTIONAL_TESTING') class InflatorLayer(PloneSandboxLayer): defaultBases = (PLONE_FIXTURE, ) def setUpZope(self, app, configurationContext): import Products.CMFPlacefulWorkflow xmlconfig.file('configure.zcml', Products.CMFPlacefulWorkflow, context=configurationContext) z2.installProduct(app, 'Products.CMFPlacefulWorkflow') import ftw.inflator
def setUp(self): zca.pushGlobalRegistry() import plone.namedfile xmlconfig.file('testing.zcml', plone.namedfile) self['zodbDB'] = zodb.stackDemoStorage(self.get('zodbDB'), name='NamedFileFixture') def tearDown(self): # Zap the stacked ZODB self['zodbDB'].close() del self['zodbDB'] # Zap the stacked zca context zca.popGlobalRegistry() PLONE_NAMEDFILE_FIXTURE = NamedFileTestLayer() PLONE_NAMEDFILE_INTEGRATION_TESTING = z2.IntegrationTesting( bases=(PLONE_NAMEDFILE_FIXTURE, ), name='plone.namedfile:NamedFileTestLayerIntegration', ) PLONE_NAMEDFILE_FUNCTIONAL_TESTING = z2.FunctionalTesting( bases=(PLONE_NAMEDFILE_FIXTURE, ), name='plone.namedfile:NamedFileTestLayerFunctional', )