Ejemplo n.º 1
0
def test_suite():
    import unittest
    from zope.testing import doctest
    optionflags = doctest.ELLIPSIS
    from Products.PloneTestCase.layer import PloneSite, ZCMLLayer
    from wicked.plone.tests import ZCMLLayer as PloneWickedZCMLLayer
    from Testing.ZopeTestCase import ZopeDocFileSuite, FunctionalDocFileSuite
    from Products.PloneTestCase import ptc
    ptc.setupPloneSite()
    renderer = ZopeDocFileSuite('renderer.txt',
                                package='wicked.at',
                                optionflags=optionflags)
    renderer.layer = ZCMLLayer
    add = FunctionalDocFileSuite('add.txt',
                           package='wicked.at',
                           test_class=ptc.FunctionalTestCase,
                           optionflags=optionflags)
    add.layer = PloneWickedZCMLLayer
    return unittest.TestSuite((add, renderer))
Ejemplo n.º 2
0
def test_suite():
    import unittest
    from zope.testing import doctest
    optionflags = doctest.ELLIPSIS
    from Products.PloneTestCase.layer import PloneSite, ZCMLLayer
    from wicked.plone.tests import ZCMLLayer as PloneWickedZCMLLayer
    from Testing.ZopeTestCase import ZopeDocFileSuite, FunctionalDocFileSuite
    from Products.PloneTestCase import ptc
    ptc.setupPloneSite()
    renderer = ZopeDocFileSuite('renderer.txt',
                                package='wicked.at',
                                optionflags=optionflags)
    renderer.layer = ZCMLLayer
    add = FunctionalDocFileSuite('add.txt',
                                 package='wicked.at',
                                 test_class=ptc.FunctionalTestCase,
                                 optionflags=optionflags)
    add.layer = PloneWickedZCMLLayer
    return unittest.TestSuite((add, renderer))
Ejemplo n.º 3
0
class TransmogrifierLayer(BasePTCLayer):
    """ layer for integration tests """

    ptc.setupPloneSite(id="target")

    def afterSetUp(self):
        fiveconfigure.debug_mode = True
        from quintagroup import transmogrifier
        zcml.load_config('testing.zcml', transmogrifier)
        fiveconfigure.debug_mode = False
        installPackage('quintagroup.transmogrifier', quiet=True)
        self.addProfile('quintagroup.transmogrifier:default')
        self.createDemoContent()

    def createDemoContent(self):
        self.loginAsPortalOwner()
        self.portal.news.invokeFactory('News Item',
                                       id='hold-the-press',
                                       title=u"Høld the Press!")
        self.portal.events.invokeFactory('Event',
                                         id='party',
                                         title=u"Süper Pärty",
                                         startDate='2010/01/01 15:00:00 GMT+1',
                                         endDate='2010/01/01 15:00:00 GMT+1')
Ejemplo n.º 4
0
from Products.PloneTestCase import ptc
from Products.Five import zcml, fiveconfigure
from Products.Five.testbrowser import Browser
from collective.testcaselayer.ptc import BasePTCLayer, ptc_layer

ptc.installProduct('SimpleAttachment', quiet=True)
ptc.installProduct('RichDocument', quiet=True)
ptc.setupPloneSite(products=['SimpleAttachment', 'RichDocument'])


class Layer(BasePTCLayer):
    """ basic layer for testing """
    def afterSetUp(self):
        # load zcml for this package...
        fiveconfigure.debug_mode = True
        from Products import SimpleAttachment
        zcml.load_config('configure.zcml', package=SimpleAttachment)
        fiveconfigure.debug_mode = False


layer = Layer(bases=[ptc_layer])


class IntegrationTestCase(ptc.PloneTestCase):
    """ base class for integration tests """

    layer = layer


class FunctionalTestCase(ptc.FunctionalTestCase):
    """ base class for functional tests """
Ejemplo n.º 5
0
from Testing import ZopeTestCase as ztc

from Products.PloneTestCase import ptc
from Products.PloneTestCase import layer
from Products.Five import zcml
from Products.Five import fiveconfigure

ptc.setupPloneSite(
    extension_profiles=('collective.akismet:default', )
)

