source: products/quintagroup.seoptimizer/branches/refactoring2.3.0/quintagroup/seoptimizer/tests/base.py @ 1901

Last change on this file since 1901 was 1896, checked in by mylan, 14 years ago

#161: Add Installed and NotInstalled? layers

File size: 2.3 KB
RevLine 
[1493]1"""Test setup for integration and functional tests.
2
3When we import PloneTestCase and then call setupPloneSite(), all of
4Plone's products are loaded, and a Plone site will be created. This
5happens at module level, which makes it faster to run each test, but
6slows down test runner startup.
7"""
8import re
[1896]9import transaction
[1493]10from AccessControl.SecurityManagement import newSecurityManager
11
12from Products.Five import zcml
13from Products.Five import fiveconfigure
14
15from Testing import ZopeTestCase as ztc
16
[1877]17from Products.CMFCore.utils import getToolByName
18
[1896]19from Products.PloneTestCase.layer import onsetup, PloneSite
[1493]20from Products.PloneTestCase import PloneTestCase as ptc
[1896]21from Products.PloneTestCase import setup as ptc_setup
22
[1877]23from Products.PloneTestCase.PloneTestCase import portal_owner
24from Products.PloneTestCase.PloneTestCase import default_user
25from Products.PloneTestCase.PloneTestCase import default_password
[1493]26
[1877]27from quintagroup.seoptimizer.config import *
[1493]28
[1896]29ptc.setupPloneSite()
[1493]30
[1896]31class NotInstalled(PloneSite):
32    """ Only package register, without installation into portal
[1493]33    """
34
[1896]35    @classmethod
36    def setUp(cls):
37        fiveconfigure.debug_mode = True
38        import quintagroup.seoptimizer
39        zcml.load_config('configure.zcml', quintagroup.seoptimizer)
40        #zcml.load_config('overrides.zcml', quintagroup.seoptimizer)
41        fiveconfigure.debug_mode = False
42        ztc.installPackage(PROJECT_NAME)
[1493]43
44
[1896]45class Installed(NotInstalled):
46    """ Install product into the portal
47    """
48    @classmethod
49    def setUp(cls):
50        app = ztc.app()
51        portal = app[ptc_setup.portal_name]
52        qi = getattr(portal, 'portal_quickinstaller', None)
53        qi.installProduct(PROJECT_NAME)
54        transaction.commit()
[1493]55
56
[1792]57class MixinTestCase:
[1493]58
[1792]59    def _getauth(self):
60        # Fix authenticator for the form
61        import re
62
63        authenticator = self.portal.restrictedTraverse("@@authenticator")
64        html = authenticator.authenticator()
65        handle = re.search('value="(.*)"', html).groups()[0]
66        return handle
67
68
69class TestCase(MixinTestCase, ptc.PloneTestCase):
[1896]70    layer = Installed
[1493]71
[1896]72class TestCaseNotInstalled(MixinTestCase, ptc.PloneTestCase):
73    layer = NotInstalled
[1493]74
75
[1896]76class FunctionalTestCase(MixinTestCase, ptc.FunctionalTestCase):
77    layer = Installed
[1493]78
[1896]79class FunctionalTestCaseNotInstalled(MixinTestCase, ptc.FunctionalTestCase):
80    layer = NotInstalled
Note: See TracBrowser for help on using the repository browser.