1 | from zope.interface import alsoProvides |
---|
2 | |
---|
3 | from AccessControl import getSecurityManager |
---|
4 | from AccessControl.SecurityManagement import setSecurityManager |
---|
5 | |
---|
6 | from Testing import ZopeTestCase as ztc |
---|
7 | from Products.Five import fiveconfigure |
---|
8 | from Products.PloneTestCase import PloneTestCase as ptc |
---|
9 | |
---|
10 | from collective.testcaselayer.ptc import BasePTCLayer, ptc_layer |
---|
11 | |
---|
12 | from Products.CMFCore.utils import getToolByName |
---|
13 | |
---|
14 | from quintagroup.dropdownmenu import PROJECT_NAME |
---|
15 | from quintagroup.dropdownmenu.interfaces import IDropDownMenuLayer |
---|
16 | |
---|
17 | IPREFIX = 'quintagroup.dropdownmenu.interfaces.IDropDownMenuSettings.' |
---|
18 | |
---|
19 | # This step made in collective.testcaselayer.ptc |
---|
20 | #ptc.setupPloneSite() |
---|
21 | |
---|
22 | |
---|
23 | class NotInstalled(BasePTCLayer): |
---|
24 | """Initialize the package, without installation into portal |
---|
25 | """ |
---|
26 | def afterSetUp(self): |
---|
27 | fiveconfigure.debug_mode = True |
---|
28 | import quintagroup.dropdownmenu |
---|
29 | self.loadZCML('configure.zcml', package=quintagroup.dropdownmenu) |
---|
30 | fiveconfigure.debug_mode = False |
---|
31 | ztc.installPackage(PROJECT_NAME) |
---|
32 | |
---|
33 | |
---|
34 | class Installed(BasePTCLayer): |
---|
35 | """ Install product into the portal |
---|
36 | """ |
---|
37 | def afterSetUp(self): |
---|
38 | self.addProduct(PROJECT_NAME) |
---|
39 | |
---|
40 | |
---|
41 | class UnInstalled(BasePTCLayer): |
---|
42 | """ UnInstall product from the portal |
---|
43 | """ |
---|
44 | def afterSetUp(self): |
---|
45 | sm = getSecurityManager() |
---|
46 | self.loginAsPortalOwner() |
---|
47 | try: |
---|
48 | qi = self.portal.portal_quickinstaller |
---|
49 | qi.uninstallProducts(products=[PROJECT_NAME, ]) |
---|
50 | #self._refreshSkinData() |
---|
51 | finally: |
---|
52 | setSecurityManager(sm) |
---|
53 | |
---|
54 | NotInstalledLayer = NotInstalled([ptc_layer, ]) |
---|
55 | InstalledLayer = Installed([NotInstalledLayer, ]) |
---|
56 | UnInstalledLayer = UnInstalled([InstalledLayer, ]) |
---|
57 | |
---|
58 | |
---|
59 | class TestCaseNotInstalled(ptc.PloneTestCase): |
---|
60 | layer = NotInstalledLayer |
---|
61 | |
---|
62 | |
---|
63 | class TestCase(ptc.PloneTestCase): |
---|
64 | layer = InstalledLayer |
---|
65 | |
---|
66 | def afterSetUp(self): |
---|
67 | # mark request with our browser layer |
---|
68 | super(TestCase, self).afterSetUp() |
---|
69 | alsoProvides(self.app.REQUEST, IDropDownMenuLayer) |
---|
70 | |
---|
71 | |
---|
72 | class TestCaseUnInstalled(ptc.PloneTestCase): |
---|
73 | layer = UnInstalledLayer |
---|
74 | |
---|
75 | |
---|
76 | class FunctionalTestCaseNotInstalled(ptc.FunctionalTestCase): |
---|
77 | layer = NotInstalledLayer |
---|
78 | |
---|
79 | |
---|
80 | class FunctionalTestCase(ptc.FunctionalTestCase): |
---|
81 | layer = InstalledLayer |
---|
82 | |
---|
83 | def afterSetUp(self): |
---|
84 | # mark request with our browser layer |
---|
85 | super(FunctionalTestCase, self).afterSetUp() |
---|
86 | alsoProvides(self.app.REQUEST, IDropDownMenuLayer) |
---|
87 | |
---|
88 | |
---|
89 | class FunctionalTestCaseUnInstalled(ptc.FunctionalTestCase): |
---|
90 | layer = UnInstalledLayer |
---|