1 | # |
---|
2 | # Test product's installation |
---|
3 | # |
---|
4 | from zope.component import queryUtility |
---|
5 | from plone.registry.interfaces import IRegistry |
---|
6 | from plone.browserlayer import utils as blutils |
---|
7 | |
---|
8 | from Products.CMFCore.utils import getToolByName |
---|
9 | |
---|
10 | from quintagroup.dropdownmenu.tests.base import TestCase, TestCaseUnInstalled |
---|
11 | from quintagroup.dropdownmenu.tests.base import IPREFIX |
---|
12 | |
---|
13 | from quintagroup.dropdownmenu import PROJECT_NAME |
---|
14 | from quintagroup.dropdownmenu.interfaces import IDropDownMenuLayer |
---|
15 | |
---|
16 | CSS_RESOURCES = ["++resource++drop_down.css", ] |
---|
17 | DEPENDENCIES = ["plone.app.registry", ] |
---|
18 | CONFIGLETS = ["dropdownmenu", ] |
---|
19 | #REGISTRY_INTERFACE="quintagroup.dropdownmenu.interfaces.IDropDownMenuSettings" |
---|
20 | |
---|
21 | |
---|
22 | class 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([1 for ai in configlets if ai == cid], |
---|
48 | 'No "%s" configlet added to plone control panel' % cid) |
---|
49 | |
---|
50 | def testBrowserLayer(self): |
---|
51 | self.assert_(IDropDownMenuLayer in blutils.registered_layers(), |
---|
52 | "Not registered 'IDropDownMenuLayer' browser layer") |
---|
53 | |
---|
54 | def testRegistry(self): |
---|
55 | registry = queryUtility(IRegistry) |
---|
56 | afield = "show_content_tabs" |
---|
57 | self.assertTrue(registry.records.get(IPREFIX + afield, None), |
---|
58 | "Not registered '%s' registry interface" % IPREFIX) |
---|
59 | |
---|
60 | |
---|
61 | class TestUninstallation(TestCaseUnInstalled): |
---|
62 | |
---|
63 | def testUninstalled(self): |
---|
64 | qi = self.portal.portal_quickinstaller |
---|
65 | self.assertFalse(qi.isProductInstalled(PROJECT_NAME), |
---|
66 | '%s not uninstalled.' % PROJECT_NAME) |
---|
67 | |
---|
68 | def testStyles(self): |
---|
69 | """ Test styles registration.""" |
---|
70 | cssreg = getToolByName(self.portal, "portal_css") |
---|
71 | for res in CSS_RESOURCES: |
---|
72 | self.assertEqual(cssreg.getResource(res), None) |
---|
73 | |
---|
74 | def testConfiglet(self): |
---|
75 | cp = self.portal.portal_controlpanel |
---|
76 | configlets = [ai['id'] for ai in cp.listActionInfos( |
---|
77 | check_permissions=0)] |
---|
78 | for cid in CONFIGLETS: |
---|
79 | self.assertFalse([1 for ai in configlets if ai == cid], |
---|
80 | '"%s" configlet not uninstalled '\ |
---|
81 | 'from plone control panel' % cid) |
---|
82 | |
---|
83 | def testBrowserLayer(self): |
---|
84 | self.assertFalse(IDropDownMenuLayer in blutils.registered_layers(), |
---|
85 | "Not unregistered 'IDropDownMenuLayer' browser layer") |
---|
86 | |
---|
87 | def testRegistry(self): |
---|
88 | registry = queryUtility(IRegistry) |
---|
89 | afield = "show_content_tabs" |
---|
90 | self.assertFalse(registry.records.get(IPREFIX + afield, None), |
---|
91 | "Not unregistered '%s' registry interface" % IPREFIX) |
---|
92 | |
---|
93 | |
---|
94 | def test_suite(): |
---|
95 | from unittest import TestSuite, makeSuite |
---|
96 | suite = TestSuite() |
---|
97 | suite.addTest(makeSuite(TestInstallation)) |
---|
98 | suite.addTest(makeSuite(TestUninstallation)) |
---|
99 | return suite |
---|