# -*- coding: utf-8 -*-
"""Test Layer for {{{ package.dottedname }}}."""

# zope imports
from plone.app.robotframework.testing import REMOTE_LIBRARY_BUNDLE_FIXTURE
from plone.app.testing import (
    FunctionalTesting,
    IntegrationTesting,
    PloneSandboxLayer,
    PLONE_FIXTURE,
    applyProfile,
)
from plone.testing import (
    Layer,
    z2,
)
from zope.configuration import xmlconfig


class {{{ package.testlayer }}}(PloneSandboxLayer):
    """Custom Test Layer for {{{ package.dottedname }}}."""
    defaultBases = (PLONE_FIXTURE, )

    def setUpZope(self, app, configurationContext):
        """Set up Zope for testing."""
        # Load ZCML
        import {{{ package.dottedname }}}
        xmlconfig.file(
            'configure.zcml',
            {{{ package.dottedname }}},
            context=configurationContext
        )

    def setUpPloneSite(self, portal):
        applyProfile(portal, '{{{ package.dottedname }}}:default')


{{{ package.uppercasename }}}_FIXTURE = {{{ package.testlayer }}}()


{{{ package.uppercasename }}}_INTEGRATION_TESTING = IntegrationTesting(
    bases=({{{ package.uppercasename }}}_FIXTURE,),
    name='{{{ package.testlayer }}}:IntegrationTesting'
)


{{{ package.uppercasename }}}_FUNCTIONAL_TESTING = FunctionalTesting(
    bases=({{{ package.uppercasename }}}_FIXTURE,),
    name='{{{ package.testlayer }}}:FunctionalTesting'
)


{{{ package.uppercasename }}}_ACCEPTANCE_TESTING = FunctionalTesting(
    bases=(
        {{{ package.uppercasename }}}_FIXTURE,
        REMOTE_LIBRARY_BUNDLE_FIXTURE,
        z2.ZSERVER_FIXTURE
    ),
    name='{{{ package.testlayer }}}:AcceptanceTesting'
)


ROBOT_TESTING = Layer(name='{{{ package.dottedname }}}:Robot')
