def setUp(cls):
     ptc.installProduct('Maps')
     fiveconfigure.debug_mode = True
     zcml.load_config('configure.zcml',
                      collective.realestatebroker)
     fiveconfigure.debug_mode = False
     ptc.installPackage('collective.realestatebroker')
	def test_04_addConnection(self,):
						
		self.failIf(PloneDbFormsManager.PloneDbFormsManager.addConnection.__doc__==None,"addConnection is not documented")

		
		
		
		PloneTestCase.installProduct('ZPsycopgDA')
		folder = self.folder
		pdfsmtest = self.getPdfsmTest()
		
		# doesn't add connection is connection_string is bad
	
		pdfsmtest.addConnection(connection_info="n'importe quoi",title="mon titre")
		self.failIf(hasattr(pdfsmtest,"connection"))
		
		# adds if connection_string is good
		
		pdfsmtest.addConnection(connection_info="dbname=cnb2 user=caron_test password=shsd54 host=138.102.22.9 port=5433",title="mon titre")
		
		self.failUnless(hasattr(pdfsmtest,"connection"))
		self.failUnless(pdfsmtest.connection.connection_string=="dbname=cnb2 user=caron_test password=shsd54 host=138.102.22.9 port=5433")
		self.failUnless(pdfsmtest.connection_info=="dbname=cnb2 user=caron_test password=shsd54 host=138.102.22.9 port=5433")
		
				
		pgfsmtest = self.getPgfsmTest()
		pgfsmtest.addConnection(connection_info="subventions",title="mon titre")
    def afterSetUp(self):
        PloneTestCase.installProduct('FSImportTool')
        self.pdf_latex_tool = getToolByName(self.portal, 'portal_pdflatex')

        # PloneTestCase already gives us a folder, so within that folder,
        # create a document and a collection to version.
        self.folder.invokeFactory('Document', 'doc')
        self.doc = self.folder.doc
    def afterSetUp(self):
        PloneTestCase.installProduct('FSImportTool')
        self.pdf_latex_tool = getToolByName(self.portal, 'portal_pdflatex')

        # PloneTestCase already gives us a folder, so within that folder,
        # create a document and a collection to version.
        self.folder.invokeFactory('Document', 'doc')
        self.doc = self.folder.doc
def setup_eeaploneadmin():
    """ Setup EEA Plone Admin
    """

    for dependency in DEPENDENCIES:
        PloneTestCase.installProduct(dependency)

    fiveconfigure.debug_mode = True
    #import Products.Five
    #import Products.FiveSite
    import valentine.linguaflow
    zcml.load_config('configure.zcml', valentine.linguaflow)
    fiveconfigure.debug_mode = False
def setup_eeaploneadmin():
    """ Setup EEA Plone Admin
    """

    for dependency in DEPENDENCIES:
        PloneTestCase.installProduct(dependency)

    fiveconfigure.debug_mode = True
    #import Products.Five
    #import Products.FiveSite
    import valentine.linguaflow
    zcml.load_config('configure.zcml', valentine.linguaflow)
    fiveconfigure.debug_mode = False
Beispiel #7
0
def setup_eea_exhibit():
    """ Setup
    """
    fiveconfigure.debug_mode = True
    import Products.Five
    import eea.exhibit
    zcml.load_config('meta.zcml', Products.Five)
    zcml.load_config('configure.zcml', Products.Five)
    zcml.load_config('configure.zcml', eea.exhibit)
    fiveconfigure.debug_mode = False

    PloneTestCase.installProduct('Five')
    for i in PRODUCTS:
        PloneTestCase.installProduct(i)
Beispiel #8
0
def setup_eea_signals():
    """ Setup
    """
    fiveconfigure.debug_mode = True
    import Products.Five
    import eea.signals
    zcml.load_config('meta.zcml', Products.Five)
    zcml.load_config('configure.zcml', Products.Five)
    zcml.load_config('configure.zcml', eea.signals)
    fiveconfigure.debug_mode = False

    PloneTestCase.installProduct('Five')
    for i in PRODUCTS:
        PloneTestCase.installProduct(i)
Beispiel #9
0
def setup_eea_faceted_tool():
    """Set up the additional products.

    The @onsetup decorator causes the execution of this body to be deferred
    until the setup of the Plone site testing layer.
    """
    fiveconfigure.debug_mode = True
    import Products.Five
    zcml.load_config('meta.zcml', Products.Five)

    import eea.faceted.tool
    zcml.load_config('configure.zcml', eea.faceted.tool)
    fiveconfigure.debug_mode = False

    ptc.installProduct('Five')
Beispiel #10
0
def setup_eea_faceted_tool():
    """Set up the additional products.

    The @onsetup decorator causes the execution of this body to be deferred
    until the setup of the Plone site testing layer.
    """
    fiveconfigure.debug_mode = True
    import Products.Five
    zcml.load_config('meta.zcml', Products.Five)

    import eea.faceted.tool
    zcml.load_config('configure.zcml', eea.faceted.tool)
    fiveconfigure.debug_mode = False

    ptc.installProduct('Five')
Beispiel #11
0
def setup_eea_sitestructurediff():
    """ Setup EEA Sitestructurediff
    """

    fiveconfigure.debug_mode = True
    import Products.Five
    import eea.sitestructurediff
    import valentine.linguaflow
    zcml.load_config('meta.zcml', Products.Five)
    zcml.load_config('configure.zcml', eea.sitestructurediff)
    zcml.load_config('configure.zcml', valentine.linguaflow)
    fiveconfigure.debug_mode = False

    #ptc.installProduct('PloneLanguageTool')
    ptc.installProduct('LinguaPlone')
