1 | # |
---|
2 | # Test product's installation |
---|
3 | # |
---|
4 | import string |
---|
5 | from zope.component import queryUtility |
---|
6 | from zope.component import queryMultiAdapter |
---|
7 | from zope.viewlet.interfaces import IViewletManager |
---|
8 | from plone.registry.interfaces import IRegistry |
---|
9 | from plone.browserlayer import utils as blutils |
---|
10 | |
---|
11 | from base import * |
---|
12 | CSS_RESOURCES = ["++resource++drop_down.css",] |
---|
13 | DEPENDENCIES = ["plone.app.registry",] |
---|
14 | CONFIGLETS = ["dropdownmenu",] |
---|
15 | #REGISTRY_INTERFACE = "quintagroup.dropdownmenu.interfaces.IDropDownMenuSettings" |
---|
16 | |
---|
17 | class 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 | |
---|
53 | class 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 | |
---|
84 | def test_suite(): |
---|
85 | from unittest import TestSuite, makeSuite |
---|
86 | suite = TestSuite() |
---|
87 | suite.addTest(makeSuite(TestInstallation)) |
---|
88 | suite.addTest(makeSuite(TestUninstallation)) |
---|
89 | return suite |
---|