[832] | 1 | # |
---|
[880] | 2 | # Test product's installation |
---|
[832] | 3 | # |
---|
| 4 | |
---|
[3107] | 5 | from Products.CMFCore.utils import getToolByName |
---|
| 6 | from base import TestCase |
---|
| 7 | from config import PRODUCT, CONFIGLET_ID, PRODUCT_SKIN_NAME, PROPERTY_SHEET |
---|
| 8 | from config import EMAIL_PID, EMAIL_SUBJECT_PID, REQUIRE_EMAIL_PID, PERM_NAME |
---|
| 9 | from config import APPROVE_NOTIFICATION_PID, PUBLISHED_NOTIFICATION_PID |
---|
| 10 | from config import APPROVE_USER_NOTIFICATION_PID, REPLY_USER_NOTIFICATION_PID |
---|
| 11 | from config import MODERATION_PID, REJECTED_NOTIFICATION_PID |
---|
| 12 | from config import ANONYMOUS_COMMENTING_PID |
---|
[832] | 13 | |
---|
[880] | 14 | |
---|
[832] | 15 | class TestInstallation(TestCase): |
---|
| 16 | |
---|
| 17 | def afterSetUp(self): |
---|
| 18 | self.loginAsPortalOwner() |
---|
| 19 | self.qi = self.portal.portal_quickinstaller |
---|
| 20 | |
---|
[880] | 21 | def test_package_install(self): |
---|
| 22 | self.failUnless(self.qi.isProductInstalled(PRODUCT), |
---|
| 23 | '%s is not installed.' % PRODUCT) |
---|
| 24 | |
---|
[832] | 25 | def test_configlet_install(self): |
---|
| 26 | configTool = getToolByName(self.portal, 'portal_controlpanel', None) |
---|
[2137] | 27 | self.failUnless(CONFIGLET_ID in [a.getId() |
---|
| 28 | for a in configTool.listActions()], |
---|
[880] | 29 | 'Configlet %s is not registered.' % CONFIGLET_ID) |
---|
[832] | 30 | |
---|
| 31 | def test_skins_install(self): |
---|
[2137] | 32 | skinstool = getToolByName(self.portal, 'portal_skins') |
---|
[880] | 33 | self.failUnless(PRODUCT_SKIN_NAME in skinstool.objectIds(), |
---|
| 34 | 'There is no %s folder in portal_skins.' % PRODUCT_SKIN_NAME) |
---|
[832] | 35 | for skin in skinstool.getSkinSelections(): |
---|
[2137] | 36 | path = skinstool.getSkinPath(skin) |
---|
[880] | 37 | layers = map(str.strip, path.split(',')) |
---|
| 38 | self.failUnless(PRODUCT_SKIN_NAME in layers, |
---|
[2137] | 39 | '%s layer is not registered for %s.' % (PRODUCT_SKIN_NAME, skin)) |
---|
[832] | 40 | |
---|
| 41 | def test_layer_install(self): |
---|
| 42 | from plone.browserlayer.utils import registered_layers |
---|
| 43 | from quintagroup.plonecomments.interfaces import IPloneCommentsLayer |
---|
[880] | 44 | self.failUnless(IPloneCommentsLayer in registered_layers(), |
---|
| 45 | '%s layer is not registered.' % IPloneCommentsLayer.getName()) |
---|
[832] | 46 | |
---|
| 47 | def test_propertysheet_install(self): |
---|
[2137] | 48 | portal_properties = getToolByName(self.portal, 'portal_properties', |
---|
| 49 | None) |
---|
[880] | 50 | self.failUnless(PROPERTY_SHEET in portal_properties.objectIds(), |
---|
| 51 | '%s properies not found in portal_properties.' % PROPERTY_SHEET) |
---|
[832] | 52 | property_ids = portal_properties[PROPERTY_SHEET].propertyIds() |
---|
[880] | 53 | self.failUnless(EMAIL_PID in property_ids, |
---|
[2137] | 54 | '%s propery not found in %s property.' % |
---|
| 55 | (EMAIL_PID, PROPERTY_SHEET)) |
---|
[880] | 56 | self.failUnless(EMAIL_SUBJECT_PID in property_ids, |
---|
[2137] | 57 | '%s propery not found in %s property.' % |
---|
| 58 | (EMAIL_SUBJECT_PID, PROPERTY_SHEET)) |
---|
[880] | 59 | self.failUnless(REQUIRE_EMAIL_PID in property_ids, |
---|
[2137] | 60 | '%s propery not found in %s property.' % |
---|
| 61 | (REQUIRE_EMAIL_PID, PROPERTY_SHEET)) |
---|
[880] | 62 | self.failUnless(APPROVE_NOTIFICATION_PID in property_ids, |
---|
[2137] | 63 | '%s propery not found in %s property.' % |
---|
| 64 | (APPROVE_NOTIFICATION_PID, PROPERTY_SHEET)) |
---|
[880] | 65 | self.failUnless(PUBLISHED_NOTIFICATION_PID in property_ids, |
---|
[2137] | 66 | '%s propery not found in %s property.' % |
---|
| 67 | (PUBLISHED_NOTIFICATION_PID, PROPERTY_SHEET)) |
---|
[880] | 68 | self.failUnless(REJECTED_NOTIFICATION_PID in property_ids, |
---|
[2137] | 69 | '%s propery not found in %s property.' % |
---|
| 70 | (REJECTED_NOTIFICATION_PID, PROPERTY_SHEET)) |
---|
[880] | 71 | self.failUnless(APPROVE_USER_NOTIFICATION_PID in property_ids, |
---|
[2137] | 72 | '%s propery not found in %s property.' % |
---|
| 73 | (APPROVE_USER_NOTIFICATION_PID, PROPERTY_SHEET)) |
---|
[880] | 74 | self.failUnless(REPLY_USER_NOTIFICATION_PID in property_ids, |
---|
[2137] | 75 | '%s propery not found in %s property.' % |
---|
| 76 | (REPLY_USER_NOTIFICATION_PID, PROPERTY_SHEET)) |
---|
[880] | 77 | self.failUnless(MODERATION_PID in property_ids, |
---|
[2137] | 78 | '%s propery not found in %s property.' % |
---|
| 79 | (MODERATION_PID, PROPERTY_SHEET)) |
---|
[880] | 80 | self.failUnless(ANONYMOUS_COMMENTING_PID in property_ids, |
---|
[2137] | 81 | '%s propery not found in %s property.' % |
---|
| 82 | (ANONYMOUS_COMMENTING_PID, PROPERTY_SHEET)) |
---|
[832] | 83 | |
---|
| 84 | def test_permission_added(self): |
---|
[2137] | 85 | roles = [item['name'] |
---|
| 86 | for item in self.portal.rolesOfPermission(PERM_NAME)] |
---|
| 87 | self.failIf(roles == [], '%s not installed.' % PERM_NAME) |
---|
[832] | 88 | |
---|
| 89 | |
---|
| 90 | def test_suite(): |
---|
| 91 | from unittest import TestSuite, makeSuite |
---|
| 92 | suite = TestSuite() |
---|
| 93 | suite.addTest(makeSuite(TestInstallation)) |
---|
| 94 | return suite |
---|