source: products/quintagroup.plonetabs/branches/tests/quintagroup/plonetabs/tests/test_erase.py @ 3402

Last change on this file since 3402 was 3402, checked in by potar, 8 years ago

Fixing pep8

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