class AkismetLayer(layer.PloneSite):
    """Configure collective.akismet"""

    @classmethod
    def setUp(cls):
        fiveconfigure.debug_mode = True
        import collective.akismet
        zcml.load_config("configure.zcml", collective.akismet)
        fiveconfigure.debug_mode = False
        ztc.installPackage("collective.akismet", quiet=1)

    @classmethod
    def tearDown(cls):
        pass
Ejemplo n.º 6
0
import transaction
from zope.site.hooks import setSite

from Testing.ZopeTestCase.sandbox import Sandboxed
from Products.PloneTestCase.layer import PloneSiteLayer
from Products.PloneTestCase.ptc import PloneTestCase
from Products.PloneTestCase.ptc import setupPloneSite

from Products.CMFCore.interfaces import IActionCategory
from Products.CMFCore.interfaces import IActionInfo
from Products.CMFCore.utils import getToolByName
from Products.CMFCore.tests.base.testcase import WarningInterceptor
from Products.GenericSetup.context import TarballImportContext

setupPloneSite()


class MigrationTest(PloneTestCase):

    def removeActionFromTool(self, action_id, category=None, action_provider='portal_actions'):
        # Removes an action from portal_actions
        tool = getToolByName(self.portal, action_provider)
        if category is None:
            if action_id in tool.objectIds() and IActionInfo.providedBy(tool._getOb(action_id)):
                tool._delOb(action_id)
        else:
            if category in tool.objectIds() and IActionCategory.providedBy(tool._getOb(category)):
                if action_id in tool.objectIds() and IActionInfo.providedBy(tool._getOb(action_id)):
                    tool._delOb(action_id)
Ejemplo n.º 7
0
TITLE1 = "Cop Shop"
TITLE2 = 'DMV Computer has died'

import transaction as txn
#from collective.testing.debug import autopsy


@onsetup
def register_package():
    import wicked.atcontent
    zcml.load_config("configure.zcml", package=wicked.atcontent)
    installPackage('wicked.atcontent')


register_package()
ptc.setupPloneSite(products=['wicked.atcontent'])


class WickedSite(PloneSite):
    @classmethod
    def setUp(cls):
        app = ZopeTestCase.app()
        plone = app.plone
        reg = BasePloneWickedRegistration(plone)
        reg.handle()
        # install the product
        qi = plone.portal_quickinstaller
        qi.installProduct('wicked.atcontent')
        txn.commit()
        ZopeTestCase.close(app)
Ejemplo n.º 8
0
import os, sys

import unittest
from zope.testing.doctest import ELLIPSIS

from Testing.ZopeTestCase import installProduct
from Products.PloneTestCase.ptc import setupPloneSite

# don't need to install products in lib/python
setupPloneSite()

from Products.CMFCore.utils import getToolByName
from Products.PloneTestCase.PloneTestCase import FunctionalTestCase
from Products.PloneTestCase.setup import _createObjectByType
from Testing.ZopeTestCase import ZopeDocFileSuite, FunctionalDocFileSuite


class TestCase(FunctionalTestCase):
    """Passubscribers test case."""
    def _setup(self):
        super(TestCase, self)._setup()
        self.portal.portal_quickinstaller.installProducts(
            ['zopen.plone.milestone'], stoponerror=True)


