Ejemplo n.º 1
0
        self.loadZCML(package=ploneintranet.docconv.client)

        import ploneintranet.layout
        self.loadZCML(package=ploneintranet.layout)

    def setUpPloneSite(self, portal):
        self.applyProfile(portal, 'ploneintranet.docconv.client:default')
        self.applyProfile(portal, 'ploneintranet.library:default')

    # def tearDownPloneSite(self, portal):
    #     super(PloneintranetLibraryLayer, self).tearDownPloneSite(portal)


FIXTURE = PloneintranetLibraryLayer()
INTEGRATION_TESTING = testing.IntegrationTesting(
    bases=(FIXTURE, ), name="PloneintranetLibraryLayer:Integration")
FUNCTIONAL_TESTING = testing.FunctionalTesting(
    bases=(FIXTURE, ), name="PloneintranetLibraryLayer: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
Ejemplo n.º 2
0
# -*- coding: utf-8 -*-
from plone.app.imaging.monkey import unpatchImageField
from plone.app import testing
from plone.app.testing.bbb_at import PloneTestCaseFixture
from plone.testing import z2


class ImagingFixture(PloneTestCaseFixture):
    """ Test fixture for plone.app.imaging """
    def setUpZope(self, app, configurationContext):
        super(ImagingFixture, self).setUpZope(app, configurationContext)
        import plone.app.imaging
        self.loadZCML(package=plone.app.imaging)
        z2.installProduct(app, 'plone.app.imaging')

    def setUpPloneSite(self, portal):
        super(ImagingFixture, self).setUpPloneSite(portal)

    def tearDownZope(self, app):
        super(ImagingFixture, self).tearDownZope(app)
        unpatchImageField()
        z2.uninstallProduct(app, 'plone.app.imaging')


PTC_FIXTURE = ImagingFixture()
imaging = testing.FunctionalTesting(bases=(PTC_FIXTURE, ),
                                    name='ImagingTestCase:Functional')
Ejemplo n.º 3
0
import plone.app.textfield
from plone.app.testing.bbb import PloneTestCase
from plone.app import testing
from plone.testing import layered


class IntegrationFixture(testing.PloneSandboxLayer):

    defaultBases = (testing.PLONE_FIXTURE, )

    def setUpZope(self, app, configurationContext):
        self.loadZCML(package=plone.app.textfield)


PTC_FIXTURE = IntegrationFixture()
IntegrationLayer = testing.FunctionalTesting(
    bases=(PTC_FIXTURE, ), name='PloneAppTextfieldTest:Functional')


class TestIntegration(PloneTestCase):

    layer = IntegrationLayer

    def testTransformPlain(self):
        from zope.interface import Interface
        from plone.app.textfield import RichText

        class IWithText(Interface):

            text = RichText(title=u"Text",
                            default_mime_type='text/plain',
                            output_mime_type='text/html')
Ejemplo n.º 4
0
from plone.app import testing


class ConferenceFixture(testing.PloneSandboxLayer):
    default_bases = (testing.PLONE_FIXTURE, )

    def setUpZope(self, app, configurationContext):
        # Load ZCML
        import netsight.conferenceregistration
        self.loadZCML(package=netsight.conferenceregistration)

    def setUpPloneSite(self, portal):
        # Install into Plone site using portal_setup
        self.applyProfile(portal, 'netsight.conferenceregistration:default')


CONFERENCE_FIXTURE = ConferenceFixture()
CONFERENCE_FUNCTIONAL_TESTING = testing.FunctionalTesting(
    bases=(CONFERENCE_FIXTURE, ), name="Conference:Functional")
Ejemplo n.º 5
0
from zope.configuration import xmlconfig

from plone.testing import z2
from plone.app import testing

from Acquisition import aq_parent

from plone.app.toolbar import testing as toolbar


class MyRecentLayer(testing.PloneSandboxLayer):

    defaultBases = (toolbar.TOOLBAR_FIXTURE, )

    def setUpZope(self, app, configurationContext):
        import collective.myrecentcontent
        xmlconfig.file('configure.zcml',
                       collective.myrecentcontent,
                       context=configurationContext)

    def setUpPloneSite(self, portal):
        z2.login(aq_parent(portal)['acl_users'], testing.SITE_OWNER_NAME)
        portal.invokeFactory(type_name='Document', id='front-page')


MY_RECENT_FIXTURE = MyRecentLayer()
MY_RECENT_FUNCTIONAL_TESTING = testing.FunctionalTesting(
    bases=(MY_RECENT_FIXTURE, ), name="MyRecentLayer:Functional")
Ejemplo n.º 6
0
        self.loadZCML(package=tests, name='testing.zcml')
        z2.installProduct(app, 'plone.app.blob')

    def setUpPloneSite(self, portal):
        # install cmfeditions
        self.applyProfile(portal, 'plone.app.blob:sample-type')
        types = getToolByName(portal, 'portal_types')
        assert types.getTypeInfo('Blob').product == 'plone.app.blob'

    def tearDownZope(self, app):
        z2.uninstallProduct(app, 'plone.app.blob')


BLOB_FIXTURE = BlobFixture()
BlobLayer = testing.FunctionalTesting(
    bases=(BLOB_FIXTURE, ),
    name='Blob:Functional',
)


class BlobReplacementFixture(PloneTestCaseFixture):
    """ layer for integration tests using replacement types """

    defaultBases = (BLOB_FIXTURE, )

    def setUpZope(self, app, configurationContext):
        from plone.app import imaging
        self.loadZCML(package=imaging)
        z2.installProduct(app, 'plone.app.imaging')

    def setUpPloneSite(self, portal):
        for name in ['file', 'image']:
Ejemplo n.º 7
0
    def setUpZope(self, app, configurationContext):
        profile_registry.registerProfile('CMFDVFTI_sampletypes',
            'CMFDynamicViewFTI Sample Content Types',
            'Extension profile including CMFDVFTI sample content types',
            'profiles/sample_types',
            'CMFDynamicViewFTI',
            EXTENSION,
            for_=ISiteRoot)
        import Products.CMFDynamicViewFTI.tests
        self.loadZCML(name='browserdefault.zcml',
                      package=Products.CMFDynamicViewFTI.tests)

    def setUpPloneSite(self, portal):
        self.applyProfile(portal, 'CMFDynamicViewFTI:CMFDVFTI_sampletypes')

    def tearDownZope(self, app):
        pass

CDV_FIXTURE = PloneTestCaseFixture()
CDV_FUNCTIONAL_TESTING = testing.FunctionalTesting(
    bases=(CDV_FIXTURE, ), name='CMFDynamicViewFTI Testing:Functional')


class CMFDVFTITestCase(bbb.PloneTestCase):
    """This is a stub now, but in case you want to try
       something fancy on Your Branch (tm), put it here.
    """

    layer = CDV_FUNCTIONAL_TESTING
Ejemplo n.º 8
0
        sm.registerUtility(mailhost, provided=IMailHost)
        portal.email_from_address = '*****@*****.**'
        commit()

    def tearDownPloneSite(self, portal):
        portal.MailHost = portal._original_MailHost
        sm = getSiteManager(context=portal)
        sm.unregisterUtility(provided=IMailHost)
        sm.registerUtility(
            aq_base(portal._original_MailHost),
            provided=IMailHost
        )

MOCK_MAIL_FIXTURE = MockMailFixture()
MM_FUNCTIONAL_TESTING = testing.FunctionalTesting(
    bases=(MOCK_MAIL_FIXTURE, ),
    name='PloneTestCase:Functional'
)


def test_suite():
    return unittest.TestSuite((
        layered(
            doctest.DocFileSuite(
                'browser.txt',
                optionflags=OPTIONFLAGS,
                package='Products.PasswordResetTool.tests',
            ),
            layer=MM_FUNCTIONAL_TESTING
        ),
        layered(
            doctest.DocFileSuite(
Ejemplo n.º 9
0
from plone.app.testing import bbb
from plone.app import testing


class PloneTestCaseFixture(bbb.PloneTestCaseFixture):

    defaultBases = (bbb.PTC_FIXTURE, )

    def setUpZope(self, app, configurationContext):
        from Products import contentmigration
        self.loadZCML('testing.zcml', package=contentmigration)
        self.loadZCML('testing-schemaextender.zcml', package=contentmigration)


PCM_FIXTURE = PloneTestCaseFixture()
TestLayer = testing.FunctionalTesting(
    bases=(PCM_FIXTURE, ), name='PloneContentMigrationTestCase:Functional')

SchemaExtenderTestLayer = TestLayer
Ejemplo n.º 10
0
class PloneOrgFixture(testing.PloneSandboxLayer):
    default_bases = (testing.PLONE_FIXTURE, )

    def setUpZope(self, app, configurationContext):
        # Load ZCML
        import Products.PloneOrg
        self.loadZCML(package=Products.PloneOrg)

    def setUpPloneSite(self, portal):
        # Install into Plone site using portal_setup
        self.applyProfile(portal, 'Products.PloneOrg:default')

        # Add some members to some groups for testing the team page
        portal_membership = getToolByName(portal, 'portal_membership')
        gtool = getToolByName(portal, 'portal_groups')

        portal_membership.addMember('limi', 'secret', ['Member'], ())
        gtool.addPrincipalToGroup('limi', 'Founders')

        portal_membership.addMember('runyaga', 'secret', ['Member'], ())
        gtool.addPrincipalToGroup('runyaga', 'Founders')

        portal_membership.addMember('esteele', 'secret', ['Member'], ())
        gtool.addPrincipalToGroup('esteele', 'ReleaseManagers')


PLONEORG_FIXTURE = PloneOrgFixture()
PLONEORG_FUNCTIONAL_TESTING = testing.FunctionalTesting(
    bases=(PLONEORG_FIXTURE, ), name="PloneOrg:Functional")
Ejemplo n.º 11
0
            for_=ISiteRoot)
        z2.installProduct(app, 'Products.CMFPlacefulWorkflow')

    def setUpPloneSite(self, portal):
        super(PlacefulWorkflowLayer, self).setUpPloneSite(portal)
        # install sunburst theme
        testing.applyProfile(
            portal, 'Products.CMFPlacefulWorkflow:CMFPlacefulWorkflow')

    def tearDownZope(self, app):
        super(PlacefulWorkflowLayer, self).tearDownZope(app)
        z2.uninstallProduct(app, 'Products.CMFPlacefulWorkflow')


PWF_FIXTURE = PlacefulWorkflowLayer()
PWF_LAYER = testing.FunctionalTesting(
    bases=(PWF_FIXTURE, ), name='PlacefulWorkflowTestCase:Functional')


class CMFPlacefulWorkflowTestCase(PloneTestCase):

    layer = PWF_LAYER

    class Session(dict):
        def set(self, key, value):
            self[key] = value

    def _setup(self):
        PloneTestCase.PloneTestCase._setup(self)
        self.app.REQUEST['SESSION'] = self.Session()

    def getPermissionsOfRole(self, role):
from Products.CMFCore.utils import getToolByName


class PloneFixture(testing.PloneSandboxLayer):
    """A fixture which just loads the package code."""
    defaultBases = (testing.PLONE_FIXTURE, )

    def setUpZope(self, app, configurationContext):
        # Load ZCML
        import collective.sponsorship
        self.loadZCML(package=collective.sponsorship)


PLONE_FIXTURE = PloneFixture()
PLONE_FUNCTIONAL_TESTING = testing.FunctionalTesting(
    bases=(PLONE_FIXTURE, ), name="SponsorshipPlone:Functional")


class SponsorshipFixture(testing.PloneSandboxLayer):
    """A fixture which installs the profile."""
    defaultBases = (PLONE_FIXTURE, )

    def setUpPloneSite(self, portal):
        # Install into Plone site using portal_setup
        self.applyProfile(portal, 'collective.sponsorship:default')

        testing.login(aq_parent(portal), 'admin')
        wftool = getToolByName(portal, 'portal_workflow')
        wftool.setDefaultChain('simple_publication_workflow')
        wftool.doActionFor(portal.sponsorships, 'publish')
        testing.logout()
class ServicesFixture(testing.PloneSandboxLayer):
    default_bases = (testing.PLONE_FIXTURE, )

    def setUpZope(self, app, configurationContext):
        # Load ZCML
        import Products.PloneServicesCenter
        self.loadZCML(package=Products.PloneServicesCenter)

        # Install product and call its initialize() function
        z2.installProduct(app, 'Products.ArchAddOn')
        z2.installProduct(app, 'Products.PloneServicesCenter')

    def setUpPloneSite(self, portal):
        # Install into Plone site using portal_setup
        getToolByName(
            portal,
            'portal_quickinstaller').installProduct('Products.ArchAddOn')
        self.applyProfile(portal, 'Products.PloneServicesCenter:default')

        # Publish the folders
        z2.login(aq_parent(portal).acl_users, 'admin')
        wftool = getToolByName(portal, 'portal_workflow')
        for id_ in ('case-studies', 'sites', 'providers'):
            wftool.doActionFor(portal.support[id_], 'publish')
        z2.logout()


SERVICES_FIXTURE = ServicesFixture()
SERVICES_FUNCTIONAL_TESTING = testing.FunctionalTesting(
    bases=(SERVICES_FIXTURE, ), name="Services:Functional")
Ejemplo n.º 14
0
             name=name,
             zcml_filename=b'configure.zcml',
             zcml_package=import_module(__package__),
             additional_z2_products=(__package__, ),
             gs_profile_id=b'%s:default' % (__package__, ))

    def tearDownPloneSite(self, portal):
        self.applyProfile(portal, b'%s:uninstall' % (__package__, ))


FIXTURE = SecurityIndexingLayer()

INTEGRATION = pa_testing.IntegrationTesting(
    bases=(FIXTURE, ), name=b'SecurityIndexingLayer:Integration')

FUNCTIONAL = pa_testing.FunctionalTesting(
    bases=(FIXTURE, ), name=b'SecurityIndexingLayer:Functional')


class TestCaseMixin(object):
    """Base mixin class for unittest.TestCase."""
    def _set_default_workflow_chain(self, workflow_id):
        wftool = api.portal.get_tool(name=b'portal_workflow')
        wftool.setDefaultChain(workflow_id)

    def _id_for_path(self, path):
        return path.split('/')[-1]

    def _create_folder(self,
                       path,
                       local_roles,
                       userid=pa_testing.TEST_USER_ID,
Ejemplo n.º 15
0
                return True
            return TEST_PATCHES['orig_isProductInstallable'](self, productname)

        QuickInstallerTool.isProductInstallable = patched_isProductInstallable

    def tearDownPloneSite(self, portal):
        QuickInstallerTool.isProductInstallable = TEST_PATCHES[
            'orig_isProductInstallable']  # noqa
        profile_registry.unregisterProfile('test',
                                           'Products.CMFQuickInstallerTool')
        sm = zope.component.getSiteManager()
        sm.unregisterHandler(handleBeforeProfileImportEvent)
        sm.unregisterHandler(handleProfileImportedEvent)


CQI_FIXTURE = QuickInstallerCaseFixture()
CQI_FUNCTIONAL_TESTING = testing.FunctionalTesting(
    bases=(CQI_FIXTURE, ), name='CMFQuickInstallerToolTest:Functional')


def test_suite():
    suite = unittest.TestSuite()
    for testfile in ['actions.txt', 'profiles.txt', 'install.txt']:
        suite.addTest(
            layered(doctest.DocFileSuite(
                testfile,
                package='Products.CMFQuickInstallerTool.tests',
                optionflags=OPTIONFLAGS),
                    layer=CQI_FUNCTIONAL_TESTING))
    return suite
from Products.CMFCore.utils import getToolByName
from six import StringIO
from six.moves.urllib.parse import urlencode

import re
import transaction


class ControlPanelFixture(PloneTestCaseFixture):
    def setUpPloneSite(self, portal):
        super(ControlPanelFixture, self).setUpPloneSite(portal)
        portal.acl_users.userFolderAddUser('root', 'secret', ['Manager'], [])


CP_FIXTURE = ControlPanelFixture()
CP_FUNCTIONAL_LAYER = testing.FunctionalTesting(bases=(CP_FIXTURE, ),
                                                name='ControlPanel:Functional')


class UserGroupsControlPanelTestCase(FunctionalTestCase):
    """user/groups-specific test case"""

    layer = CP_FUNCTIONAL_LAYER

    def afterSetUp(self):
        super(UserGroupsControlPanelTestCase, self).afterSetUp()
        members = [
            {
                'username': '******',
                'fullname': 'Kevin Hughes',
                'email': '*****@*****.**'
            },
Ejemplo n.º 17
0
class PloneI18nLayer(PloneSandboxLayer):

    defaultBases = (PLONE_APP_CONTENTTYPES_FIXTURE, )

    def setUpZope(self, app, configurationContext):
        import plone.i18n

        # Needed to have ILanguage adapter for dx
        import plone.app.multilingual

        self.loadZCML(package=plone.i18n)
        self.loadZCML(package=plone.app.multilingual)


PLT_FIXTURE = PloneI18nLayer()
PLT_FUNCTIONAL_TESTING = testing.FunctionalTesting(
    bases=(PLT_FIXTURE, ), name='Plonei18nTestCase:Functional')


class TestCase(bbb.PloneTestCase):
    """Simple test case
    """

    layer = PLT_FUNCTIONAL_TESTING


class FunctionalTestCase(TestCase):
    """Simple test case for functional tests
    """
Ejemplo n.º 18
0
        self.loadZCML(package=tests, name='testing.zcml')
        z2.installProduct(app, 'plone.app.blob')

    def setUpPloneSite(self, portal):
        # install cmfeditions
        self.applyProfile(portal, 'plone.app.blob:sample-type')
        types = getToolByName(portal, 'portal_types')
        assert types.getTypeInfo('Blob').product == 'plone.app.blob'

    def tearDownZope(self, app):
        z2.uninstallProduct(app, 'plone.app.blob')


BLOB_FIXTURE = BlobFixture()
BlobLayer = testing.FunctionalTesting(
    bases=(BLOB_FIXTURE, ),
    name='Blob:Functional',
)


class BlobReplacementFixture(PloneTestCaseFixture):
    """ layer for integration tests using replacement types """

    defaultBases = (BLOB_FIXTURE, )

    def setUpZope(self, app, configurationContext):
        from plone.app import imaging
        self.loadZCML(package=imaging)
        z2.installProduct(app, 'plone.app.imaging')

    def setUpPloneSite(self, portal):
        for name in ['file', 'image']: