| 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 | 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 | |
|---|
| 32 | class Installed(BasePTCLayer): |
|---|
| 33 | """ Install product into the portal |
|---|
| 34 | """ |
|---|
| 35 | def afterSetUp(self): |
|---|
| 36 | self.addProduct(PROJECT_NAME) |
|---|
| 37 | |
|---|
| 38 | class UnInstalled(BasePTCLayer): |
|---|
| 39 | """ UnInstall product from the portal |
|---|
| 40 | """ |
|---|
| 41 | def afterSetUp(self): |
|---|
| 42 | sm = getSecurityManager() |
|---|
| 43 | self.loginAsPortalOwner() |
|---|
| 44 | try: |
|---|
| 45 | qi = self.portal.portal_quickinstaller |
|---|
| 46 | qi.uninstallProducts(products=[PROJECT_NAME,]) |
|---|
| 47 | #self._refreshSkinData() |
|---|
| 48 | finally: |
|---|
| 49 | setSecurityManager(sm) |
|---|
| 50 | |
|---|
| 51 | NotInstalledLayer = NotInstalled([ptc_layer,]) |
|---|
| 52 | InstalledLayer = Installed([NotInstalledLayer,]) |
|---|
| 53 | UnInstalledLayer = UnInstalled([InstalledLayer,]) |
|---|
| 54 | |
|---|
| 55 | |
|---|
| 56 | class TestCaseNotInstalled(ptc.PloneTestCase): |
|---|
| 57 | layer = NotInstalledLayer |
|---|
| 58 | |
|---|
| 59 | class TestCase(ptc.PloneTestCase): |
|---|
| 60 | layer = InstalledLayer |
|---|
| 61 | |
|---|
| 62 | def afterSetUp(self): |
|---|
| 63 | # mark request with our browser layer |
|---|
| 64 | super(TestCase, self).afterSetUp() |
|---|
| 65 | alsoProvides(self.app.REQUEST, IDropDownMenuLayer) |
|---|
| 66 | |
|---|
| 67 | class TestCaseUnInstalled(ptc.PloneTestCase): |
|---|
| 68 | layer = UnInstalledLayer |
|---|
| 69 | |
|---|
| 70 | |
|---|
| 71 | class FunctionalTestCaseNotInstalled(ptc.FunctionalTestCase): |
|---|
| 72 | layer = NotInstalledLayer |
|---|
| 73 | |
|---|
| 74 | class FunctionalTestCase(ptc.FunctionalTestCase): |
|---|
| 75 | layer = InstalledLayer |
|---|
| 76 | |
|---|
| 77 | def afterSetUp(self): |
|---|
| 78 | # mark request with our browser layer |
|---|
| 79 | super(FunctionalTestCase, self).afterSetUp() |
|---|
| 80 | alsoProvides(self.app.REQUEST, IDropDownMenuLayer) |
|---|
| 81 | |
|---|
| 82 | class FunctionalTestCaseUnInstalled(ptc.FunctionalTestCase): |
|---|
| 83 | layer = UnInstalledLayer |
|---|