def test_suite():
    suites = [
        FunctionalDocFileSuite(filename,
                               package='zopen.plone.milestone',
                               optionflags=ELLIPSIS,
                               test_class=TestCase)
Ejemplo n.º 9
0
from Testing.testbrowser import Browser
from Products.PloneTestCase import ptc

ptc.setupPloneSite(id=ptc.portal_name)
ptc.setupPloneSite(id="login_portal")
ptc.setupPloneSite(id="another_portal")


class SSOLoginTestCase(ptc.FunctionalTestCase):
    def afterSetUp(self):
        ptc.FunctionalTestCase.afterSetUp(self)

        self.browser = Browser()
        self.browser.handleErrors = False  # Don't get HTTP 500 pages

        self.login_portal = self.app.login_portal  # logins go here
        self.another_portal = self.app.another_portal  # another portal
        # The extra portals do not get a member setup from the base class.
        # Add our user to the other portals to simulate an ldap environment.
        for portal in (self.login_portal, self.another_portal):
            portal.acl_users.userFolderAddUser(ptc.default_user, ptc.default_password, ["Member"], [])

        # Configure the login portal to allow logins from our sites.
        self.login_portal.portal_properties.site_properties._updateProperty(
            "allow_external_login_sites", [self.portal.absolute_url(), self.another_portal.absolute_url()]
        )

        # Configure our sites to use the login portal for logins and logouts
        login_portal_url = self.login_portal.absolute_url()
        for portal in (self.portal, self.another_portal):
            site_properties = portal.portal_properties.site_properties
Ejemplo n.º 10
0
import unittest
from zope.testing.doctest import ELLIPSIS

from Testing.ZopeTestCase import installProduct
from Products.PloneTestCase.ptc import setupPloneSite

# don't need to install products in lib/python
installProduct('CMFPlacefulWorkflow')
installProduct('membrane')
installProduct('borg')
installProduct('PloneChat')
installProduct('SimpleAttachment')
installProduct('Ploneboard')

setupPloneSite(with_default_memberarea=0,
               extension_profiles=('zopen.plone.basecamp:default', ))

from Products.PloneTestCase.PloneTestCase import FunctionalTestCase
from Testing.ZopeTestCase import ZopeDocFileSuite, FunctionalDocFileSuite


class TestCase(FunctionalTestCase):
    """Passubscribers test case."""
    def _setup(self):
        super(TestCase, self)._setup()

    def _setupHomeFolder(self):
        """ 我们的网站没有home folder,重载这个函数,以便让测试能够跑下去 """
        pass

Ejemplo n.º 11
0
from unittest import TestSuite, makeSuite

from zope.component.hooks import getSite
from zope.traversing.interfaces import BeforeTraverseEvent

from plone.browserlayer.layer import mark_layer

from Products.PloneTestCase import ptc
from Products.CMFCore.utils import getToolByName
from Products.PluggableAuthService.interfaces.plugins import IChallengePlugin

ptc.setupPloneSite(extension_profiles=('pmr2.app:default',))


class TestProductInstall(ptc.PloneTestCase):
    # Using the vanilla ptc test class for we are testing integration
    # of our installation with core Plone parts.

    def afterSetUp(self):
        self.types = {
            'WorkspaceContainer': None,
            'SandboxContainer': None,
            'ExposureContainer': None,
            'Sandbox': None,
            'Exposure': 'pmr2_exposure_workflow',
            'Workspace': 'pmr2_workspace_workflow',
        }

        self.addProfile('pmr2.app:default')
        event = BeforeTraverseEvent(self.portal, self.portal.REQUEST)
        mark_layer(self.portal, event)
Ejemplo n.º 12
0
from plone.testing import layered
import robotsuite


@onsetup
def setup_zcml():
    from Products.Five import fiveconfigure
    import plone.app.z3cform.tests
    fiveconfigure.debug_mode = True
    zcml.load_config('testing.zcml', plone.app.z3cform.tests)
    fiveconfigure.debug_mode = False


setup_zcml()
ptc.setupPloneSite(extension_profiles=('plone.app.z3cform:default', ))


class IntegrationTests(ptc.PloneTestCase):
    def afterSetUp(self):
        import plone.app.z3cform.tests
        zcml.load_config('testing.zcml', plone.app.z3cform.tests)
        self.addProfile('plone.app.z3cform:default')
        event = BeforeTraverseEvent(self.portal, self.portal.REQUEST)
        mark_layer(self.portal, event)

    def test_layer_applied(self):
        from plone.app.z3cform.interfaces import IPloneFormLayer
        self.assertTrue(IPloneFormLayer.providedBy(self.portal.REQUEST))

    def test_default_templates(self):
Ejemplo n.º 13
0
from Products.PloneTestCase import ptc
from Products.PloneTestCase import layer

ptc.setupPloneSite(
    extension_profiles=('collective.regexredirector:default', )
)

class RegexRedirectionLayer(layer.PloneSite):
    """Configure collective.akismet"""

    @classmethod
    def setUp(cls):
		pass

    @classmethod
    def tearDown(cls):
        pass
Ejemplo n.º 14
0
from Products.PloneTestCase import ptc
from Products.Five import zcml, fiveconfigure
from Products.Five.testbrowser import Browser
from collective.testcaselayer.ptc import BasePTCLayer, ptc_layer


ptc.installProduct('SimpleAttachment', quiet=True)
ptc.installProduct('RichDocument', quiet=True)
ptc.setupPloneSite(products=['SimpleAttachment', 'RichDocument'])


class Layer(BasePTCLayer):
    """ basic layer for testing """

    def afterSetUp(self):
        # load zcml for this package...
        fiveconfigure.debug_mode = True
        from Products import SimpleAttachment
        zcml.load_config('configure.zcml', package=SimpleAttachment)
        fiveconfigure.debug_mode = False

layer = Layer(bases=[ptc_layer])


class IntegrationTestCase(ptc.PloneTestCase):
    """ base class for integration tests """

    layer = layer


class FunctionalTestCase(ptc.FunctionalTestCase):
Ejemplo n.º 15
0
from Testing import ZopeTestCase as ztc

from Products.PloneTestCase import ptc
from Products.PloneTestCase import layer
from Products.Five import zcml
from Products.Five import fiveconfigure

ptc.setupPloneSite(extension_profiles=("vs.dashboardmanager:default",))


class DashboardManagerLayer(layer.PloneSite):
    """Configure vs.dashboardmanager"""

    @classmethod
    def setUp(cls):
        fiveconfigure.debug_mode = True
        import vs.dashboardmanager

        zcml.load_config("configure.zcml", vs.dashboardmanager)
        fiveconfigure.debug_mode = False
        ztc.installPackage("vs.dashboardmanager", quiet=1)

    @classmethod
    def tearDown(cls):
        pass
Ejemplo n.º 16
0
from Products.PloneTestCase import PloneTestCase

# setup test content types
from Products.GenericSetup import EXTENSION, profile_registry
from Products.PloneTestCase.layer import ZCMLLayer

profile_registry.registerProfile('Archetypes_sampletypes',
    'Archetypes Sample Content Types',
    'Extension profile including Archetypes sample content types',
    'profiles/sample_types',
    'Products.Archetypes',
    EXTENSION)

# setup a Plone site
from Products.PloneTestCase.ptc import setupPloneSite
setupPloneSite(extension_profiles=['Products.Archetypes:Archetypes_sampletypes'
                                  ])

# Fixup zope 2.7+ configuration
from App import config
config._config.rest_input_encoding = 'ascii'
config._config.rest_output_encoding = 'ascii'
config._config.rest_header_level = 3
del config

class ATTestCase(ZopeTestCase.ZopeTestCase):
    """Simple AT test case
    """
    layer = ZCMLLayer

class ATFunctionalTestCase(Functional, ATTestCase):
    """Simple AT test case for functional tests
Ejemplo n.º 17
0
import unittest
from zope.testing.doctest import ELLIPSIS

from Testing.ZopeTestCase import installProduct
from Products.PloneTestCase.ptc import setupPloneSite

# don't need to install products in lib/python
installProduct('CMFPlacefulWorkflow')
installProduct('membrane')
installProduct('borg')
installProduct('PloneChat')
installProduct('SimpleAttachment')
installProduct('Ploneboard')

setupPloneSite(with_default_memberarea=0,
        extension_profiles=('zopen.plone.basecamp:default',))

from Products.PloneTestCase.PloneTestCase import FunctionalTestCase
from Testing.ZopeTestCase import ZopeDocFileSuite, FunctionalDocFileSuite

class TestCase(FunctionalTestCase):
    """Passubscribers test case."""

    def _setup(self):
        super(TestCase, self)._setup()

    def _setupHomeFolder(self):
        """ 我们的网站没有home folder,重载这个函数,以便让测试能够跑下去 """
        pass

def test_suite():
Ejemplo n.º 18
0
classImplements(PloneSite, ITestCasePloneSiteRoot)

TEST_PROFILE = "Products.CMFPlone:testfixture"

from plone.protect.authenticator import AuthenticatorView
from re import match

try:
    # plone.app.event integration
    from plone.app.event.testing import set_timezone
except:
    set_timezone = None


setupPloneSite(extension_profiles=[TEST_PROFILE])


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

    def _setup(self):
        super(PloneTestCase, self)._setup()
        if set_timezone:
            set_timezone("UTC")

    def setRequestMethod(self, method):
        self.app.REQUEST.set("REQUEST_METHOD", method)
        self.app.REQUEST.method = method
Ejemplo n.º 19
0
from Products.Five import zcml

TITLE1 = "Cop Shop"
TITLE2 = 'DMV Computer has died'

import transaction as txn
#from collective.testing.debug import autopsy

@onsetup
def register_package():
    import wicked.atcontent
    zcml.load_config("configure.zcml", package=wicked.atcontent)
    installPackage('wicked.atcontent')

register_package()
ptc.setupPloneSite(products=['wicked.atcontent'])

class WickedSite(PloneSite):

    @classmethod
    def setUp(cls):
        app = ZopeTestCase.app()
        plone = app.plone
        reg = BasePloneWickedRegistration(plone)
        reg.handle()
        # install the product
        qi = plone.portal_quickinstaller
        qi.installProduct('wicked.atcontent')
        txn.commit()
        ZopeTestCase.close(app)
Ejemplo n.º 20
0
from Products.CMFPlone.Portal import PloneSite
from Products.CMFPlone.interfaces import ITestCasePloneSiteRoot
classImplements(PloneSite, ITestCasePloneSiteRoot)

TEST_PROFILE = 'Products.CMFPlone:testfixture'

from plone.protect.authenticator import AuthenticatorView
from re import match

try:
    # plone.app.event integration
    from plone.app.event.testing import set_timezone
except:
    set_timezone = None

setupPloneSite(extension_profiles=[TEST_PROFILE])


class PloneTestCase(ptc):
    """This is a stub now, but in case you want to try
       something fancy on Your Branch (tm), put it here.
    """
    def _setup(self):
        super(PloneTestCase, self)._setup()
        if set_timezone:
            set_timezone('UTC')

    def setRequestMethod(self, method):
        self.app.REQUEST.set('REQUEST_METHOD', method)
        self.app.REQUEST.method = method
from zope.testing import doctest
from Testing import ZopeTestCase
from Products.PloneTestCase import ptc

from collective.virtualtreecategories import testing

ptc.setupPloneSite()
ptc.setupPloneSite('plone2')

optionflags = (doctest.NORMALIZE_WHITESPACE|
               doctest.ELLIPSIS|
               doctest.REPORT_NDIFF)

def test_suite():
    suite = ZopeTestCase.FunctionalDocFileSuite(
        'README.txt',
        'tests/multisite.txt',
        package='collective.virtualtreecategories',
        optionflags=optionflags,
        test_class=ptc.FunctionalTestCase)
    suite.layer = testing.layer
    return suite
Ejemplo n.º 22
0
from txtfilter.utils import doc_file
from txtfilter.at.example import Smartlink

import txtfilter.at.config
from Products.PloneTestCase import ptc

# util for making content in a container
def makeContent(container, id, portal_type, title=None):
    container.invokeFactory(id=id, type_name=portal_type)
    o = getattr(container, id)
    if title is not None:
        o.setTitle(title)
    return o

ptc.setupPloneSite(products=['txtfilter.at'])

# our example type
portal_type = Smartlink.portal_type

class FilterTest(ptc.PloneTestCase):

    def afterSetUp(self):
        super(ptc.PloneTestCase, self).afterSetUp()
        # Because we add skins this needs to be called. Um... ick.
        self._refreshSkinData()
        self.loginAsPortalOwner()

    def test_chunksingleton(self):
        c1 = makeContent(self.folder, 'content1', portal_type, 'ContentOne')
        c1.Schema()['body'].filter='Weak Wiki Filter'
from Products.PloneTestCase import ptc
import collective.testcaselayer.ptc

ptc.setupPloneSite()


class IntegrationTestLayer(collective.testcaselayer.ptc.BasePTCLayer):
    def afterSetUp(self):
        self.addProfile("collective.alias:default")


Layer = IntegrationTestLayer([collective.testcaselayer.ptc.ptc_layer])
Ejemplo n.º 24
0
from Testing import ZopeTestCase as ztc

from Products.PloneTestCase import ptc
from Products.PloneTestCase import layer
from Products.Five import zcml
from Products.Five import fiveconfigure

ptc.setupPloneSite(extension_profiles=('vs.dashboardmanager:default', ))


class DashboardManagerLayer(layer.PloneSite):
    """Configure vs.dashboardmanager"""
    @classmethod
    def setUp(cls):
        fiveconfigure.debug_mode = True
        import vs.dashboardmanager
        zcml.load_config("configure.zcml", vs.dashboardmanager)
        fiveconfigure.debug_mode = False
        ztc.installPackage("vs.dashboardmanager", quiet=1)

    @classmethod
    def tearDown(cls):
        pass
Ejemplo n.º 25
0
from Products.PloneTestCase import ptc
from Products.PloneTestCase.layer import onsetup

from plone.app.z3cform.tests.layer import InlineValidationLayer


@onsetup
def setup_zcml():
    from Products.Five import fiveconfigure
    import plone.app.z3cform.tests
    fiveconfigure.debug_mode = True
    zcml.load_config('testing.zcml', plone.app.z3cform.tests)
    fiveconfigure.debug_mode = False

setup_zcml()
ptc.setupPloneSite(extension_profiles=('plone.app.z3cform:default',))


class IntegrationTests(ptc.PloneTestCase):

    def afterSetUp(self):
        import plone.app.z3cform.tests
        zcml.load_config('testing.zcml', plone.app.z3cform.tests)
        self.addProfile('plone.app.z3cform:default')
        event = BeforeTraverseEvent(self.portal, self.portal.REQUEST)
        mark_layer(self.portal, event)

    def test_layer_applied(self):
        from plone.app.z3cform.interfaces import IPloneFormLayer
        self.failUnless(IPloneFormLayer.providedBy(self.portal.REQUEST))
Ejemplo n.º 26
0
from Testing.testbrowser import Browser
from Products.PloneTestCase import ptc

ptc.setupPloneSite(id=ptc.portal_name)
ptc.setupPloneSite(id='login_portal')
ptc.setupPloneSite(id='another_portal')


class SSOLoginTestCase(ptc.FunctionalTestCase):
    def afterSetUp(self):
        ptc.FunctionalTestCase.afterSetUp(self)

        self.browser = Browser()
        self.browser.handleErrors = False  # Don't get HTTP 500 pages

        self.login_portal = self.app.login_portal  # logins go here
        self.another_portal = self.app.another_portal  # another portal
        # The extra portals do not get a member setup from the base class.
        # Add our user to the other portals to simulate an ldap environment.
        for portal in (self.login_portal, self.another_portal):
            portal.acl_users.userFolderAddUser(ptc.default_user,
                                               ptc.default_password,
                                               ['Member'], [])

        # Configure the login portal to allow logins from our sites.
        self.login_portal.portal_properties.site_properties._updateProperty(
            'allow_external_login_sites', [
                self.portal.absolute_url(),
                self.another_portal.absolute_url(),
            ])
Ejemplo n.º 27
0
import unittest
import doctest

from Testing import ZopeTestCase
from Products.PloneTestCase import ptc
from collective.testcaselayer import ptc as tcl_ptc
from Products.Five import zcml

from interlude import interact

optionflags = (doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS
               | doctest.REPORT_NDIFF)

ptc.setupPloneSite()


class Layer(tcl_ptc.BasePTCLayer):
    """Install collective.flowplayer"""
    def afterSetUp(self):
        import collective.flowplayer
        zcml.load_config('configure.zcml', collective.flowplayer)
        self.addProfile('collective.flowplayer:default')
        # put resource registry to debug mode to avoid cachekyes in tests
        self.portal.portal_css.setDebugMode(True)
        self.portal.portal_javascripts.setDebugMode(True)


layer = Layer([tcl_ptc.ptc_layer])

FUNCTIONALTESTFILES = [
    'README.txt',
Ejemplo n.º 28
0
from Products.PloneTestCase import ptc

from Products.PloneTestCase.layer import onsetup

from Products.Five import zcml

import collective.testcaselayer.ptc

import upc.genwebupc


@onsetup
def setup_product():
    zcml.load_config("configure.zcml", upc.genwebupc)


setup_product()
ptc.setupPloneSite(products=["upc.genwebupc"])


class IntegrationTestLayer(collective.testcaselayer.ptc.BasePTCLayer):
    def afterSetUp(self):
        # Install the upc.genwebupc product
        self.addProfile("upc.genwebupc:default")


Layer = IntegrationTestLayer([collective.testcaselayer.ptc.ptc_layer])