| 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 | |
|---|
| 16 | class TestInstallation(TestCase): |
|---|
| 17 | |
|---|
| 18 | def testInstalled(self): |
|---|
| 19 | qi = self.portal.portal_quickinstaller |
|---|
| 20 | self.assertTrue(qi.isProductInstalled(PROJECT_NAME), |
|---|
| 21 | '%s is not installed.' % PROJECT_NAME) |
|---|
| 22 | |
|---|
| 23 | def testInstalledDependencies(self): |
|---|
| 24 | cp = self.portal.portal_controlpanel |
|---|
| 25 | configlets = [ai['id'] for ai in cp.listActionInfos(check_permissions=0)] |
|---|
| 26 | self.assertTrue([1 for ai in configlets if ai=="plone.app.registry"], |
|---|
| 27 | 'Not installed required plone.app.registry product.') |
|---|
| 28 | |
|---|
| 29 | def testStyles(self): |
|---|
| 30 | """ Test styles registration.""" |
|---|
| 31 | cssreg = getToolByName(self.portal, "portal_css") |
|---|
| 32 | for res in CSS_RESOURCES: |
|---|
| 33 | self.assertNotEqual(cssreg.getResource(res), None) |
|---|
| 34 | |
|---|
| 35 | def testConfiglet(self): |
|---|
| 36 | cp = self.portal.portal_controlpanel |
|---|
| 37 | configlets = [ai['id'] for ai in cp.listActionInfos(check_permissions=0)] |
|---|
| 38 | for cid in CONFIGLETS: |
|---|
| 39 | self.assertTrue([1 for ai in configlets if ai==cid], |
|---|
| 40 | 'No "%s" configlet added to plone control panel' % cid) |
|---|
| 41 | |
|---|
| 42 | def testBrowserLayer(self): |
|---|
| 43 | self.assert_(IDropDownMenuLayer in blutils.registered_layers(), |
|---|
| 44 | "Not registered 'IDropDownMenuLayer' browser layer") |
|---|
| 45 | |
|---|
| 46 | def testRegistry(self): |
|---|
| 47 | registry = queryUtility(IRegistry) |
|---|
| 48 | afield = "show_content_tabs" |
|---|
| 49 | self.assertTrue(registry.records.get(IPREFIX+afield, None), |
|---|
| 50 | "Not registered '%s' registry interface" % IPREFIX) |
|---|
| 51 | |
|---|
| 52 | |
|---|
| 53 | def test_suite(): |
|---|
| 54 | from unittest import TestSuite, makeSuite |
|---|
| 55 | suite = TestSuite() |
|---|
| 56 | suite.addTest(makeSuite(TestInstallation)) |
|---|
| 57 | return suite |
|---|