import unittest
from Testing import ZopeTestCase as ztc
from Products.Five import zcml
from Products.PloneTestCase.PloneTestCase import setupPloneSite
from Products.PloneTestCase.layer import onsetup
from Products.PloneGetPaid.tests.base import PloneGetPaidFunctionalTestCase

ztc.installProduct('DataGridField')
ztc.installProduct('PloneGetPaid')
ztc.installProduct('PloneFormGen')

@onsetup
def load_zcml():
    import getpaid.formgen
    zcml.load_config('configure.zcml', getpaid.formgen)
    
    ztc.installPackage('getpaid.formgen')

load_zcml()
setupPloneSite(products=['getpaid.formgen'])

def test_suite():
    """This sets up a test suite that actually runs the tests in the class
    above
    """
    suite = unittest.TestSuite()
    suite.addTest(ztc.FunctionalDocFileSuite('test_functional_oneshot_success.txt',
                        package='getpaid.formgen.tests',
                        test_class=PloneGetPaidFunctionalTestCase))
    return suite
    """
    Load and install packages required for the collective.contentlicensing tests
    """

    fiveconfigure.debug_mode = True
    
    import collective.contentlicensing
    zcml.load_config('configure.zcml',collective.contentlicensing)
    
    fiveconfigure.debug_mode = False

    ztc.installPackage('collective.contentlicensing')


setup_contentlicensing_project()
setupPloneSite(with_default_memberarea=0,extension_profiles=['collective.contentlicensing:default'])

oflags = (doctest.ELLIPSIS |
          doctest.NORMALIZE_WHITESPACE)

prod = "collective.contentlicensing"

class ContentLicensingTestCase(PloneTestCase):
    """ Test Class """

    def _setupHomeFolder(self):
	""" Ugly hack to keep the underlying testing framework from trying to create a user folder."""
	pass

class BlobContentLicensingTestCase(PloneTestCase):
    """ Test Class with blob support """
Esempio n. 3
0
    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('collective.oaiintercom')

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

setup_oaiintercom_project()
setupPloneSite(with_default_memberarea=0, extension_profiles=['collective.oaiintercom:default',])           


oflags = (doctest.ELLIPSIS |
          doctest.NORMALIZE_WHITESPACE)
prod = 'collective.oaiintercom'

class oaiintercomTestCase(PloneTestCase):
    """ Base Test Case"""

class oaiintercomFunctionalTestCase(Functional, oaiintercomTestCase):
    """ Base class for functional integration tests. """


Esempio n. 4
0
from plone.app.users.tests import TestCase
from Products.PloneTestCase.PloneTestCase import setupPloneSite
from Testing.ZopeTestCase import FunctionalDocFileSuite
from unittest import TestSuite

import doctest
import os

setupPloneSite()

OPTIONFLAGS = (doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE)


class DocTestCase(TestCase):
    # Just here to work around a weird error message.
    # And now an extra helper method.

    def get_test_file(self, filename):
        return open(os.path.join(os.path.dirname(__file__), filename))


