source: products/quintagroup.seoptimizer/branches/plone4/quintagroup/seoptimizer/tests/base.py @ 2958

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

Merged 3.0.5 to 3.0.7 changes from trunk into plone-4 branch version.

Merged revisions 3942-3945,3966-3976,3982-3983,3994 via svnmerge from
http://svn.quintagroup.com/products/quintagroup.seoptimizer/trunk

........

r3942 | mylan | 2010-10-20 17:06:46 +0300 (Wed, 20 Oct 2010) | 1 line


#233: Bump version to 3.0.7, updated history

........

r3943 | olha | 2010-10-20 17:14:52 +0300 (Wed, 20 Oct 2010) | 1 line


HISTORY.txt checked

........

r3944 | olha | 2010-10-20 17:20:15 +0300 (Wed, 20 Oct 2010) | 1 line


internal README file updated

........

r3945 | mylan | 2010-10-20 18:16:14 +0300 (Wed, 20 Oct 2010) | 1 line


#233: Updated list of supported version in README.txt to 3.1+

........

r3966 | mylan | 2010-10-26 17:33:27 +0300 (Tue, 26 Oct 2010) | 1 line


#233: Reduce catch exceptions to URLError and HTTPError, log error to error_log, return link to error_log

........

r3967 | mylan | 2010-10-26 17:34:03 +0300 (Tue, 26 Oct 2010) | 1 line


#233: Update tests for catching errors on keywords calculation

........

r3968 | mylan | 2010-10-26 17:55:15 +0300 (Tue, 26 Oct 2010) | 1 line


#233: Make code more readable

........

r3969 | mylan | 2010-10-26 18:08:15 +0300 (Tue, 26 Oct 2010) | 1 line


#233: Force to get portal_transforms as utility

........

r3970 | mylan | 2010-10-26 18:14:46 +0300 (Tue, 26 Oct 2010) | 1 line


#233: little cleanup

........

r3971 | mylan | 2010-10-26 20:35:28 +0300 (Tue, 26 Oct 2010) | 1 line


#233: Force logging keywords calculation to nearest to context error_log object. Other minor fixes

........

r3972 | mylan | 2010-10-26 21:08:06 +0300 (Tue, 26 Oct 2010) | 1 line


#233: Return getting error_log with getToolByName as more flexible and accurate

........

r3973 | mylan | 2010-10-27 18:09:31 +0300 (Wed, 27 Oct 2010) | 1 line


#233: Correct HISTORY information

........

r3974 | mylan | 2010-10-27 18:16:40 +0300 (Wed, 27 Oct 2010) | 1 line


#233: Added plone.browserlayer to requirements for Plone-3.0 support

........

r3975 | mylan | 2010-10-27 18:18:13 +0300 (Wed, 27 Oct 2010) | 1 line


#233: Fixed testcases to emulate proper test environment for plone-3.0

........

r3976 | mylan | 2010-10-27 18:21:55 +0300 (Wed, 27 Oct 2010) | 1 line


#233: Described steps for use the package with plone-3.0.

........

r3982 | olha | 2010-10-29 13:16:55 +0300 (Fri, 29 Oct 2010) | 1 line


doc files corrected a bit

........

r3983 | olha | 2010-10-29 13:20:45 +0300 (Fri, 29 Oct 2010) | 1 line


wrong line spacing corrected

........

r3994 | mylan | 2010-11-01 16:59:34 +0200 (Mon, 01 Nov 2010) | 1 line


Removed devloper settings of the package configuration

........

File size: 3.1 KB
Line 
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
9import transaction
10from zope.component import getUtility
11
12# Starting from plone.memoize v1.1a4 (used in plone4), global ram cache
13# utility provides other IRAMCache interface, than before
14try:
15    # In plone4 provides
16    from zope.ramcache.interfaces.ram import IRAMCache
17except ImportError:
18    # In plone3 provides
19    from zope.app.cache.interfaces.ram import IRAMCache
20
21from Products.Five import zcml
22from Products.Five import fiveconfigure
23
24from Testing import ZopeTestCase as ztc
25
26from Products.CMFCore.utils import getToolByName
27
28from Products.PloneTestCase.layer import PloneSite
29from Products.PloneTestCase import PloneTestCase as ptc
30from Products.PloneTestCase import setup as ptc_setup
31
32from Products.PloneTestCase.PloneTestCase import portal_owner
33from Products.PloneTestCase.PloneTestCase import default_password
34
35from quintagroup.seoptimizer.config import PROJECT_NAME
36from quintagroup.seoptimizer.config import SUPPORT_BLAYER
37
38ptc.setupPloneSite()
39
40class NotInstalled(PloneSite):
41    """ Only package register, without installation into portal
42    """
43
44    @classmethod
45    def setUp(cls):
46        fiveconfigure.debug_mode = True
47        import quintagroup.seoptimizer
48        zcml.load_config('configure.zcml', quintagroup.seoptimizer)
49        fiveconfigure.debug_mode = False
50        ztc.installPackage(PROJECT_NAME)
51
52
53class Installed(NotInstalled):
54    """ Install product into the portal
55    """
56    @classmethod
57    def setUp(cls):
58        app = ztc.app()
59        portal = app[ptc_setup.portal_name]
60
61        # Sets the local site/manager
62        ptc_setup._placefulSetUp(portal)
63        # Install PROJECT
64        qi = getattr(portal, 'portal_quickinstaller', None)
65        if not ptc.PLONE31:
66            qi.installProduct("plone.browserlayer")
67        qi.installProduct(PROJECT_NAME)
68        transaction.commit()
69
70    @classmethod
71    def tearDown(cls):
72        ptc_setup._placefulTearDown()
73       
74
75class MixinTestCase:
76
77    def _getauth(self):
78        # Fix authenticator for the form
79        import re
80        try:
81            authenticator = self.portal.restrictedTraverse("@@authenticator")
82        except:
83            handle  = ""
84        else:
85            html = authenticator.authenticator()
86            handle = re.search('value="(.*)"', html).groups()[0]
87        return handle
88
89    def beforeTearDown(self):
90        getUtility(IRAMCache).invalidateAll()
91
92
93class TestCase(MixinTestCase, ptc.PloneTestCase):
94    layer = Installed
95
96class TestCaseNotInstalled(MixinTestCase, ptc.PloneTestCase):
97    layer = NotInstalled
98
99
100class FunctionalTestCase(MixinTestCase, ptc.FunctionalTestCase):
101    layer = Installed
102
103class FunctionalTestCaseNotInstalled(MixinTestCase, ptc.FunctionalTestCase):
104    layer = NotInstalled
105
106    def afterSetUp(self):
107        qi = getattr(self.portal, 'portal_quickinstaller', None)
108        if not ptc.PLONE31:
109            qi.installProduct("plone.browserlayer")
Note: See TracBrowser for help on using the repository browser.