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