"""Base module for unittesting."""

from plone.app.testing import applyProfile
from plone.app.testing import FunctionalTesting
from plone.app.testing import IntegrationTesting
from plone.app.testing import MOCK_MAILHOST_FIXTURE
from plone.app.testing import PloneSandboxLayer
from ploneintranet.userprofile.testing import PLONEINTRANET_USERPROFILE_FIXTURE

import ploneintranet
import unittest


class PloneintranetTodoLayer(PloneSandboxLayer):

    defaultBases = (PLONEINTRANET_USERPROFILE_FIXTURE,)

    def setUpZope(self, app, configurationContext):
        self.loadZCML(package=ploneintranet.todo)

    def setUpPloneSite(self, portal):
        # Install into Plone site using portal_setup
        applyProfile(portal, "ploneintranet.todo:default")


FIXTURE = PloneintranetTodoLayer()

INTEGRATION_TESTING = IntegrationTesting(
    bases=(FIXTURE, MOCK_MAILHOST_FIXTURE), name="PloneintranetTodoLayer:Integration"
)
FUNCTIONAL_TESTING = FunctionalTesting(
    bases=(FIXTURE,), name="PloneintranetTodoLayer:Functional"
)


class IntegrationTestCase(unittest.TestCase):
    """Base class for integration tests."""

    layer = INTEGRATION_TESTING


class FunctionalTestCase(unittest.TestCase):
    """Base class for functional tests."""

    layer = FUNCTIONAL_TESTING
