1 | import transaction |
---|
2 | |
---|
3 | from Products.Five import zcml |
---|
4 | from Products.Five import fiveconfigure |
---|
5 | from Testing import ZopeTestCase as ztc |
---|
6 | |
---|
7 | from Products.PloneTestCase.layer import PloneSite |
---|
8 | from Products.PloneTestCase import setup as ptc_setup |
---|
9 | from Products.PloneTestCase import PloneTestCase as ptc |
---|
10 | |
---|
11 | PACKAGES = [ |
---|
12 | 'quintagroup.captcha.core', |
---|
13 | 'quintagroup.pfg.captcha', |
---|
14 | ] |
---|
15 | REQUIREMENTS = ['PloneFormGen', ] + PACKAGES |
---|
16 | |
---|
17 | ptc.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. |
---|
22 | ztc.installProduct('PloneFormGen') |
---|
23 | |
---|
24 | |
---|
25 | class 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 | |
---|
42 | class 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 | |
---|
64 | class TestCase(ptc.PloneTestCase): |
---|
65 | layer = Installed |
---|
66 | |
---|
67 | |
---|
68 | class TestCaseNotInstalled(ptc.PloneTestCase): |
---|
69 | layer = NotInstalled |
---|