[1493] | 1 | """Test setup for integration and functional tests. |
---|
| 2 | |
---|
| 3 | When we import PloneTestCase and then call setupPloneSite(), all of |
---|
| 4 | Plone's products are loaded, and a Plone site will be created. This |
---|
| 5 | happens at module level, which makes it faster to run each test, but |
---|
| 6 | slows down test runner startup. |
---|
| 7 | """ |
---|
| 8 | import re |
---|
[1896] | 9 | import transaction |
---|
[1493] | 10 | from AccessControl.SecurityManagement import newSecurityManager |
---|
| 11 | |
---|
| 12 | from Products.Five import zcml |
---|
| 13 | from Products.Five import fiveconfigure |
---|
| 14 | |
---|
| 15 | from Testing import ZopeTestCase as ztc |
---|
| 16 | |
---|
[1877] | 17 | from Products.CMFCore.utils import getToolByName |
---|
| 18 | |
---|
[1896] | 19 | from Products.PloneTestCase.layer import onsetup, PloneSite |
---|
[1493] | 20 | from Products.PloneTestCase import PloneTestCase as ptc |
---|
[1896] | 21 | from Products.PloneTestCase import setup as ptc_setup |
---|
| 22 | |
---|
[1877] | 23 | from Products.PloneTestCase.PloneTestCase import portal_owner |
---|
| 24 | from Products.PloneTestCase.PloneTestCase import default_user |
---|
| 25 | from Products.PloneTestCase.PloneTestCase import default_password |
---|
[1493] | 26 | |
---|
[1877] | 27 | from quintagroup.seoptimizer.config import * |
---|
[1493] | 28 | |
---|
[1896] | 29 | ptc.setupPloneSite() |
---|
[1493] | 30 | |
---|
[1896] | 31 | class 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] | 45 | class 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] | 57 | class 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 | |
---|
| 69 | class TestCase(MixinTestCase, ptc.PloneTestCase): |
---|
[1896] | 70 | layer = Installed |
---|
[1493] | 71 | |
---|
[1896] | 72 | class TestCaseNotInstalled(MixinTestCase, ptc.PloneTestCase): |
---|
| 73 | layer = NotInstalled |
---|
[1493] | 74 | |
---|
| 75 | |
---|
[1896] | 76 | class FunctionalTestCase(MixinTestCase, ptc.FunctionalTestCase): |
---|
| 77 | layer = Installed |
---|
[1493] | 78 | |
---|
[1896] | 79 | class FunctionalTestCaseNotInstalled(MixinTestCase, ptc.FunctionalTestCase): |
---|
| 80 | layer = NotInstalled |
---|