source: products/quintagroup.dropdownmenu/trunk/quintagroup/dropdownmenu/tests/test_installation.py @ 2875

Last change on this file since 2875 was 2874, checked in by mylan, 14 years ago

#232: Added uninstallation tests

  • Property svn:eol-style set to native
File size: 3.4 KB
Line 
1#
2# Test product's installation
3#
4import string
5from zope.component import queryUtility
6from zope.component import queryMultiAdapter
7from zope.viewlet.interfaces import IViewletManager
8from plone.registry.interfaces import IRegistry
9from plone.browserlayer import utils as blutils
10
11from base import *
12CSS_RESOURCES = ["++resource++drop_down.css",]
13DEPENDENCIES = ["plone.app.registry",]
14CONFIGLETS = ["dropdownmenu",]
15#REGISTRY_INTERFACE = "quintagroup.dropdownmenu.interfaces.IDropDownMenuSettings"
16
17class TestInstallation(TestCase):
18
19    def testInstalled(self):
20        qi = self.portal.portal_quickinstaller
21        self.assertTrue(qi.isProductInstalled(PROJECT_NAME),
22            '%s is not installed.' % PROJECT_NAME)
23
24    def testInstalledDependencies(self):
25        cp = self.portal.portal_controlpanel
26        configlets = [ai['id'] for ai in cp.listActionInfos(check_permissions=0)]
27        self.assertTrue([1 for ai in configlets if ai=="plone.app.registry"], 
28                'Not installed required plone.app.registry product.')
29
30    def testStyles(self):
31        """ Test styles registration."""
32        cssreg = getToolByName(self.portal, "portal_css")
33        for res in CSS_RESOURCES:
34            self.assertNotEqual(cssreg.getResource(res), None)
35
36    def testConfiglet(self):
37        cp = self.portal.portal_controlpanel
38        configlets = [ai['id'] for ai in cp.listActionInfos(check_permissions=0)]
39        for cid in CONFIGLETS:
40            self.assertTrue([1 for ai in configlets if ai==cid], 
41                'No "%s" configlet added to plone control panel' % cid)
42
43    def testBrowserLayer(self):
44        self.assert_(IDropDownMenuLayer in blutils.registered_layers(),
45                     "Not registered 'IDropDownMenuLayer' browser layer")
46
47    def testRegistry(self):
48        registry = queryUtility(IRegistry)
49        afield = "show_content_tabs"
50        self.assertTrue(registry.records.get(IPREFIX+afield, None),
51            "Not registered '%s' registry interface" % IPREFIX)
52
53class TestUninstallation(TestCaseUnInstalled):
54
55    def testUninstalled(self):
56        qi = self.portal.portal_quickinstaller
57        self.assertFalse(qi.isProductInstalled(PROJECT_NAME),
58            '%s not uninstalled.' % PROJECT_NAME)
59
60    def testStyles(self):
61        """ Test styles registration."""
62        cssreg = getToolByName(self.portal, "portal_css")
63        for res in CSS_RESOURCES:
64            self.assertEqual(cssreg.getResource(res), None)
65
66    def testConfiglet(self):
67        cp = self.portal.portal_controlpanel
68        configlets = [ai['id'] for ai in cp.listActionInfos(check_permissions=0)]
69        for cid in CONFIGLETS:
70            self.assertFalse([1 for ai in configlets if ai==cid], 
71                '"%s" configlet not uninstalled from plone control panel' % cid)
72
73    def testBrowserLayer(self):
74        self.assertFalse(IDropDownMenuLayer in blutils.registered_layers(),
75                     "Not unregistered 'IDropDownMenuLayer' browser layer")
76
77    def testRegistry(self):
78        registry = queryUtility(IRegistry)
79        afield = "show_content_tabs"
80        self.assertFalse(registry.records.get(IPREFIX+afield, None),
81            "Not unregistered '%s' registry interface" % IPREFIX)
82
83
84def test_suite():
85    from unittest import TestSuite, makeSuite
86    suite = TestSuite()
87    suite.addTest(makeSuite(TestInstallation))
88    suite.addTest(makeSuite(TestUninstallation))
89    return suite
Note: See TracBrowser for help on using the repository browser.