def test_suite():
    tests = [
        'flexible_user_registration.txt', 'forms_navigationroot.txt',
        'registration_forms.txt', 'userdata.txt',
        'userdata_prefs_user_details.txt', 'personal_preferences.txt',
        'personal_preferences_prefs_user_details.txt', 'password.txt'
    ]
    suite = TestSuite()
    for test in tests:
        suite.addTest(
Esempio n. 5
0
@onsetup
def setup_plonebookmarklets_project():
    """
    Load and install packages required for the collective.plonebookmarklets tests
    """

    fiveconfigure.debug_mode = True
    
    import collective.plonebookmarklets
    zcml.load_config('configure.zcml',collective.plonebookmarklets)
    zcml.load_config('browser/configure.zcml',collective.plonebookmarklets)
    
    fiveconfigure.debug_mode = False

    ztc.installPackage('collective.plonebookmarklets')


setup_plonebookmarklets_project()
setupPloneSite(with_default_memberarea=0,extension_profiles=['collective.plonebookmarklets:default'])

oflags = (doctest.ELLIPSIS |
          doctest.NORMALIZE_WHITESPACE)

prod = "collective.plonebookmarklets"

class PloneBookmarkletsTestCase(PloneTestCase):
    """ Test Class """

class PloneBookmarkletsFunctionalTestCase(FunctionalTestCase, PloneBookmarkletsTestCase):
    """ Functional test class """
Esempio n. 6
0
File: base.py Progetto: dtgit/dtedu
from Products.PloneTestCase.PloneTestCase import FunctionalTestCase, setupPloneSite, installProduct

installProduct('ContentLicensing')
installProduct('ZipFileTransport')
installProduct('IMSTransport')
installProduct('PloneBookmarklets')
installProduct('leftskin')
installProduct('ProxyIndex')
installProduct('eduCommons')
installProduct('LinguaPlone')


setupPloneSite(with_default_memberarea=0,
               extension_profiles=['Products.ContentLicensing:default',
                                   'Products.ZipFileTransport:default',
                                   'Products.IMSTransport:default',
                                   'Products.PloneBookmarklets:default',
                                   'Products.LinguaPlone:LinguaPlone',
                                   'Products.leftskin:default',
                                   'Products.eduCommons:default'])

               

oflags = (doctest.ELLIPSIS |
          doctest.NORMALIZE_WHITESPACE)

prod = 'Products.eduCommons'


class eduCommonsTestCase(PloneTestCase):
    """ Base class for integration tests. """
Esempio n. 7
0
# Let Zope know about the products we need. Only "old style" products with
# the "Products" prefix need to appear here. 
ZopeTestCase.installProduct('fatsyndication')
ZopeTestCase.installProduct('QuillsEnabled')

# Import PloneTestCase - this registers more products with Zope as a side effect
from Products.PloneTestCase.PloneTestCase import PloneTestCase
from Products.PloneTestCase.PloneTestCase import FunctionalTestCase
from Products.PloneTestCase.PloneTestCase import setupPloneSite

from quills.core.interfaces import IWeblog
from quills.app.tests.base import BrowserMixin
from Products.QuillsEnabled.browser.activation import Toggle as BlogToggle

# Set up a Plone site, and apply the Quills extension profile
setupPloneSite(products=['QuillsEnabled'])


class QuillsTestCaseMixin(BrowserMixin):
    """Base class for integration tests for the 'Quills' product. This may
    provide specific set-up and tear-down operations, or provide convenience
    methods.
    """

    def afterSetUp(self):
        self.loginAsPortalOwner()
        self.weblog = self.createBlog('weblog')
        self.weblog_content = self.portal.weblog

    def createBlog(self, id):
        """Create a weblog instance."""
from Products.PloneTestCase.PloneTestCase import setupPloneSite
from Products.PloneTestCase.layer import onsetup

@onsetup
def setup_entitiesdirectory():
    fiveconfigure.debug_mode = True
    import collective.entitiesdirectory
    zcml.load_config('configure.zcml', collective.entitiesdirectory)
    fiveconfigure.debug_mode = False
    
    # Let Zope know about the products we require above-and-beyond a basic
    # Plone install (PloneTestCase takes care of these).
    ZopeTestCase.installPackage('collective.entitiesdirectory')

# Set up a Plone site, and quick-install the relevant products
setup_entitiesdirectory()
setupPloneSite(products=('collective.entitiesdirectory',))

class EntitiesDirectoryTestCase(PloneTestCase):
    """Base class for integration tests. 
    
    This may provide specific set-up and tear-down operations, or provide 
    convenience methods.
    """
    
class EntitiesDirectoryFunctionalTestCase(FunctionalTestCase):
    """Base class for functional integration tests. 
    
    This may provide specific set-up and tear-down operations, or provide 
    convenience methods.
    """
Esempio n. 9
0
    """
    fiveconfigure.debug_mode = True
    import eea.reports
    zcml.load_config('configure.zcml', eea.reports)

    try:
        import eea.rdfmarshaller
        zcml.load_config('configure.zcml', eea.rdfmarshaller)
    except ImportError:
        logger.warning("Could not import eea.rdfmarshaller")

    fiveconfigure.debug_mode = False


setup_eea_reports()
setupPloneSite(extension_profiles=('eea.reports:default',))

class ReportFunctionalTestCase(FunctionalTestCase):
    """Base class for functional integration tests for the 'Report' product.
    """
    def loadfile(self, rel_filename, ctype='application/pdf'):
        """ load a file
        """
        home = package_home(product_globals)
        filename = os.path.sep.join([home, rel_filename])
        data = open(filename, 'r').read()

        fp = StringIO(data)
        fp.seek(0)

        env = {'REQUEST_METHOD':'PUT'}
    
    class layer(PloneSite):
        
        @classmethod
        def setUp(cls):
            import bda.broschuerenshop
            fiveconfigure.debug_mode = True
            zcml.load_config('configure.zcml',
                             bda.broschuerenshop)
            fiveconfigure.debug_mode = False
        
        @classmethod
        def tearDown(cls):
            pass              

ZopeTestCase.installProduct('izBroschueren')
setupPloneSite(extension_profiles=['bda.broschuerenshop:default'])

def test_suite():
    import unittest
    suite = unittest.TestSuite()
    from Testing.ZopeTestCase import FunctionalDocFileSuite as FileSuite
    return unittest.TestSuite([
        FileSuite(
            file, 
            test_class=TestCase,
            optionflags=optionflags,
            globs={'interact': interact,
                   'pprint': pprint,},
        ) for file in TESTFILES
    ])
Esempio n. 11
0
    Load and install packages required for the collective.searchandreplace tests
    """

    fiveconfigure.debug_mode = True

    import collective.searchandreplace
    zcml.load_config('configure.zcml', collective.searchandreplace)

    fiveconfigure.debug_mode = False

    ztc.installPackage('collective.searchandreplace')


setup_searchandreplace_project()
setupPloneSite(
    with_default_memberarea=0,
    extension_profiles=['collective.searchandreplace:default'])

oflags = (doctest.ELLIPSIS |
          doctest.NORMALIZE_WHITESPACE)

prod = "collective.searchandreplace"


class SearchAndReplaceTestCase(PloneTestCase):
    """ Test Class """

    def _setupHomeFolder(self):
        """ Ugly hack to keep the underlying testing framework from trying to create a user folder."""
        pass
Esempio n. 12
0
"""

from Testing import ZopeTestCase
from Products.Five.testbrowser import Browser as BaseBrowser

# Let Zope know about the products we need. Only "old style" products with
# the "Products" prefix need to appear here.
ZopeTestCase.installProduct('fatsyndication')
ZopeTestCase.installProduct('Quills')

# Import PloneTestCase - this registers more products with Zope as a side effect
from Products.PloneTestCase import PloneTestCase
from Products.PloneTestCase.PloneTestCase import setupPloneSite

# Set up a Plone site, and apply the Quills extension profile
setupPloneSite(products=['Quills'])


class Browser(BaseBrowser):
    def addAuthorizationHeader(self,
                               user=PloneTestCase.default_user,
                               password=PloneTestCase.default_password):
        """Add an authorization header using the given or default credentials.
        """
        self.addHeader('Authorization', 'Basic %s:%s' % (user, password))
        return self


class QuillsTestCaseMixin:
    """Base class for integration tests for the 'Quills' product. This may
    provide specific set-up and tear-down operations, or provide convenience
# -*- coding: utf-8 -*-

from Testing.ZopeTestCase import installPackage
from Products.Five import zcml, fiveconfigure
from Products.PloneTestCase.PloneTestCase import setupPloneSite
from Products.PloneTestCase.layer import onsetup


@onsetup
def setup_product():
    """Setting up the package and including the ZCML
    """
    import sd.app
    fiveconfigure.debug_mode = True
    zcml.load_config('configure.zcml', sd.app)
    fiveconfigure.debug_mode = False
    installPackage('sd.app')


setup_product()
setupPloneSite(products=('sd.app',))
Esempio n. 14
0
"""

from Testing import ZopeTestCase
from Products.Five.testbrowser import Browser as BaseBrowser

# Let Zope know about the products we need. Only "old style" products with
# the "Products" prefix need to appear here. 
ZopeTestCase.installProduct('fatsyndication')
ZopeTestCase.installProduct('Quills')

# Import PloneTestCase - this registers more products with Zope as a side effect
from Products.PloneTestCase import PloneTestCase
from Products.PloneTestCase.PloneTestCase import setupPloneSite

# Set up a Plone site, and apply the Quills extension profile
setupPloneSite(products=['Quills'])


class Browser(BaseBrowser):

    def addAuthorizationHeader(self, user=PloneTestCase.default_user,
                               password=PloneTestCase.default_password):
        """Add an authorization header using the given or default credentials.
        """
        self.addHeader('Authorization', 'Basic %s:%s' % (user, password))
        return self


class QuillsTestCaseMixin:
    """Base class for integration tests for the 'Quills' product. This may
    provide specific set-up and tear-down operations, or provide convenience
Esempio n. 15
0
products installed.
"""

from Testing import ZopeTestCase

# Let Zope know about the products we require above-and-beyond a basic
# Plone install (PloneTestCase takes care of these).
ZopeTestCase.installProduct('ArchAddOn')

# Import PloneTestCase - this registers more products with Zope as a side effect
from Products.PloneTestCase.PloneTestCase import PloneTestCase
from Products.PloneTestCase.PloneTestCase import FunctionalTestCase
from Products.PloneTestCase.PloneTestCase import setupPloneSite

# Set up a Plone site, and install the ArchAddOn product.
setupPloneSite(products=('ArchAddOn', ))


class ArchAddOnTestCase(PloneTestCase):
    """Base class for integration tests for the 'ArchAddOn' product. This may
    provide specific set-up and tear-down operations, or provide convenience
    methods.
    """


class ArchAddOnFunctionalTestCase(FunctionalTestCase):
    """Base class for functional integration tests for the 'ArchAddOn' product.
    This may provide specific set-up and tear-down operations, or provide
    convenience methods.
    """
import unittest, doctest

from DateTime.DateTime import DateTime
from Testing.ZopeTestCase import FunctionalDocFileSuite as Suite

from Products.PloneTestCase.PloneTestCase import FunctionalTestCase, \
    setupPloneSite
setupPloneSite(extension_profiles=['upfront.diet:default'])

optionflags = doctest.REPORT_ONLY_FIRST_FAILURE | doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE

def addMember(self, username, fullname="", email="", roles=('Member',), last_login_time=None):
    self.portal.portal_membership.addMember(username, 'secret', roles, [])
    member = self.portal.portal_membership.getMemberById(username)
    member.setMemberProperties({'fullname': fullname, 'email': email,
                                'last_login_time': DateTime(last_login_time),})

def setUp(self):
    addMember(self, 'member1', 'Member one')

def test_suite():    
    tests = (
        Suite(
            'docs/foldercontents.txt', 
            package="upfront.foldercontents",
            setUp=setUp,
            optionflags=optionflags,
            test_class=FunctionalTestCase
        ),
    )    
    return unittest.TestSuite(tests)
Esempio n. 17
0
File: base.py Progetto: dtgit/ecec
from zope.testing import doctest
from Products.PloneTestCase.PloneTestCase import setupPloneSite, installProduct
from Products.PloneTestCase.PloneTestCase import PloneTestCase, FunctionalTestCase

installProduct("ContentLicensing")
setupPloneSite(extension_profiles=["Products.ContentLicensing:default"])

oflags = doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE

prod = "Products.ContentLicensing"


class ContentLicensingTestCase(PloneTestCase):
    """ Test Class """


class ContentLicensingFunctionalTestCase(FunctionalTestCase):
    """ Functional test class """
Esempio n. 18
0
# Let Zope know about the two products we require above-and-beyond a basic
# Plone install (PloneTestCase takes care of these).
ZopeTestCase.installProduct(PROJECT_NAME)

# Let Zope know about the two products we require above-and-beyond a basic
# Plone install (PloneTestCase takes care of these).
#ZopeTestCase.installProduct('PageCacheManager')
ZopeTestCase.installProduct('CMFSquidTool')
#ZopeTestCase.installProduct('PythonScripts')
#ZopeTestCase.installProduct(PROJECT_NAME)

# Import PloneTestCase - this registers more products with Zope as a side effect
from Products.PloneTestCase.PloneTestCase import PloneTestCase
from Products.PloneTestCase.PloneTestCase import FunctionalTestCase
from Products.PloneTestCase.PloneTestCase import setupPloneSite

# Set up a Plone site
setupPloneSite(products=[PROJECT_NAME])

class CacheFuTestCase(PloneTestCase):
    """Base class for integration tests for the 'CacheSetup' product. This may
    provide specific set-up and tear-down operations, or provide convenience
    methods.
    """
class CacheFuFunctionalTestCase(FunctionalTestCase):
    """Base class for functional integration tests for the 'CacheSetup' product. 
    This may provide specific set-up and tear-down operations, or provide 
    convenience methods.
    """
Esempio n. 19
0
File: base.py Progetto: dtgit/dtedu
from zope.testing import doctest
from unittest import TestSuite
from zope.testing.doctestunit import DocFileSuite
from Testing.ZopeTestCase import FunctionalDocFileSuite
from Testing.ZopeTestCase import ZopeDocFileSuite
from Products.PloneTestCase.PloneTestCase import FunctionalTestCase
from Products.PloneTestCase.PloneTestCase import setupPloneSite, installProduct

installProduct('PloneBookmarklets')
setupPloneSite(extension_profiles=['Products.PloneBookmarklets:default'])

oflags = (doctest.ELLIPSIS |
          doctest.NORMALIZE_WHITESPACE)

prod = 'Products.PloneBookmarklets'




Esempio n. 20
0
# Set up a Plone site - note that the portlets branch of CMFPlone applies
# a portlets profile.
ZopeTestCase.installProduct('ATVocabularyManager')

@onsetup
def setup():
    fiveconfigure.debug_mode = True
    import slc.treecategoriesexample
    import slc.treecategories
    zcml.load_config('configure.zcml', slc.treecategoriesexample)
    zcml.load_config('configure.zcml', slc.treecategories)
    fiveconfigure.debug_mode = False
    ZopeTestCase.installPackage('slc.treecategoriesexample')

setup()
setupPloneSite(products=['slc.treecategories', 'Products.ATVocabularyManager', 'slc.treecategoriesexample'])

class PortletsTestCase(PloneTestCase):
    """
    Base class for integration tests for plone.app.portlets. This may
    provide specific set-up and tear-down operations, or provide convenience
    methods.
    """

class PortletsFunctionalTestCase(FunctionalTestCase):
    """
    Base class for functional integration tests for plone.app.portlets.
    This may provide specific set-up and tear-down operations, or provide
    convenience methods.
    """
Esempio n. 21
0
from Products.PloneTestCase.PloneTestCase import PloneTestCase
from Products.PloneTestCase.PloneTestCase import FunctionalTestCase
from Products.PloneTestCase.PloneTestCase import setupPloneSite

from Products.Five import fiveconfigure
from Products.Five import zcml

from Products.PloneTestCase.layer import onsetup
from Products.PloneTestCase.layer import PloneSite

@onsetup
def install_plugins():
    ZopeTestCase.installPackage('collective.psc.externalstorage')

install_plugins()
setupPloneSite(products=('PloneSoftwareCenter',))

class DeveloperWarning(Warning):
    pass

def developer_warning(msg):
    warnings.warn(msg, DeveloperWarning)

class PSCTestCase(PloneTestCase):
    """Base class for integration tests
    """
    def warning(self, msg):
        developer_warning(msg)

    class layer(PloneSite):
        @classmethod
Esempio n. 22
0
Note that importing this module has various side-effects: it registers a set of
products with Zope, and it sets up a sandbox Plone site with the appropriate
products installed.
"""

from Testing import ZopeTestCase

# Let Zope know about the products we require above-and-beyond a basic
# Plone install (PloneTestCase takes care of these).
ZopeTestCase.installProduct('ArchAddOn')

# Import PloneTestCase - this registers more products with Zope as a side effect
from Products.PloneTestCase.PloneTestCase import PloneTestCase
from Products.PloneTestCase.PloneTestCase import FunctionalTestCase
from Products.PloneTestCase.PloneTestCase import setupPloneSite

# Set up a Plone site, and install the ArchAddOn product.
setupPloneSite(products=('ArchAddOn',))

class ArchAddOnTestCase(PloneTestCase):
    """Base class for integration tests for the 'ArchAddOn' product. This may
    provide specific set-up and tear-down operations, or provide convenience
    methods.
    """

class ArchAddOnFunctionalTestCase(FunctionalTestCase):
    """Base class for functional integration tests for the 'ArchAddOn' product.
    This may provide specific set-up and tear-down operations, or provide
    convenience methods.
    """
    """
    Load and install packages required for the collective.contentlicensing tests
    """

    fiveconfigure.debug_mode = True

    import collective.contentlicensing
    zcml.load_config('configure.zcml', collective.contentlicensing)

    fiveconfigure.debug_mode = False

    ztc.installPackage('collective.contentlicensing')


setup_contentlicensing_project()
setupPloneSite(with_default_memberarea=0,
               extension_profiles=['collective.contentlicensing:default'])

oflags = (doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE)

prod = "collective.contentlicensing"


class ContentLicensingTestCase(PloneTestCase):
    """ Test Class """
    def _setupHomeFolder(self):
        """ Ugly hack to keep the underlying testing framework from trying to create a user folder."""
        pass


class BlobContentLicensingTestCase(PloneTestCase):
    """ Test Class with blob support """
Esempio n. 24
0
from Testing import ZopeTestCase

# Let Zope know about the products we require above and beyond a basic
# Plone install (PloneTestCase takes care of these).
ZopeTestCase.installProduct('DataGridField')
ZopeTestCase.installProduct('ECQuiz')

# Import PloneTestCase - this registers more products with Zope as a side effect
from Products.PloneTestCase.PloneTestCase import PloneTestCase
from Products.PloneTestCase.PloneTestCase import FunctionalTestCase
from Products.PloneTestCase.PloneTestCase import setupPloneSite

# Set up a Plone site, and apply the membrane and borg extension profiles
# to make sure they are installed.
#setupPloneSite(extension_profiles=('membrane:default', 'borg:default'))
setupPloneSite(products=('ECQuiz',))

from Products.ECQuiz.tools import createObject

def getAccessor(obj, prop_name, getter_p):
    if getter_p:
        prefix = 'get'
    else:
        prefix = 'set'
    name = prefix + prop_name[0].upper() + prop_name[1:]
    return getattr(obj, name)

def setProp(obj, prop_name, value):
    f = getAccessor(obj, prop_name, False)
    f(value)
Esempio n. 25
0
# Let Zope know about the two products we require above-and-beyond a basic
# Plone install (PloneTestCase takes care of these).
ZopeTestCase.installProduct('PloneSurvey')

# Import PloneTestCase - this registers more products with Zope as a side effect
from Products.PloneTestCase.PloneTestCase import PloneTestCase
from Products.PloneTestCase.PloneTestCase import FunctionalTestCase
from Products.PloneTestCase.PloneTestCase import setupPloneSite

from Products.PloneSurvey.config import DEFAULT_SURVEY_INVITE
from Products.PloneSurvey.tests import utils
from utils import MockMailHost

# Set up a Plone site, and apply the extension profiles
# to make sure they are installed.
setupPloneSite(extension_profiles=('Products.PloneSurvey:default',))

class PloneSurveyTestCase(PloneTestCase):
    """Base class for integration tests for the 'PloneSurvey' product.
    """

    def addMember(self, username, fullname, email, roles, last_login_time):
        self.portal.portal_membership.addMember(username, 'secret', roles, [])
        member = self.portal.portal_membership.getMemberById(username)
        member.setMemberProperties({'fullname': fullname, 'email': email,
                                    'last_login_time': DateTime(last_login_time),})

    def useMockMailHost(self):
        self.portal.MailHost = MockMailHost('MailHost')

    def createAnonSurvey(self):
Esempio n. 26
0
"""Base class for integration tests, based on ZopeTestCase and PloneTestCase.

Note that importing this module has various side-effects: it registers a set of
products with Zope, and it sets up a sandbox Plone site with the appropriate
products installed.
"""

# Import PloneTestCase - this registers more products with Zope as a side effect
from Products.PloneTestCase.PloneTestCase import PloneTestCase
from Products.PloneTestCase.PloneTestCase import FunctionalTestCase
from Products.PloneTestCase.PloneTestCase import setupPloneSite
from zope.component import getMultiAdapter

# Set up a Plone site - note that the portlets branch of CMFPlone applies
# a portlets profile.
setupPloneSite()


class ContentRulesTestCase(PloneTestCase):
    """Base class for integration tests for plone.app.contentrules. This may
    provide specific set-up and tear-down operations, or provide convenience
    methods.
    """

    def addAuthToRequest(self):
        portal = self.portal
        request = portal.REQUEST
        authenticator = getMultiAdapter((portal, request), name=u"authenticator")
        auth = authenticator.authenticator().split('value="')[1].rstrip('"/>')
        request.form["_authenticator"] = auth
from Testing import ZopeTestCase

# Let Zope know about the two products we require above-and-beyond a basic
# Plone install (PloneTestCase takes care of these).
ZopeTestCase.installProduct('Relations')
ZopeTestCase.installProduct('PloneOntology')

# Import PloneTestCase - this registers more products with Zope as a side effect
from Products.PloneTestCase.PloneTestCase import PloneTestCase
from Products.PloneTestCase.PloneTestCase import FunctionalTestCase
from Products.PloneTestCase.PloneTestCase import setupPloneSite

# Set up a Plone site, and apply the Relations and PloneOntology extension
# profiles to make sure they are installed.
setupPloneSite(products=('Relations', 'PloneOntology'))

class PloneOntologyTestCase(PloneTestCase):
    """Base class for integration tests for the 'PloneOntology' product.
    """

    def tearDown(self):
        self.portal.portal_classification._p_deactivate() # Drop _v_relcache
        super(PloneOntologyTestCase, self).tearDown()

class PloneOntologyFunctionalTestCase(FunctionalTestCase):
    """Base class for functional integration tests for the 'PloneOntology' product.
    """

    def tearDown(self):
        self.portal.portal_classification._p_deactivate() # Drop _v_relcache
        super(PloneOntologyFunctionalTestCase, self).tearDown()