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