Exemplo n.º 1
0
    def setUp(self):
        # SchoolTool needs to bootstrap the database first, before the Zope 3
        # IDatabaseOpenedEvent gets a chance to create its own root folder and
        # stuff.  Unfortunatelly, we cannot install a IDatabaseOpenedEvent
        # subscriber via ftesting.zcml and ensure it will get called first.
        # Instead we place our own subscriber directly into zope.event.subscribers,
        # where it gets a chance to intercept IDatabaseOpenedEvent before the
        # Zope 3 event dispatcher sees it.

        def install_db_bootstrap_hook():
            """Install schooltool_db_setup into zope.event.subscribers."""
            zope.event.subscribers.insert(0, schooltool_db_setup)

        def uninstall_db_bootstrap_hook():
            """Remove schooltool_db_setup from zope.event.subscribers."""
            zope.event.subscribers.remove(schooltool_db_setup)

        def schooltool_db_setup(event):
            """IDatabaseOpenedEvent handler that bootstraps SchoolTool."""
            if IDatabaseOpenedEvent.providedBy(event):
                import schooltool.app.main
                server = schooltool.app.main.SchoolToolServer()
                server.initializePreferences = lambda app: None
                server.bootstrapSchoolTool(event.database)
                server.startApplication(event.database)

        install_db_bootstrap_hook()
        try:
            _ZCMLLayer.setUp(self)
        finally:
            uninstall_db_bootstrap_hook()
Exemplo n.º 2
0
import os.path
import z3c.testsetup
import uvc.landingpage
from zope.app.testing.functional import ZCMLLayer

from uvcsite.tests import product_config

ftesting_zcml = os.path.join(os.path.dirname(uvc.landingpage.__file__),
                             'ftesting.zcml')
FunctionalLayer = ZCMLLayer(ftesting_zcml,
                            __name__,
                            'FunctionalLayer',
                            allow_teardown=True,
                            product_config=product_config)

test_suite = z3c.testsetup.register_all_tests('uvc.landingpage',
                                              layer=FunctionalLayer)
Exemplo n.º 3
0
 def tearDown(self):
     _ZCMLLayer.tearDown(self)
     clear_mappers()
Exemplo n.º 4
0
 def setUp(self):
     _ZCMLLayer.setUp(self)
     for name, utility in getUtilitiesFor(IDatabase):
         utility.setMappers()
Exemplo n.º 5
0
 def __init__(self, *args, **kwargs):
     kwargs['allow_teardown'] = True
     _ZCMLLayer.__init__(self, *args, **kwargs)
##############################################################################
#
# Copyright (c) 2007 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""zope.app.securitypolicy common test related classes/functions/objects.

$Id$
"""

__docformat__ = "reStructuredText"

import os
from zope.app.testing.functional import ZCMLLayer

SecurityPolicyLayer = ZCMLLayer(
    os.path.join(os.path.split(__file__)[0], 'ftesting.zcml'),
    __name__, 'SecurityPolicyLayer', allow_teardown=True)
Exemplo n.º 7
0
 def setUp(self):
     """ Prevent zope.sendmail to start its thread during tests, or this will
     confuse the coverage analyzer"""
     from zope.sendmail import zcml
     zcml.queuedDelivery = lambda *args, **kwargs :None
     ZCMLLayer.setUp(self)
Exemplo n.º 8
0
import os
import unittest

from zope.testing import doctest
from zope.app.testing.functional import ZCMLLayer

testing_zcml_path = os.path.join(os.path.dirname(__file__), 'testing.zcml')
testing_zcml_layer = ZCMLLayer(testing_zcml_path, 'plone.formwidget.captcha',
                               'testing_zcml_layer')


def test_suite():
    readme_txt = doctest.DocFileSuite('README.txt')
    readme_txt.layer = testing_zcml_layer

    return unittest.TestSuite([
        readme_txt,
    ])
Exemplo n.º 9
0
import tempfile
import lxml.etree
import os
from zope.rdb import gadflyda
from zope.app.testing.functional import ZCMLLayer


def setUp(test):
    gadfly_dir = tempfile.mkdtemp()
    os.mkdir(os.path.join(gadfly_dir, 'msg'))
    gadflyda.setGadflyRoot(gadfly_dir)


def printElement(browser, xpath, multiple=False, serialize=True):
    result = [
        serialize and lxml.etree.tounicode(elem) or elem
        for elem in browser.etree.xpath(xpath)
    ]
    if not multiple:
        print result[0]
        return
    for elem in result:
        print elem


FormDemoLayer = ZCMLLayer(os.path.join(
    os.path.split(__file__)[0], 'ftesting.zcml'),
                          __name__,
                          'MarsFormDemoLayer',
                          allow_teardown=True)
Exemplo n.º 10
0
 def __init__(self, *args, **kwargs):
     kwargs['allow_teardown'] = True
     _ZCMLLayer.__init__(self, *args, **kwargs)
Exemplo n.º 11
0
import os
import unittest
import simpleauthtest
from zope.testing import doctest
from zope.app.testing.functional import (FunctionalTestSetup, ZCMLLayer,
                                         getRootFolder, FunctionalDocFileSuite)
import zope.testbrowser.browser
import zope.testbrowser.testing

ftesting_zcml = os.path.join(os.path.dirname(simpleauthtest.__file__), 'ftesting.zcml')
SimpleAuthFunctionalLayer = ZCMLLayer(ftesting_zcml, __name__, 'SimpleAuthFunctionalLayer')

def test_suite():
    suite = unittest.TestSuite()
    docfiles = ['index.txt',]

    for docfile in docfiles:
        test = FunctionalDocFileSuite(
             docfile,
             globs=dict(getRootFolder=getRootFolder, Browser=zope.testbrowser.testing.Browser),
             optionflags = (doctest.ELLIPSIS
                            | doctest.REPORT_NDIFF
                            | doctest.NORMALIZE_WHITESPACE),)
        test.layer = SimpleAuthFunctionalLayer
        suite.addTest(test)

    return suite

if __name__ == '__main__':
    unittest.main()
Exemplo n.º 12
0
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""
$Id$
"""
__docformat__ = "reStructuredText"