Beispiel #12
0
def setup_eea_sitestructurediff():
    """ Setup EEA Sitestructurediff
    """

    fiveconfigure.debug_mode = True
    import Products.Five
    import eea.sitestructurediff
    import valentine.linguaflow
    zcml.load_config('meta.zcml', Products.Five)
    zcml.load_config('configure.zcml', eea.sitestructurediff)
    zcml.load_config('configure.zcml', valentine.linguaflow)
    fiveconfigure.debug_mode = False

    #ptc.installProduct('PloneLanguageTool')
    ptc.installProduct('LinguaPlone')
Beispiel #13
0
def setup_plonegazette():
    """ Setup
    """
    fiveconfigure.debug_mode = True
    import Products.Five
    import Products.FiveSite
    import Products.PloneGazette
    zcml.load_config('meta.zcml', Products.Five)
    zcml.load_config('configure.zcml', Products.Five)
    zcml.load_config('configure.zcml', Products.FiveSite)
    zcml.load_config('configure.zcml', Products.PloneGazette)
    fiveconfigure.debug_mode = False

    PloneTestCase.installProduct('Five')
    for i in PRODUCTS:
        PloneTestCase.installProduct(i)
Beispiel #14
0
class BorgProjectLayer(SiteLayer):
    ptc.installProduct('CMFPlacefulWorkflow')

    @classmethod
    def getPortal(cls):
        app = ZopeTestCase.app()
        portal = app._getOb(portal_name)
        _placefulSetUp(portal)
        return portal

    @classmethod
    def setUp(cls):

        ztc.installProduct('borg.project')

        ptc.setupPloneSite(products=(
            'CMFPlacefulWorkflow', 
            ), extension_profiles=(
                u'borg.project:default',
            ))

        fiveconfigure.debug_mode = True
        import borg.project
        zcml.load_config('configure.zcml', borg.project)
        import Products.CMFPlacefulWorkflow
        zcml.load_config('configure.zcml', Products.CMFPlacefulWorkflow)
        fiveconfigure.debug_mode = False
    
        # We need to tell the testing framework that these products
        # should be available. This can't happen until after we have loaded
        # the ZCML. Notice the extra package=True argument passed to 
        # installProduct() - this tells it that these packages are *not* in the
        # Products namespace.
    
        ztc.installPackage('borg.localrole')
        ztc.installPackage('borg.project')
        SiteLayer.setUp()
Beispiel #15
0
def installProducts():
    for product in product_dependencies:
        PloneTestCase.installProduct(product)
Beispiel #16
0
import os, sys
if __name__ == '__main__':
    execfile(os.path.join(sys.path[0], 'framework.py'))

from Products.PloneTestCase import PloneTestCase
from Products.CMFCore.utils import getToolByName
from Products.DiPP.config import PID, label, address, port

PloneTestCase.installProduct('ATVocabularyManager')
PloneTestCase.installProduct('CMFOpenflow')
PloneTestCase.installProduct('DiPPContent')
PloneTestCase.installProduct('LinguaPlone')
PloneTestCase.installProduct('PloneLanguageTool')
PloneTestCase.installProduct('TextIndexNG3')
PloneTestCase.installProduct('DiPP')
PloneTestCase.setupPloneSite(products=('DiPP', ))


class TestMetadata(PloneTestCase.PloneTestCase):

    PID = PID
    label = label
    address = address
    port = port

    def afterSetUp(self):
        #self.portal.manage_addProduct['DiPP'].manage_addTool('Fedora2DiPP3')
        self.tool = getToolByName(self.portal, 'fedora')
        self.typestool = getToolByName(self.portal, 'portal_types')

    def testSetFedoraPID(self):
"""Unit tests for challenge plugin"""

import re
from Products.PloneTestCase import PloneTestCase
from Products.WebServerAuth.plugin import useCustomRedirectionKey, challengePatternKey, challengeReplacementKey
from Products.WebServerAuth.tests.base import MockRequestTestCase

PloneTestCase.installProduct('WebServerAuth')
PloneTestCase.setupPloneSite(products=['WebServerAuth'])


class ChallengeTestCase(MockRequestTestCase):
    def afterSetUp(self):
        MockRequestTestCase.afterSetUp(self)
        self.app.REQUEST.ACTUAL_URL = 'http://example.com/some/place'

    def beforeTearDown(self):
        MockRequestTestCase.beforeTearDown(self)


