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

Last change on this file since 3514 was 3514, checked in by kroman0, 12 years ago

Pep8 fixes

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