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