コード例 #1
0
ファイル: functional.py プロジェクト: l1ph0x/schooltool-2
    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()
コード例 #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)
コード例 #3
0
 def tearDown(self):
     _ZCMLLayer.tearDown(self)
     clear_mappers()
コード例 #4
0
 def setUp(self):
     _ZCMLLayer.setUp(self)
     for name, utility in getUtilitiesFor(IDatabase):
         utility.setMappers()
コード例 #5
0
 def __init__(self, *args, **kwargs):
     kwargs['allow_teardown'] = True
     _ZCMLLayer.__init__(self, *args, **kwargs)
コード例 #6
0
##############################################################################
#
# 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)
コード例 #7
0
ファイル: tests.py プロジェクト: brambgit/bioport-site
 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)
コード例 #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,
    ])
コード例 #9
0
ファイル: testing.py プロジェクト: bendavis78/zope
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)
コード例 #10
0
ファイル: functional.py プロジェクト: l1ph0x/schooltool-2
 def __init__(self, *args, **kwargs):
     kwargs['allow_teardown'] = True
     _ZCMLLayer.__init__(self, *args, **kwargs)
コード例 #11
0
ファイル: test_functional.py プロジェクト: bendavis78/zope
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()
コード例 #12
0
ファイル: tests.py プロジェクト: eea/lovely.memcached
# 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')
コード例 #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)
コード例 #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)
コード例 #15
0
ファイル: test_functional.py プロジェクト: bendavis78/zope
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()
コード例 #16
0
ファイル: testing.py プロジェクト: bendavis78/zope
##############################################################################
#
# 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)
コード例 #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)
コード例 #18
0
ファイル: testing.py プロジェクト: bendavis78/zope
##############################################################################
#
# 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)
コード例 #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()
コード例 #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')
コード例 #21
0
ファイル: test_functional.py プロジェクト: bendavis78/zope
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,