##############################################################################
# Copyright (c) 2005 The Open Planning Project, Rob Miller, and contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the GNU General Public
# License, Version 2.0 (GPL).  A copy of the GPL should accompany this
# distribution.  THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL
# EXPRESS OR IMPLIED WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY,
# AGAINST INFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
##############################################################################

"""
Test case base class

$Id: base.py 15510 2006-01-05 21:55:41Z rafrombrc $
"""

from Testing import ZopeTestCase
from Testing.ZopeTestCase.functional import Functional
from Products.PloneTestCase import ptc, setup

from Products.CMFCore.utils import getToolByName

from Products.Anonymailer.config import Z_DEPENDENCIES, DEPENDENCIES, PROJECT_NAME

for x in Z_DEPENDENCIES + DEPENDENCIES + [PROJECT_NAME]:
    ZopeTestCase.installProduct(x)

class AnonymailerTestCase(ptc.PloneTestCase):
    """ Anonymailer product test case base class """

    def installProducts(self, products):
        qi = getToolByName(self.portal, 'portal_quickinstaller')
        for product in products:
            if not qi.isProductInstalled(product):
                if qi.isProductInstallable(product):
                    qi.installProduct(product)
                else:
                    raise "Product %s not installable" % product

    def afterSetUp(self):
        self.installProducts(DEPENDENCIES + [PROJECT_NAME])


class AnonymailerFunctionalTestCase(Functional, AnonymailerTestCase):
    """ Anonymailer functional test case base class """
    __implements__ = Functional.__implements__ + AnonymailerTestCase.__implements__


setup.setupPloneSite()
