Ejemplo n.º 1
0
    sess.auto_commit = True
    sess.session = create_session()
    return sess


def memory_session_factory():
    sqlite_testing.setup_memory_database()
    sess = session.BuilderSession()
    sess.auto_commit = False
    sess.auto_flush = True
    sess.session = create_session()
    return sess


MEMORY_DB_LAYER = sqlite_testing.StandaloneMemoryDBLayer(
    bases=(BUILDER_LAYER, set_builder_session_factory(memory_session_factory)),
    name='opengever:core:memory_db')

OPENGEVER_FIXTURE_SQLITE = OpengeverFixture(
    sql_layer=sqlite_testing.SQLITE_MEMORY_FIXTURE)

# OPENGEVER_FIXTURE is the default fixture used in policy tests.
OPENGEVER_FIXTURE = OPENGEVER_FIXTURE_SQLITE

OPENGEVER_FUNCTIONAL_TESTING = FunctionalTesting(
    bases=(OPENGEVER_FIXTURE_SQLITE,
           set_builder_session_factory(functional_session_factory)),
    name="opengever.core:functional")

OPENGEVER_FUNCTIONAL_ZSERVER_TESTING = FunctionalTesting(
    bases=(z2.ZSERVER_FIXTURE, OPENGEVER_FIXTURE_SQLITE,
Ejemplo n.º 2
0
from zope.configuration import xmlconfig
from ftw.htmlblock.tests import builders


class FtwHtmlBlockLayer(PloneSandboxLayer):

    defaultBases = (PLONE_FIXTURE, BUILDER_LAYER)

    def setUpZope(self, app, configurationContext):
        xmlconfig.string(
            '<configure xmlns="http://namespaces.zope.org/zope">'
            '  <include package="z3c.autoinclude" file="meta.zcml" />'
            '  <includePlugins package="plone" />'
            '  <includePluginsOverrides package="plone" />'
            '</configure>',
            context=configurationContext)
        z2.installProduct(app, 'ftw.simplelayout')

    def setUpPloneSite(self, portal):
        # Install into Plone site using portal_setup
        applyProfile(portal, 'ftw.simplelayout.contenttypes:default')
        applyProfile(portal, 'ftw.htmlblock:default')


FTW_HTMLBLOCK_FIXTURE = FtwHtmlBlockLayer()

FTW_HTMLBLOCK_FUNCTIONAL_TESTING = FunctionalTesting(
    bases=(FTW_HTMLBLOCK_FIXTURE,
           set_builder_session_factory(functional_session_factory)),
    name="ftw.htmlblock:functional")
Ejemplo n.º 3
0
class ThemeLayer(PloneSandboxLayer):

    defaultBases = (PLONE_FIXTURE, BUILDER_LAYER)

    def setUpZope(self, app, configurationContext):
        xmlconfig.string(
            '<configure xmlns="http://namespaces.zope.org/zope">'
            '  <include package="z3c.autoinclude" file="meta.zcml" />'
            '  <includePlugins package="plone" />'
            '  <includePluginsOverrides package="plone" />'
            "</configure>",
            context=configurationContext,
        )

        import plonetheme.onegov.tests

        xmlconfig.file("configure.zcml", plonetheme.onegov.tests, context=configurationContext)

    def setUpPloneSite(self, portal):
        applyProfile(portal, "plonetheme.onegov:default")


THEME_FIXTURE = ThemeLayer()

THEME_INTEGRATION_TESTING = IntegrationTesting(bases=(THEME_FIXTURE,), name="plonetheme.onegov:integration")

THEME_FUNCTIONAL_TESTING = FunctionalSplinterTesting(
    bases=(THEME_FIXTURE, set_builder_session_factory(functional_session_factory)), name="plonetheme.onegov:functional"
)
Ejemplo n.º 4
0
        'sqlite:///:memory:',
        connect_args={'check_same_thread': False},
        poolclass=StaticPool)
    provideUtility(
        engine_factory, provides=IEngineFactory, name=u'opengever_db')

    scoped_session = GloballyScopedSession(engine=u'opengever_db')
    provideUtility(
        scoped_session, provides=IScopedSession, name=u'opengever')

    return functional_session_factory()


MEMORY_DB_LAYER = MemoryDBLayer(
    bases=(BUILDER_LAYER,
           set_builder_session_factory(memory_session_factory)),
    name='opengever:core:memory_db')

OPENGEVER_FIXTURE = OpengeverFixture()

OPENGEVER_INTEGRATION_TESTING = IntegrationTesting(
    bases=(OPENGEVER_FIXTURE,
           set_builder_session_factory(integration_session_factory)),
    name="opengever.core:integration")

OPENGEVER_FUNCTIONAL_TESTING = FunctionalTesting(
    bases=(OPENGEVER_FIXTURE,
           set_builder_session_factory(functional_session_factory)),
    name="opengever.core:functional")

OPENGEVER_FUNCTIONAL_ZSERVER_TESTING = FunctionalTesting(
Ejemplo n.º 5
0
from plone.app.testing import PloneSandboxLayer
from plone.testing import z2
from zope.configuration import xmlconfig
import ftw.collectionblock.tests.builders


class FtwLayer(PloneSandboxLayer):
    defaultBases = (PLONE_FIXTURE, BUILDER_LAYER)

    def setUpZope(self, app, configurationContext):
        xmlconfig.string(
            '<configure xmlns="http://namespaces.zope.org/zope">'
            '  <include package="z3c.autoinclude" file="meta.zcml" />'
            '  <includePlugins package="plone" />'
            '  <includePluginsOverrides package="plone" />'
            "</configure>",
            context=configurationContext,
        )

        z2.installProduct(app, "ftw.simplelayout")

    def setUpPloneSite(self, portal):
        applyProfile(portal, "ftw.simplelayout.contenttypes:default")
        applyProfile(portal, "ftw.collectionblock:default")


FTW_FIXTURE = FtwLayer()
FTW_FUNCTIONAL = FunctionalTesting(
    bases=(FTW_FIXTURE, set_builder_session_factory(functional_session_factory)), name="ftw.collectionblock:functional"
)
Ejemplo n.º 6
0
    def setUpZope(self, app, configurationContext):
        import z3c.autoinclude

        xmlconfig.file("meta.zcml", z3c.autoinclude, context=configurationContext)
        xmlconfig.string(
            '<configure xmlns="http://namespaces.zope.org/zope">' '  <includePlugins package="plone" />' "</configure>",
            context=configurationContext,
        )

        import ftw.blog

        xmlconfig.file("configure.zcml", ftw.blog, context=configurationContext)

        z2.installProduct(app, "ftw.blog")

    def setUpPloneSite(self, portal):
        applyProfile(portal, "ftw.blog:default")

        wftool = getToolByName(portal, "portal_workflow")
        wftool.setChainForPortalTypes(["Blog", "BlogEntry"], "one_state_workflow")

        setRoles(portal, TEST_USER_ID, ["Contributor"])
        login(portal, TEST_USER_NAME)


FTW_BLOG_FIXTURE = FtwBlogLayer()
FTW_BLOG_INTEGRATION_TESTING = IntegrationTesting(bases=(FTW_BLOG_FIXTURE,), name="FtwBlog:Integration")
FTW_BLOG_FUNCTIONAL_TESTING = FunctionalTesting(
    bases=(FTW_BLOG_FIXTURE, set_builder_session_factory(functional_session_factory)), name="FtwBlog:Functional"
)
Ejemplo n.º 7
0
from ftw.builder.testing import set_builder_session_factory
from plone.app.testing import applyProfile
from plone.app.testing import FunctionalTesting
from plone.app.testing import PLONE_FIXTURE
from plone.app.testing import PloneSandboxLayer
from zope.configuration import xmlconfig


class RedirectorLayer(PloneSandboxLayer):
    defaultBases = (PLONE_FIXTURE, BUILDER_LAYER)

    def setUpZope(self, app, configurationContext):
        xmlconfig.string(
            '<configure xmlns="http://namespaces.zope.org/zope">'
            '  <include package="z3c.autoinclude" file="meta.zcml" />'
            '  <includePlugins package="plone" />'
            '  <includePluginsOverrides package="plone" />'
            "</configure>",
            context=configurationContext,
        )

    def setUpPloneSite(self, portal):
        applyProfile(portal, "ftw.redirector:default")


REDIRECTOR_FIXTURE = RedirectorLayer()
REDIRECTOR_FUNCTIONAL = FunctionalTesting(
    bases=(REDIRECTOR_FIXTURE, set_builder_session_factory(functional_session_factory)),
    name="ftw.redirector:functional",
)
Ejemplo n.º 8
0
    def setUpZope(self, app, configurationContext):
        xmlconfig.string(
            '<configure xmlns="http://namespaces.zope.org/zope">'
            '  <include package="z3c.autoinclude" file="meta.zcml" />'
            '  <includePlugins package="plone" />'
            '  <includePluginsOverrides package="plone" />'
            '</configure>',
            context=configurationContext)

        import ftw.tabbedview.tests
        xmlconfig.file('tests.zcml', ftw.tabbedview.tests,
                       context=configurationContext)
        xmlconfig.file('tabs.zcml', ftw.tabbedview.tests,
                       context=configurationContext)
        xmlconfig.file('profiles/profiles.zcml', ftw.tabbedview.tests,
                       context=configurationContext)

    def setUpPloneSite(self, portal):
        applyProfile(portal, 'ftw.tabbedview:default')
        applyProfile(portal, 'ftw.tabbedview.tests:tabs')
        if IS_PLONE_5:
            applyProfile(portal, 'plone.app.contenttypes:default')


TABBED_VIEW_LAYER = TabbedViewLayer()
TABBEDVIEW_INTEGRATION_TESTING = IntegrationTesting(
    bases=(TABBED_VIEW_LAYER, ), name="ftw.tabbedview:integration")
TABBEDVIEW_FUNCTIONAL_TESTING = FunctionalTesting(
    bases=(TABBED_VIEW_LAYER, set_builder_session_factory(functional_session_factory)),
    name="ftw.tabbedview:functional")
Ejemplo n.º 9
0
            '  <includePluginsOverrides package="plone" />'
            '</configure>',
            context=configurationContext,
        )

        import Products.CMFPlacefulWorkflow
        xmlconfig.file('configure.zcml', Products.CMFPlacefulWorkflow, context=configurationContext)

        try:
            # Plone >= 4.3.x
            import Products.DataGridField
            xmlconfig.file('configure.zcml', Products.DataGridField, context=configurationContext)
        except:
            pass

        z2.installProduct(app, 'ftw.file')
        z2.installProduct(app, 'ftw.meeting')
        z2.installProduct(app, 'ftw.workspace')

    def setUpPloneSite(self, portal):
        applyProfile(portal, 'ftw.mail:default')
        applyProfile(portal, 'ftw.workspace:default')
        applyProfile(portal, 'ftw.zipexport:default')


FTW_MAIL_LAYER = FtwMailLayer()
FTW_MAIL_FUNCTIONAL_TESTING = FunctionalTesting(
    bases=(FTW_MAIL_LAYER, set_builder_session_factory(functional_session_factory)),
    name="ftw.mail:functional",
)
Ejemplo n.º 10
0
            context=configurationContext,
        )

        import Products.CMFPlacefulWorkflow

        xmlconfig.file("configure.zcml", Products.CMFPlacefulWorkflow, context=configurationContext)

        try:
            # Plone >= 4.3.x
            import Products.DataGridField

            xmlconfig.file("configure.zcml", Products.DataGridField, context=configurationContext)
        except:
            pass

        z2.installProduct(app, "ftw.file")
        z2.installProduct(app, "ftw.meeting")
        z2.installProduct(app, "ftw.mail")
        z2.installProduct(app, "ftw.workspace")

    def setUpPloneSite(self, portal):
        applyProfile(portal, "ftw.mail:default")
        applyProfile(portal, "ftw.workspace:default")
        applyProfile(portal, "ftw.zipexport:default")