import os.path
import unittest
from zope.testing import doctest
from zope.app.testing import functional
from zope.app.testing.functional import ZCMLLayer

memcachedLayer = ZCMLLayer(os.path.join(
    os.path.split(__file__)[0], 'ftesting.zcml'),
                           __name__,
                           'memcachedLayer',
                           allow_teardown=True)


def test_suite():
    suite = functional.FunctionalDocFileSuite('README.txt')
    suite.layer = memcachedLayer
    suite.level = 2
    return unittest.TestSuite((suite, ))


if __name__ == '__main__':
    unittest.main(defaultTest='test_suite')
Exemplo n.º 13
0
import os
import unittest
import plainlogindemo
from zope.testing import doctest
from zope.app.testing.functional import (FunctionalTestSetup, ZCMLLayer,
                                         getRootFolder, FunctionalDocFileSuite)
import zope.testbrowser.browser
import zope.testbrowser.testing

ftesting_zcml = os.path.join(os.path.dirname(plainlogindemo.__file__),
                             'ftesting.zcml')
PlainLoginDemoFunctionalLayer = ZCMLLayer(ftesting_zcml, __name__,
                                          'PlainLoginDemoFunctionalLayer')


def test_suite():
    suite = unittest.TestSuite()
    docfiles = ['index.txt', 'join.txt', 'member.txt']

    for docfile in docfiles:
        test = FunctionalDocFileSuite(
            docfile,
            globs=dict(getRootFolder=getRootFolder,
                       Browser=zope.testbrowser.testing.Browser),
            optionflags=(doctest.ELLIPSIS
                         | doctest.REPORT_NDIFF
                         | doctest.NORMALIZE_WHITESPACE),
        )
        test.layer = PlainLoginDemoFunctionalLayer
        suite.addTest(test)
Exemplo n.º 14
0
import os.path
import megrok.storm
from zope.app.testing.functional import ZCMLLayer

ftesting_zcml = os.path.join(os.path.dirname(megrok.storm.__file__),
                             'ftesting.zcml')
FunctionalLayer = ZCMLLayer(ftesting_zcml,
                            __name__,
                            'FunctionalLayer',
                            allow_teardown=True)
Exemplo n.º 15
0
import os
import unittest
from zope.testing import doctest
from zope.app.testing import setup
from zope.app.testing.functional import ZCMLLayer

from zope.app.testing.functional import FunctionalTestSetup, getRootFolder

import tfws.website

ftesting_zcml = os.path.join(os.path.dirname(tfws.website.__file__),
                             'ftesting.zcml')

TestLayer = ZCMLLayer(ftesting_zcml, __name__, 'TestLayer')

ftest_selenium_zcml = os.path.join(os.path.dirname(tfws.website.__file__),
                                   'ftest-selenium.zcml')

SeleniumTestLayer = ZCMLLayer(ftest_selenium_zcml, __name__, 'SeleniumLayer')

optionflags = doctest.NORMALIZE_WHITESPACE + doctest.ELLIPSIS
globs = dict(getRootFolder=getRootFolder)


def setUp(test):
    FunctionalTestSetup().setUp()


def tearDown(test):
    FunctionalTestSetup().tearDown()
Exemplo n.º 16
0
##############################################################################
#
# Copyright (c) 2007 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""zope.app.publisher common test related classes/functions/objects.

$Id$
"""

__docformat__ = "reStructuredText"

import os
from zope.app.testing.functional import ZCMLLayer

AppPublisherLayer = ZCMLLayer(os.path.join(
    os.path.split(__file__)[0], 'ftesting.zcml'),
                              __name__,
                              'AppPublisherLayer',
                              allow_teardown=True)
Exemplo n.º 17
0
import os
import unittest
import testedsample
from zope.testing import doctest
from zope.app.testing.functional import (FunctionalTestSetup, ZCMLLayer,
                                         getRootFolder, FunctionalDocFileSuite)
import zope.testbrowser.browser
import zope.testbrowser.testing

ftesting_zcml = os.path.join(os.path.dirname(testedsample.__file__),
                             'ftesting.zcml')
TestedSampleFunctionalLayer = ZCMLLayer(ftesting_zcml, __name__,
                                        'TestedSampleFunctionalLayer')


def test_suite():
    suite = unittest.TestSuite()
    docfiles = ['index.txt']

    for docfile in docfiles:
        test = FunctionalDocFileSuite(
            docfile,
            globs=dict(getRootFolder=getRootFolder,
                       Browser=zope.testbrowser.testing.Browser),
            optionflags=(doctest.ELLIPSIS
                         | doctest.REPORT_NDIFF
                         | doctest.NORMALIZE_WHITESPACE),
        )
        test.layer = TestedSampleFunctionalLayer
        suite.addTest(test)
Exemplo n.º 18
0
##############################################################################
#
# Copyright (c) 2007 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""zope.app.authentication common test related classes/functions/objects.

$Id: testing.py 72477 2007-02-09 03:25:38Z baijum $
"""

__docformat__ = "reStructuredText"

import os
from zope.app.testing.functional import ZCMLLayer

AppAuthenticationLayer = ZCMLLayer(
    os.path.join(os.path.split(__file__)[0], 'ftesting.zcml'),
    __name__, 'AppAuthenticationLayer', allow_teardown=True)
Exemplo n.º 19
0
import os

from zope.app.testing import setup
from zope.app.testing.functional import ZCMLLayer
from zope.component import provideAdapter
from zope.dublincore.interfaces import IWriteZopeDublinCore

from zopesandbox.document.interfaces import IDocument
from zopesandbox.document.document import DocumentDublinCore 

DocumentLayer = ZCMLLayer(os.path.join(os.path.dirname(__file__), 'ftesting.zcml'), __name__, 'DocumentLayer')

def setUp(test):
    setup.placefulSetUp()
    provideAdapter(DocumentDublinCore, (IDocument,), IWriteZopeDublinCore)

def tearDown(test):
    setup.placefulTearDown()
Exemplo n.º 20
0
import os.path
import testedsample
from zope.app.testing.functional import ZCMLLayer

ftesting_zcml = os.path.join(os.path.dirname(testedsample.__file__),
                             'ftesting.zcml')
FunctionalLayer = ZCMLLayer(ftesting_zcml, __name__, 'FunctionalLayer')
Exemplo n.º 21
0
import os
import unittest
import bookshelf
from zope.testing import doctest
from zope.app.testing.functional import (FunctionalTestSetup, ZCMLLayer,
                                         HTTPCaller, sync, getRootFolder)

ftesting_zcml = os.path.join(os.path.dirname(bookshelf.__file__),
                             'ftesting.zcml')
BookShelfFunctionalLayer = ZCMLLayer(ftesting_zcml, __name__,
                                     'BookShelfFunctionalLayer')


def setUp(test):
    FunctionalTestSetup().setUp()


def tearDown(test):
    FunctionalTestSetup().tearDown()


def test_suite():
    suite = unittest.TestSuite()
    test_modules = ['catalog', 'xmlrpc']

    for module in test_modules:
        module_name = 'bookshelf.ftests.%s' % module
        test = doctest.DocTestSuite(
            module_name,
            setUp=setUp,
            tearDown=tearDown,