class TestChallenge(ChallengeTestCase):
    def testDefaultPattern(self):
        """Make sure the default regex works."""
        worked = self._plugin().challenge(self.app.REQUEST,
                                          self.app.REQUEST.response)
        self.failUnlessEqual(self.app.REQUEST.response.getHeader('Location'),
                             'https://example.com/some/place')
        self.failUnless(
            worked,
            msg=
            "Challenge handler did the redirect but then passed control to the next challenge handler."
""" This file is a skeleton test suite.
 It is here for letting you add new tests to the product without having to
 modify the existing testStyleInstallation.py module.
 You may modify its name to something that describes what it tests
 (keeping its 'test' prefix).
"""

from Products.PloneTestCase import PloneTestCase

PloneTestCase.installProduct('EEAPloneAdmin')
PloneTestCase.setupPloneSite(products=['EEAPloneAdmin'])

class TestSomething(PloneTestCase.PloneTestCase):
    """ Test something
    """

    def afterSetUp(self):
        """ After setup
        """
        pass

    def testSomething(self):
        """ Test something
        """
        self.assertEqual(1+1, 2)

def test_suite():
    """ Test suite
    """
    from unittest import TestSuite, makeSuite
    suite = TestSuite()
Beispiel #19
0
    The @onsetup decorator causes the execution of this body to be deferred
    until the setup of the Plone site testing layer.
    """
    fiveconfigure.debug_mode = True

    import collective.monkeypatcher
    zcml.load_config('configure.zcml', collective.monkeypatcher)
    import eea.workflow
    zcml.load_config('configure.zcml', eea.workflow)
    import eea.versions
    zcml.load_config('configure.zcml', eea.versions)
    import eea.jquery
    zcml.load_config('configure.zcml', eea.jquery)
    fiveconfigure.debug_mode = False


setup_site()
ptc.installProduct("ATVocabularyManager")
ptc.setupPloneSite(
        products=["ATVocabularyManager"],
        extension_profiles=['eea.workflow:default', 'eea.versions:default'],
)

class TestCase(ptc.PloneTestCase):
    """ Base class used for test cases
    """
class FunctionalTestCase(ptc.FunctionalTestCase):
    """ Test case class used for functional (doc-)tests
    """
Beispiel #20
0
from App.Common import package_home
from cgi import FieldStorage
from cStringIO import StringIO
from land.copernicus.content.config import product_globals
from Products.Five import fiveconfigure
from Products.Five import zcml
from Products.PloneTestCase import PloneTestCase as ptc
from Products.PloneTestCase.layer import onsetup
import os
from ZPublisher.HTTPRequest import FileUpload

ptc.installProduct('ATVocabularyManager')

@onsetup
def setup_copernicus_contenttypes():
    """Set up the package and its dependencies.
    """

    fiveconfigure.debug_mode = True
    import land.copernicus.content
    zcml.load_config('configure.zcml', land.copernicus.content)
    fiveconfigure.debug_mode = False

    ptc.installPackage('land.copernicus.content')


setup_copernicus_contenttypes()
ptc.setupPloneSite(products=['land.copernicus.content'])


class BaseCopernicusContentTestCase(ptc.PloneTestCase):
Beispiel #21
0
""" Base module """

import logging
import sys
from Products.ATVocabularyManager.config import TOOL_NAME as VOCABTOOL
from Products.CMFCore.utils import getToolByName
from Products.CMFPlone.log import logger
from Products.Five import fiveconfigure
from Products.PloneTestCase import PloneTestCase
from Products.PloneTestCase.layer import onsetup
from Zope2.App.zcml import load_config
import eea.rdfmarshaller
import eea.depiction

PloneTestCase.installProduct('ATVocabularyManager')
PloneTestCase.installProduct('eea.depiction')

PRODUCTS = ['ATVocabularyManager', 'eea.depiction']
PROFILES = ['eea.rdfmarshaller:default']


@onsetup
def setup_rdfmarshaller():
    """ Setup """

    fiveconfigure.debug_mode = True
    load_config('configure.zcml', eea.rdfmarshaller)
    load_config('testing.zcml', eea.rdfmarshaller)

    fiveconfigure.debug_mode = False
Beispiel #22
0
    #   ztc.installPackage('borg.localrole')

    ztc.installProduct('ATVocabularyManager')
    ztc.installPackage('uwosh.timeconflictcards')


# The order here is important: We first call the (deferred) function
# which installs the products we need for this product. Then, we let
# PloneTestCase set up this product on installation.

setup_product()
ptc.setupPloneSite(products=['ATVocabularyManager', 'uwosh.timeconflictcards'])
# ptc.setupPloneSite()
ztc.installProduct('ATVocabularyManager')
ztc.installProduct('uwosh.timeconflictcards')
ptc.installProduct('ATVocabularyManager')
ptc.installProduct('uwosh.timeconflictcards')


class TestCase(ptc.PloneTestCase):
    """We use this base class for all the tests in this package. If
    necessary, we can put common utility or setup code in here. This
    applies to unit test cases.
    """


class FunctionalTestCase(ptc.FunctionalTestCase):
    """We use this class for functional integration tests that use
    doctest syntax. Again, we can put basic common utility or setup
    code in here.
    """
Beispiel #23
0
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.

## You should have received a copy of the GNU General Public License
## along with this program; see the file COPYING. If not, write to the
## Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

# $Id: testPlonePopoll.py 49710 2007-09-19 16:24:47Z glenfant $

from Products.PlonePopoll.content import *
from Acquisition import aq_base

from Products.CMFCore.utils import getToolByName

from Products.PloneTestCase import PloneTestCase
PloneTestCase.installProduct('PlonePopoll')

PloneTestCase.setupPloneSite(products=['PlonePopoll'])


def sortTuple(t):
    l = list(t)
    l.sort()
    return tuple(l)


class TestPlonePopoll(PloneTestCase.PloneTestCase):

    #utility method

    def createMember(self, id, pw, email, roles=('Member', )):
Beispiel #24
0
def installProducts():
    for product in product_dependencies:
        PloneTestCase.installProduct(product)
Beispiel #25
0
# Define a common PloneTemplatesTestCase base class for use in all

from Products.PloneTestCase import PloneTestCase

# These must install cleanly
PloneTestCase.installProduct('PloneTemplates')

# Set up the Plone site used for the test fixture. The PRODUCTS are the products
# to install in the Plone site (as opposed to the products defined above, which
# �are all products available to Zope in the test fixture)
PRODUCTS = ['PloneTemplates']
PloneTestCase.setupPloneSite(products=PRODUCTS)


class PloneTemplatesTestCase(PloneTestCase.PloneTestCase):
    """Standard test case."""

Beispiel #26
0
#from Products.CMFPlone.tests import PloneTestCase
from Products.PloneTestCase import PloneTestCase
from Products.CMFCore.utils import getToolByName
from Acquisition import Implicit

default_user = PloneTestCase.default_user
portal_name = PloneTestCase.portal_name

PloneTestCase.installProduct("Marginalia")

PloneTestCase.setupPloneSite(products=('Mariginalia',), extension_profiles=('Marginalia:marginalia',))
import ZPublisher

class TestMarginaliaInstall(PloneTestCase.PloneTestCase):

    def afterSetUp(self):
        self.plone = getattr(self.app, portal_name)
        if not self.plone.portal_quickinstaller.isProductInstalled("Marginalia"):
            self.plone.portal_quickinstaller.installProducts(["Marginalia",])

    def testMarginaliaTool(self):        
        self.assert_(hasattr(self.plone, "portal_annotations"),
                     "Annotation Portal Tool missing.")

    def testSiteProperties(self):
        portalProperties = getToolByName(self.plone, 'portal_properties')
        siteProperties = getattr(portalProperties, 'site_properties')
        current = list(siteProperties.getProperty('types_not_searched'))
        self.assert_("Annotations" in current,
                     "'Annotations' missing from types_not_searched portal property.")
Beispiel #27
0
#-*- coding: utf-8 -*-
# $Id$
"""OpenXml testing package: testing resources"""

from Products.PloneTestCase import PloneTestCase
from Products.OpenXml.config import PROJECTNAME

PloneTestCase.installProduct(PROJECTNAME)
PloneTestCase.setupPloneSite(products=[PROJECTNAME])

Beispiel #28
0
""" Base module
"""
from Products.Five import zcml
from Products.Five import fiveconfigure
from Products.PloneTestCase import PloneTestCase
from Products.PloneTestCase.layer import onsetup
import valentine.linguaflow

PloneTestCase.installProduct('LinguaPlone')

@onsetup
def setup_valentine_linguaflow():
    """ Setup """
    fiveconfigure.debug_mode = True
    zcml.load_config('configure.zcml', valentine.linguaflow)
    zcml.load_config('testing.zcml', valentine.linguaflow.tests)
    fiveconfigure.debug_mode = False

setup_valentine_linguaflow()
PloneTestCase.setupPloneSite(
                 extension_profiles=('valentine.linguaflow:default',
                                     'valentine.linguaflow.tests:testing'))

class ValentineLinguaflowTestCase(PloneTestCase.PloneTestCase):
    """ Valentine Linguaflow Test Case """

class ValentineLinguaflowFunctionalTestCase(PloneTestCase.FunctionalTestCase):
    """ Valentine Linguaflow Functional Test Case """
Beispiel #29
0
configlets = ({'id':'qSEOptimizer',
    'name':'Search Engine Optimizer',
    'action':'string:${portal_url}/prefs_qseo_setup_form',
    'condition':'',
    'category':'Products',
    'visible':1,
    'appId':'qSEOptimizer',
    'permission':ManagePortal},)

PRODUCT = 'qSEOptimizer'
qSEO_CONTENT = ['File','Document','News Item','BlogEntry']
qSEO_FOLDER  = []
qSEO_TYPES   = qSEO_CONTENT + qSEO_FOLDER

PloneTestCase.installProduct('Five')
PloneTestCase.installProduct(PRODUCT)
PloneTestCase.setupPloneSite()

class TestBeforeInstall(PloneTestCase.FunctionalTestCase):

    def afterSetUp(self):
        self.basic_auth = 'mgr:mgrpw'
        self.portal_path = '/%s' % self.portal.absolute_url(1)

    def testAccessPortalRootAnonymous(self):
        response = self.publish(self.portal_path)
        self.assertEqual(response.getStatus(), 200)

    def testAccessPortalRootAuthenticated(self):
        response = self.publish(self.portal_path, self.basic_auth)
import unittest

from zope.testing import doctestunit
from zope.component import testing
from Testing import ZopeTestCase as ztc

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

import collective.tinymceplugins.imagebrowser

ptc.installProduct('collective.tinymceplugins.imagebrowser')
ptc.setupPloneSite(products=('collective.tinymceplugins.imagebrowser',))


class TestCase(ptc.PloneTestCase):
    class layer(PloneSite):
        @classmethod
        def setUp(cls):
            fiveconfigure.debug_mode = True
            zcml.load_config('configure.zcml', collective.tinymceplugins.imagebrowser)
            fiveconfigure.debug_mode = False

        @classmethod
        def tearDown(cls):
            pass


def test_suite():
from Products.Archetypes.tests.atsitetestcase import ATSiteTestCase
from Products.CMFCore.utils import getToolByName
from Products.PloneTestCase.layer import onsetup
from Products.Five import zcml
from Products.Five import fiveconfigure
from Testing import ZopeTestCase as ztc
from Products.PloneTestCase import PloneTestCase as ptc

from Products.OneTimeTokenPAS.config import *

ptc.installProduct('OneTimeTokenPAS')
ptc.default_extensions_profiles = ('Products.OneTimeTokenPAS:default', )
ptc.setupPloneSite(products=['OneTimeTokenPAS'])


class TokenStorageTestCase(ptc.PloneTestCase):
    def afterSetUp(self):
        super(TokenStorageTestCase, self).afterSetUp()
        self.m_tool = getToolByName(self.portal, 'portal_membership')
        self.ott = getToolByName(self.portal, 'onetimetoken_storage')

    def get_generated_user(self):
        users = self.m_tool.acl_users.getUserIds()
        self.assertEqual(len(users), 2)
        return users[0]

    def test_temporary_user(self):
        # generate token
        token = self.ott.setToken()
        userid = self.get_generated_user()
Beispiel #32
0
#
# Tests for qPloneCaptchas
#

import os, sys, re
if __name__ == '__main__':
    execfile(os.path.join(sys.path[0], 'framework.py'))

from Products.PloneTestCase import PloneTestCase
from AccessControl.SecurityManagement import newSecurityManager
from Products.qPloneCaptchas.utils import getWord, decrypt, parseKey

PloneTestCase.installProduct('PlacelessTranslationService')
PloneTestCase.installProduct('qPloneCaptchas')
PloneTestCase.setupPloneSite()

class TestCaptchaWidget(PloneTestCase.FunctionalTestCase):

    def afterSetUp(self):
        self.loginAsPortalOwner()
        self.addProduct('qPloneCaptchas')
        self.portal.invokeFactory('Document', 'index_html')
        self.portal['index_html'].allowDiscussion(True)
        self.absolute_url = self.portal['index_html'].absolute_url_path()

        self.basic_auth = 'portal_manager:secret'
        uf = self.app.acl_users
        uf.userFolderAddUser('portal_manager', 'secret', ['Manager'], [])
        user = uf.getUserById('portal_manager')
        if not hasattr(user, 'aq_base'):
            user = user.__of__(uf)
    import Products.ATVocabularyManager
    import plumi.content
    fiveconfigure.debug_mode = True
    zcml.load_config('configure.zcml', Products.ATVocabularyManager)
    zcml.load_config('configure.zcml', plumi.content)        
    fiveconfigure.debug_mode = False
        
    ztc.installPackage('ATVocabularyManager')
    ztc.installPackage('plumi.content')

# The order here is important: We first call the (deferred) function
# which installs the products we need for this product. Then, we let
# PloneTestCase set up this product on installation.

setup_product()
ptc.installProduct('ATVocabularyManager')
ptc.installProduct('plumi.content')
ptc.setupPloneSite(products=('plumi.content',))     
    
    
class TestCase(ptc.PloneTestCase):
    """We use this base class for all the tests in this package. If
    necessary, we can put common utility or setup code in here. This
    applies to unit test cases.
    """

class FunctionalTestCase(ptc.FunctionalTestCase):
    """We use this class for functional integration tests that use
    doctest syntax. Again, we can put basic common utility or setup
    code in here.
    """
Beispiel #34
0
$Id: utils.py 55153 2007-12-09 12:42:44Z dbaty $
"""

## Import the base test case classes
from Testing import ZopeTestCase
from Products.PloneTestCase import PloneTestCase

from Products.Five.testbrowser import Browser

## Make ZopeTestCase aware of CMFNotification
ZopeTestCase.installProduct('CMFNotification')

## Set up a Plone site
PRODUCTS = ('CMFNotification', )
PloneTestCase.setupPloneSite(products=PRODUCTS)
PloneTestCase.installProduct('Five')

## Import statements for our own code
from OFS.SimpleItem import SimpleItem
from Products.CMFCore.utils import getToolByName
from Products.CMFNotification import NotificationTool

## Monkey-patch logger so that we can test log messages (and not
## display them when tests are run).
from Products.CMFNotification.tests import fakelogger
fakelogger.patchLogging()
import logging
from Products.CMFNotification import NotificationTool
NotificationTool.LOG = logging.getLogger()

## A fake mail host which does not send emails but keep them in a
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.

## You should have received a copy of the GNU General Public License
## along with this program; see the file COPYING. If not, write to the
## Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

# $Id: testPlonePopoll.py 49710 2007-09-19 16:24:47Z glenfant $

from Products.PlonePopoll.content import *
from Acquisition import aq_base

from Products.CMFCore.utils import getToolByName

from Products.PloneTestCase import PloneTestCase
PloneTestCase.installProduct('PlonePopoll')

PloneTestCase.setupPloneSite(products=['PlonePopoll'])


def sortTuple(t):
    l = list(t)
    l.sort()
    return tuple(l)

class TestPlonePopoll(PloneTestCase.PloneTestCase):

    #utility method

    def createMember(self, id, pw, email, roles=('Member',)):
        ptool = getToolByName(self.portal, 'portal_registration')
Beispiel #36
0
""" Testing environment
"""
from Products.PloneTestCase import PloneTestCase

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

PloneTestCase.installProduct('NavigationManager')

@onsetup
def setup_navigationmanager():
    """ Setup Products.NavigationManager
    """
    fiveconfigure.debug_mode = True
    from Products import NavigationManager
    zcml.load_config('configure.zcml', NavigationManager)
    fiveconfigure.debug_mode = False

setup_navigationmanager()
PloneTestCase.setupPloneSite(extension_profiles=[
    'Products.NavigationManager:default',
])

class NavigationManagerTestCase(PloneTestCase.PloneTestCase):
    """Base TestCase for NavigationManager."""
Beispiel #37
0
#
# Skeleton TWBSkinTestCase
#

from Products.PloneTestCase import PloneTestCase

PloneTestCase.installProduct('TWBSkin')
PloneTestCase.setupPloneSite(products=['TWBSkin'])


class TestSomething(PloneTestCase.PloneTestCase):


    def afterSetUp(self):
        pass

    def testSomething(self):
        # Test something
        self.assertEqual(1+1, 2)


def test_suite():
    from unittest import TestSuite, makeSuite
    suite = TestSuite()
    suite.addTest(makeSuite(TestSomething))
    return suite
Beispiel #38
0
""" Base
"""
import eea.promotion
from Products.PloneTestCase import PloneTestCase
from Products.PloneTestCase.layer import onsetup
from Products.Five import zcml
from Products.Five import fiveconfigure

PloneTestCase.installProduct('Products.NavigationManager')


@onsetup
def setup_promotion():
    """ Setup promotion
    """
    fiveconfigure.debug_mode = True
    zcml.load_config('configure.zcml', eea.promotion)
    fiveconfigure.debug_mode = False

    PloneTestCase.installPackage('eea.themecentre')


setup_promotion()
PloneTestCase.setupPloneSite(extension_profiles=('eea.promotion:default', ))


class EEAPromotionTestCase(PloneTestCase.FunctionalTestCase):
    """ Test case class used for functional promotion tests.
    """
Beispiel #39
0
import unittest
from zope.testing import doctest
from Testing.ZopeTestCase import FunctionalDocFileSuite
import Products.PloneTestCase.layer

from Products.PloneTestCase import PloneTestCase
try:
    import Products.Plone4ArtistsSubtyper
    PloneTestCase.installProduct('Plone4ArtistsSubtyper')
except ImportError, err:
    # this is ok
    pass

PloneTestCase.setupPloneSite()


def test_suite():
    flags = doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS
    fsuite = unittest.TestSuite(())
    try:
        # this is to make sure the tests only run
        # in a plone 2.5 / zope 2.9 environment
        import zope.app.annotation.tests
        fsuite.append(FunctionalDocFileSuite('browser.txt',
                                             package='p4a.subtyper.contentmenu',
                                             optionflags=flags), )
        fsuite.layer = Products.PloneTestCase.layer.PloneSite
    except ImportError, err:
        # this is ok
        pass
Beispiel #40
0
from Products.PloneTestCase.layer import onsetup
from Zope2.App import zcml

PRODUCTS = [
    'DataGridField',
    'ATVocabularyManager',
    'EEAContentTypes',
    'EEAPloneAdmin',
    'UserAndGroupSelectionWidget',
    'kupu',
    'eea.depiction'
    #'RedirectionTool',
]

for product in PRODUCTS:
    PloneTestCase.installProduct(product)

@onsetup
def setup_indicators():
    """Setup utilities"""
    fiveconfigure.debug_mode = True

    import eea.indicators
    import eea.indicators.tests
    zcml.load_config('configure.zcml', eea.indicators)
    zcml.load_config('testing.zcml', eea.indicators.tests)
    PloneTestCase.installPackage('eea.indicators')

    import eea.themecentre
    zcml.load_config('configure.zcml', eea.themecentre)
    PloneTestCase.installPackage('eea.themecentre')
Beispiel #41
0
    # We may also need to load dependencies, e.g.:
    #   ztc.installPackage('borg.localrole')

    ztc.installProduct('ATVocabularyManager')
    ztc.installPackage('uwosh.timeconflictcards')

# The order here is important: We first call the (deferred) function
# which installs the products we need for this product. Then, we let
# PloneTestCase set up this product on installation.

setup_product()
ptc.setupPloneSite(products=['ATVocabularyManager', 'uwosh.timeconflictcards'])
# ptc.setupPloneSite()
ztc.installProduct('ATVocabularyManager')
ztc.installProduct('uwosh.timeconflictcards')
ptc.installProduct('ATVocabularyManager')
ptc.installProduct('uwosh.timeconflictcards')


class TestCase(ptc.PloneTestCase):
    """We use this base class for all the tests in this package. If
    necessary, we can put common utility or setup code in here. This
    applies to unit test cases.
    """


class FunctionalTestCase(ptc.FunctionalTestCase):
    """We use this class for functional integration tests that use
    doctest syntax. Again, we can put basic common utility or setup
    code in here.
    """
Beispiel #42
0
""" Base test cases
"""
import os
from StringIO import StringIO
from App.Common import package_home
from cgi import FieldStorage
from ZPublisher.HTTPRequest import FileUpload
from Zope2.App import zcml
from Products.Five import fiveconfigure
from Products.PloneTestCase import PloneTestCase as ptc
from Products.PloneTestCase.layer import onsetup

ptc.installProduct('Five')
ptc.installProduct('FiveSite')
ptc.installProduct('ATVocabularyManager')
ptc.installProduct('PloneLanguageTool')
ptc.installProduct('LinguaPlone')

product_globals = globals()

@onsetup
def setup_eea_facetednavigation():
    """Set up the additional products required for the Report Content.

    The @onsetup decorator causes the execution of this body to be deferred
    until the setup of the Plone site testing layer.
    """
    fiveconfigure.debug_mode = True
    from eea import facetednavigation
    zcml.load_config('meta.zcml', facetednavigation)
    zcml.load_config('overrides.zcml', facetednavigation)
Beispiel #43
0
from zExceptions import Forbidden
from Products.PloneTestCase import PloneTestCase

from Products.CMFPlacefulWorkflow.PlacefulWorkflowTool import WorkflowPolicyConfig_id
from CMFPlacefulWorkflowTestCase import CMFPlacefulWorkflowTestCase

try:
    _standard_permissions = ZopeTestCase._standard_permissions
except AttributeError:
    _standard_permissions = ZopeTestCase.standard_permissions

_edit_permissions     = [] # [PlacefulWorkflowPolicy_editPermission,]
_all_permissions      = _edit_permissions

#Install our product
PloneTestCase.installProduct('CMFPlacefulWorkflow')
PloneTestCase.setupPloneSite()

# Other imports
from Products.CMFCore.utils import getToolByName

class TestPlacefulWorkflow(CMFPlacefulWorkflowTestCase):
    """ Testing all add-on and modified method for workflow stuff """

    def createMember(self, id, pw, email, roles=('Member',)):
        pr = self.portal.portal_registration
        member = pr.addMember(id, pw, roles, properties={ 'username': id, 'email' : email })
        #self.failUnless(id in self.portal.Members.objectIds())
        return member

    def installation(self, productName):
import unittest
import pkg_resources

try:
    pkg_resources.get_distribution('Plone')
except pkg_resources.DistributionNotFound:
    _PLONE_INSTALLED = False
except pkg_resources.VersionConflict:
    raise Exception("Update this code!")
else:
    _PLONE_INSTALLED = True

if _PLONE_INSTALLED:
    from Products.PloneTestCase import PloneTestCase
    PloneTestCase.installProduct('Five')
    PloneTestCase.installProduct('CMFPlone')
    PloneTestCase.installProduct('TextIndexNG3')

    # setup a new Plohn site    
    PloneTestCase.setupPloneSite(products=('TextIndexNG3', ))
    PTC = PloneTestCase.PloneTestCase
    _PLONE_INSTALLED = True
else:
    PTC = object


class PloneTests(PTC):

    def afterSetUp(self):
        membership = self.portal.portal_membership
Beispiel #45
0
#
# Skeleton ATFThemeTestCase
#

from Products.PloneTestCase import PloneTestCase

PloneTestCase.installProduct('ATFTheme')
PloneTestCase.setupPloneSite(products=['ATFTheme'])


class TestSomething(PloneTestCase.PloneTestCase):


    def afterSetUp(self):
        pass

    def testSomething(self):
        # Test something
        self.assertEqual(1+1, 2)


def test_suite():
    from unittest import TestSuite, makeSuite
    suite = TestSuite()
    suite.addTest(makeSuite(TestSomething))
    return suite
Beispiel #46
0
""" Base module
"""
from Products.Five import zcml
from Products.Five import fiveconfigure
from Products.PloneTestCase import PloneTestCase
from Products.PloneTestCase.layer import onsetup
import valentine.linguaflow

PloneTestCase.installProduct('LinguaPlone')


@onsetup
def setup_valentine_linguaflow():
    """ Setup """
    fiveconfigure.debug_mode = True
    zcml.load_config('configure.zcml', valentine.linguaflow)
    zcml.load_config('testing.zcml', valentine.linguaflow.tests)
    fiveconfigure.debug_mode = False


setup_valentine_linguaflow()
PloneTestCase.setupPloneSite(
    extension_profiles=('valentine.linguaflow:default',
                        'valentine.linguaflow.tests:testing'))


class ValentineLinguaflowTestCase(PloneTestCase.PloneTestCase):
    """ Valentine Linguaflow Test Case """


class ValentineLinguaflowFunctionalTestCase(PloneTestCase.FunctionalTestCase):
#
# Skeleton agCommonTestCase
#

from Products.PloneTestCase import PloneTestCase

PloneTestCase.installProduct('agCommon')
PloneTestCase.setupPloneSite(products=['agCommon'])


class TestSomething(PloneTestCase.PloneTestCase):


    def afterSetUp(self):
        pass

    def testSomething(self):
        # Test something
        self.assertEqual(1+1, 2)


def test_suite():
    from unittest import TestSuite, makeSuite
    suite = TestSuite()
    suite.addTest(makeSuite(TestSomething))
    return suite
"""Unit tests for extraction plugin"""

from Products.PloneTestCase import PloneTestCase
from Products.CMFCore.utils import getToolByName
from Products.WebServerAuth.utils import firstInstanceOfClass
from Products.WebServerAuth.plugin import usernameKey, defaultUsernameHeader, stripDomainNamesKey, usernameHeaderKey
from Products.WebServerAuth.tests.base import WebServerAuthTestCase


PloneTestCase.installProduct('WebServerAuth')
PloneTestCase.setupPloneSite(products=['WebServerAuth'])


_username = '******'
_domain = 'example.com'
_userAtDomain = '%s@%s' % (_username, _domain)

class _MockRequest(object):
    def __init__(self, environ=None):
        self.environ = environ or {}

class TestExtraction(WebServerAuthTestCase):
    def afterSetUp(self):
        self.plugin = self._plugin()
    
    def testDefaultExtraction(self):
        """Assert default behavior of extraction works."""
        request = _MockRequest()
        self.failUnless(self.plugin.extractCredentials(request) is None, msg="Found credentials to extract, even though we shouldn't have.")
        
        request.environ[defaultUsernameHeader] = _username
Beispiel #49
0

_extenderName = 'MobilePhoneExtender'

# Install the example extender, even if it's not in the Products folder.
# This has to be out in module space because ZopeLite.py says PloneTestCase.installProduct has to be called from module level.
if not PloneTestCase.hasProduct(_extenderName):
    def _pretendExtenderIsInProductsFolder():
        """Let it be as if MobilePhoneExtender is in the Products folder, even if it isn't."""
        
        _productsNamespacePackage = os.path.join(*([os.sep] + __file__.split(os.sep)[:-2] + ['examples', 'Products.MobilePhoneExtender', 'Products']))  # yeeeeehaw!
        Products.__path__.append(_productsNamespacePackage)  # Stick the "Products" dir within the egg onto the end of the folders Zope searches for products so it can find MobilePhoneExtender.
    
    _pretendExtenderIsInProductsFolder()

PloneTestCase.installProduct(_extenderName)
PloneTestCase.setupPloneSite(id='anotherPortal', products=PRODUCTS)  # a site into which the extender is *not* installed, just to make sure installation doesn't accidentally leak across Plone sites

def _personIsExtended(person):
    return person.Schema().get('mobilePhone') is not None


class TestExtensibilityBase(testPlone):
    def afterSetUp(self):
        self.installer = getToolByName(self.portal, 'portal_quickinstaller')
        self.installer.installProducts([_extenderName])
        self.loginAsPortalOwner()  # so getPerson() can make people and stuff


class TestExtensibility(TestExtensibilityBase):
    """Integration tests to make sure the schema extensibility infrastructure works"""
Beispiel #50
0
""" Base test cases
"""
import os
from StringIO import StringIO
from App.Common import package_home
from cgi import FieldStorage
from ZPublisher.HTTPRequest import FileUpload
from Zope2.App import zcml
from Products.Five import fiveconfigure
from Products.PloneTestCase import PloneTestCase as ptc
from Products.PloneTestCase.layer import onsetup

ptc.installProduct('Five')
ptc.installProduct('FiveSite')
ptc.installProduct('ATVocabularyManager')
ptc.installProduct('PloneLanguageTool')
ptc.installProduct('LinguaPlone')

product_globals = globals()


@onsetup
def setup_eea_facetednavigation():
    """Set up the additional products required for the Report Content.

    The @onsetup decorator causes the execution of this body to be deferred
    until the setup of the Plone site testing layer.
    """
    fiveconfigure.debug_mode = True
    from eea import facetednavigation
    zcml.load_config('meta.zcml', facetednavigation)
Beispiel #51
0
import unittest
from zope.testing import doctest
from Testing.ZopeTestCase import FunctionalDocFileSuite
import Products.PloneTestCase.layer

from Products.PloneTestCase import PloneTestCase
PloneTestCase.installProduct('Plone4ArtistsSubtyper')
PloneTestCase.setupPloneSite()


def test_suite():
    flags = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS
    fsuite = unittest.TestSuite(())
    try:
        # this is to make sure the tests only run in a plone 2.5 / zope 2.9 environment
        import zope.app.annotation.tests
        fsuite.append(
            FunctionalDocFileSuite('browser.txt',
                                   package='p4a.subtyper.contentmenu',
                                   optionflags=flags), )
        fsuite.layer = Products.PloneTestCase.layer.PloneSite
    except ImportError, err:
        # this is ok
        pass

    return fsuite
Beispiel #52
0
# -*- coding: utf-8 -*-
# Tests which use the FAQ 'product' in this folder.
# This is a folderish content type which also uses references.
#
# Nastily patch Products to get FAQ accepted
import os
import Products
Products.__path__.insert(0, os.path.dirname(os.path.abspath(__file__)))

from Products.PloneTestCase import PloneTestCase

# We may not have Archetypes, which the FAQ tests require
try:
    PloneTestCase.installProduct('FAQ')
    PloneTestCase.setupPloneSite(products=('FAQ', ))
    HAS_AT = True
except ImportError:
    HAS_AT = False

from Products.CMFEditions import PACKAGE_HOME


class TestATContents(PloneTestCase.PloneTestCase):
    def afterSetUp(self):
        self.membership = self.portal.portal_membership
        self.catalog = self.portal.portal_catalog
        self.workflow = self.portal.portal_workflow
        self.portal_repository = self.portal.portal_repository
        self.portal_archivist = self.portal.portal_archivist
        self.folder.manage_permission('Add FAQ content', ['Member', 'Manager'])
Beispiel #53
0
#
# Unit Tests for the style install and uninstall methods
#

import os, sys
if __name__ == '__main__':
    execfile(os.path.join(sys.path[0], 'framework.py'))

from Products.PloneTestCase import PloneTestCase

# CHANGE 'NuPlone' to your product name in the following lines
from Products.NuPlone.config import *
from Products.NuPlone.Extensions.utils import getSkinsFolderNames
PROJECTNAME = 'NuPlone'

PloneTestCase.installProduct(PROJECTNAME)
PloneTestCase.setupPloneSite(products=[PROJECTNAME])

class testSkinsTool(PloneTestCase.PloneTestCase):

    def afterSetUp(self):
        self.tool = getattr(self.portal, 'portal_skins')

    def testSkinSelectionCreated(self):
        """Test if a new skin exists in portal_skins."""
        for skin_selection in SKINSELECTIONS:
            self.failUnless(
                skin_selection['name'] in self.tool.getSkinSelections())

    def testSkinPaths(self):
        """Test if the skin layers in the new skin were correctly added."""
import unittest

#from zope.testing import doctestunit
#from zope.component import testing
from Testing import ZopeTestCase as ztc

from Products.Five import fiveconfigure
from Products.PloneTestCase import PloneTestCase as ptc
from Products.PloneTestCase.layer import PloneSite
ztc.installProduct('CacheSetup')
ztc.installProduct('CMFSquidTool')

ptc.installProduct('LinguaPlone')

ptc.setupPloneSite(products=['CacheSetup', 'LinguaPlone'],
                   extension_profiles=[])

import collective.patchlinguaploneissue273


class TestCase(ptc.PloneTestCase):
    class layer(PloneSite):
        @classmethod
        def setUp(cls):
            fiveconfigure.debug_mode = True

            ztc.installPackage(collective.patchlinguaploneissue273)
            fiveconfigure.debug_mode = False

        @classmethod
        def tearDown(cls):
Beispiel #55
0
""" Tests setup
"""
from Products.PloneTestCase import PloneTestCase
from Products.PloneTestCase.layer import onsetup
from Products.Five import zcml
from Products.Five import fiveconfigure
import eea.vocab

PloneTestCase.installProduct('ATVocabularyManager')


@onsetup
def setup_package():
    """ Setup
    """
    fiveconfigure.debug_mode = True
    zcml.load_config('configure.zcml', eea.vocab)
    fiveconfigure.debug_mode = False


setup_package()
PloneTestCase.setupPloneSite(extension_profiles=('eea.vocab:default', ))


class VocabFunctionalTestCase(PloneTestCase.FunctionalTestCase):
    """ Vocab Functional Test Case """
from Products.PloneTestCase import PloneTestCase as ptc

ptc.setupPloneSite()
ptc.installProduct('AutoUserMakerPASPlugin')

class PluginTestCase(ptc.PloneTestCase):
    """ Base class for AutoUserMakerPASPlugin tests """


class PluginFunctionalTestCase(ptc.FunctionalTestCase):
    """ Base class for AutoUserMakerPASPlugin integration tests """

# EOF