FTW_MAIL_LAYER = FtwMailLayer()
FTW_MAIL_FUNCTIONAL_TESTING = FunctionalTesting(
    bases=(FTW_MAIL_LAYER, set_builder_session_factory(functional_session_factory)), name="ftw.mail:functional"
)
Ejemplo n.º 11
0
        applyProfile(portal, "ftw.book:default")
        applyProfile(portal, "ftw.tabbedview:default")
        applyProfile(portal, "ftw.zipexport:default")

        setRoles(portal, TEST_USER_ID, ["Manager"])
        login(portal, TEST_USER_NAME)

    def tearDown(self):
        super(FtwBookLayer, self).tearDown()
        clear_transmogrifier_registry()


FTW_BOOK_FIXTURE = FtwBookLayer()
FTW_BOOK_INTEGRATION_TESTING = IntegrationTesting(bases=(FTW_BOOK_FIXTURE,), name="ftw.book:Integration")
FTW_BOOK_FUNCTIONAL_TESTING = FunctionalTesting(
    bases=(FTW_BOOK_FIXTURE, set_builder_session_factory(functional_session_factory)), name="ftw.book:Functional"
)


class ExampleContentLayer(Layer):

    defaultBases = (FTW_BOOK_FIXTURE,)

    def setUp(self):
        # Stack the component registry
        self["configurationContext"] = zca.stackConfigurationContext(self.get("configurationContext"))

        # Stack the database
        self["zodbDB"] = zodb.stackDemoStorage(self.get("zodbDB"), name="ftw.book:examplecontent")

        # Register and apply the example content GS profile