1 | import unittest |
---|
2 | |
---|
3 | import transaction |
---|
4 | from AccessControl.SecurityManagement import newSecurityManager, \ |
---|
5 | noSecurityManager |
---|
6 | from Testing import ZopeTestCase as ztc |
---|
7 | |
---|
8 | # BBB: compatibility with older plone versions |
---|
9 | try: |
---|
10 | # Plone < 4.3 |
---|
11 | from zope.app.component import hooks |
---|
12 | setSite = hooks.setSite |
---|
13 | setHooks = hooks.setHooks |
---|
14 | except ImportError: |
---|
15 | # Plone >= 4.3 |
---|
16 | from zope.component.hooks import setSite, setHooks |
---|
17 | |
---|
18 | from plone.browserlayer.utils import registered_layers |
---|
19 | |
---|
20 | from Products.CMFCore.utils import getToolByName |
---|
21 | from Products.PloneTestCase.layer import PloneSiteLayer |
---|
22 | |
---|
23 | from quintagroup.plonetabs.tests.base import PloneTabsTestCase |
---|
24 | |
---|
25 | |
---|
26 | class TestErase(PloneTabsTestCase): |
---|
27 | # we use here nested layer for not to make an impact on |
---|
28 | # the rest test cases, this test case check uninstall procedure |
---|
29 | # thus it has to uninstall package which will be required to |
---|
30 | # be installed for other test cases |
---|
31 | class layer(PloneSiteLayer): |
---|
32 | @classmethod |
---|
33 | def setUp(cls): |
---|
34 | |
---|
35 | app = ztc.app() |
---|
36 | portal = app.plone |
---|
37 | |
---|
38 | # change the active local site manager |
---|
39 | setHooks() |
---|
40 | setSite(portal) |
---|
41 | |
---|
42 | # elevate permissions |
---|
43 | user = portal.getWrappedOwner() |
---|
44 | newSecurityManager(None, user) |
---|
45 | |
---|
46 | tool = getToolByName(portal, 'portal_quickinstaller') |
---|
47 | product_name = 'quintagroup.plonetabs' |
---|
48 | if tool.isProductInstalled(product_name): |
---|
49 | tool.uninstallProducts([product_name, ]) |
---|
50 | |
---|
51 | # drop elevated perms |
---|
52 | noSecurityManager() |
---|
53 | |
---|
54 | transaction.commit() |
---|
55 | ztc.close(app) |
---|
56 | |
---|
57 | def afterSetUp(self): |
---|
58 | self.loginAsPortalOwner() |
---|
59 | |
---|
60 | def test_actionIcons(self): |
---|
61 | tool = getToolByName(self.portal, 'portal_actionicons') |
---|
62 | icon_ids = [i._action_id for i in tool.listActionIcons()] |
---|
63 | self.failIf('plonetabs' in icon_ids, 'There should be no plonetabs ' |
---|
64 | 'action icon after uninstall.') |
---|
65 | |
---|
66 | def test_controlPanel(self): |
---|
67 | tool = getToolByName(self.portal, 'portal_controlpanel') |
---|
68 | action_ids = [a.id for a in tool.listActions()] |
---|
69 | self.failIf('plonetabs' in action_ids, 'There should be no plonetabs ' |
---|
70 | 'configlet after after uninstall.') |
---|
71 | |
---|
72 | def test_cssRegistry(self): |
---|
73 | tool = getToolByName(self.portal, 'portal_css') |
---|
74 | css = tool.getResource('++resource++plonetabs.css') |
---|
75 | self.failUnless(css is None, |
---|
76 | 'There should be no ++resource++plonetabs.css ' |
---|
77 | 'stylesheets after uninstall.') |
---|
78 | |
---|
79 | def test_jsRegistry(self): |
---|
80 | tool = getToolByName(self.portal, 'portal_javascripts') |
---|
81 | |
---|
82 | effects = tool.getResource('++resource++pt_effects.js') |
---|
83 | self.failUnless(effects is None, |
---|
84 | 'There should be no ++resource++pt_effects.js script ' |
---|
85 | 'after uninstall.') |
---|
86 | |
---|
87 | dad = tool.getResource('++resource++sa_dragdrop.js') |
---|
88 | self.failUnless(dad is None, |
---|
89 | 'There should be no ++resource++sa_dragdrop.js script ' |
---|
90 | 'after uninstall.') |
---|
91 | |
---|
92 | def test_kssRegistry(self): |
---|
93 | tool = getToolByName(self.portal, 'portal_kss') |
---|
94 | kss = tool.getResource('++resource++plonetabs.kss') |
---|
95 | self.failUnless(kss is None, |
---|
96 | 'There should be no ++resource++plonetabs.kss sheets ' |
---|
97 | 'after uninstall.') |
---|
98 | kss = tool.getResource('++resource++plonetabsmode.kss') |
---|
99 | self.failUnless(kss is None, |
---|
100 | 'There should be no ++resource++plonetabsmode.kss ' |
---|
101 | 'sheets after uninstall.') |
---|
102 | |
---|
103 | def test_propertiesTool(self): |
---|
104 | tool = getToolByName(self.portal, 'portal_properties') |
---|
105 | self.failUnless(hasattr(tool, 'tabs_properties'), |
---|
106 | 'There is no tabs_properties sheet in portal ' |
---|
107 | 'properties tool after uninstall.') |
---|
108 | titles = tool.tabs_properties.getProperty('titles', None) |
---|
109 | self.assertEquals(titles, |
---|
110 | ('portal_tabs|Portal Tabs Configuration', |
---|
111 | 'portal_footer|Portal Footer Configuration'), |
---|
112 | 'titles plonetabs property was erased from ' |
---|
113 | 'portal_properties after uninstall.' |
---|
114 | ) |
---|
115 | |
---|
116 | def test_browserLayer(self): |
---|
117 | layers = [o.__name__ for o in registered_layers()] |
---|
118 | self.failIf('IPloneTabsProductLayer' in layers, |
---|
119 | 'There should be no quintagroup.plonetabs layer after' |
---|
120 | ' uninstall.') |
---|
121 | |
---|
122 | |
---|
123 | def test_suite(): |
---|
124 | suite = unittest.TestSuite() |
---|
125 | suite.addTest(unittest.makeSuite(TestErase)) |
---|
126 | return suite |
---|