source: products/quintagroup.pfg.captcha/trunk/quintagroup/pfg/captcha/tests/base.py

Last change on this file was 3212, checked in by vmaksymiv, 13 years ago

fixed tests plone3.0 compatibility

  • Property svn:eol-style set to native
File size: 1.8 KB
Line 
1import transaction
2
3from Products.Five import zcml
4from Products.Five import fiveconfigure
5from Testing import ZopeTestCase as ztc
6
7from Products.PloneTestCase.layer import PloneSite
8from Products.PloneTestCase import setup as ptc_setup
9from Products.PloneTestCase import PloneTestCase as ptc
10
11PACKAGES = [
12    'quintagroup.captcha.core',
13    'quintagroup.pfg.captcha',
14]
15REQUIREMENTS = ['PloneFormGen', ] + PACKAGES
16
17ptc.setupPloneSite()
18
19# !!! Not initialized factory methods for the content types
20# !!! (for Plone-4+) if located in NotInstalled.setUp
21# !!! method of the layer class.
22ztc.installProduct('PloneFormGen')
23
24
25class NotInstalled(PloneSite):
26    """ Only package register, without installation into portal
27    """
28    @classmethod
29    def setUp(cls):
30        fiveconfigure.debug_mode = True
31        import quintagroup.pfg.captcha
32        zcml.load_config('configure.zcml', quintagroup.pfg.captcha)
33        fiveconfigure.debug_mode = False
34        ztc.installPackage('quintagroup.pfg.captcha')
35        ztc.installPackage('quintagroup.captcha.core')
36
37    @classmethod
38    def tearDown(cls):
39        ptc_setup.cleanupPloneSite(ptc_setup.portal_name)
40
41
42class Installed(NotInstalled):
43    """ Install product into the portal
44    """
45    @classmethod
46    def setUp(cls):
47        app = ztc.app()
48        portal = app[ptc_setup.portal_name]
49
50        # Sets the local site/manager
51        ptc_setup._placefulSetUp(portal)
52        # Install PROJECT
53        qi = getattr(portal, 'portal_quickinstaller', None)
54        for p in REQUIREMENTS:
55            if not qi.isProductInstalled(p):
56                qi.installProduct(p)
57        transaction.commit()
58
59    @classmethod
60    def tearDown(cls):
61        ptc_setup._placefulTearDown()
62
63
64class TestCase(ptc.PloneTestCase):
65    layer = Installed
66
67
68class TestCaseNotInstalled(ptc.PloneTestCase):
69    layer = NotInstalled
Note: See TracBrowser for help on using the repository browser.