[832] | 1 | # |
---|
[880] | 2 | # Test product's installation |
---|
[832] | 3 | # |
---|
| 4 | |
---|
[3112] | 5 | from Products.CMFCore.utils import getToolByName |
---|
| 6 | from quintagroup.plonecomments.tests.base import TestCase |
---|
| 7 | from quintagroup.plonecomments.tests.config import PRODUCT, CONFIGLET_ID, \ |
---|
| 8 | PRODUCT_SKIN_NAME, PROPERTY_SHEET, EMAIL_PID, EMAIL_SUBJECT_PID, \ |
---|
| 9 | REQUIRE_EMAIL_PID, PERM_NAME, APPROVE_NOTIFICATION_PID, \ |
---|
| 10 | PUBLISHED_NOTIFICATION_PID, APPROVE_USER_NOTIFICATION_PID, \ |
---|
| 11 | REPLY_USER_NOTIFICATION_PID, MODERATION_PID, REJECTED_NOTIFICATION_PID, \ |
---|
| 12 | 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) |
---|
[880] | 27 | self.failUnless(CONFIGLET_ID in [a.getId() for a in configTool.listActions()], |
---|
| 28 | 'Configlet %s is not registered.' % CONFIGLET_ID) |
---|
[832] | 29 | |
---|
| 30 | def test_skins_install(self): |
---|
| 31 | skinstool=getToolByName(self.portal, 'portal_skins') |
---|
[880] | 32 | self.failUnless(PRODUCT_SKIN_NAME in skinstool.objectIds(), |
---|
| 33 | 'There is no %s folder in portal_skins.' % PRODUCT_SKIN_NAME) |
---|
[832] | 34 | for skin in skinstool.getSkinSelections(): |
---|
[880] | 35 | path = skinstool.getSkinPath(skin) |
---|
| 36 | layers = map(str.strip, path.split(',')) |
---|
| 37 | self.failUnless(PRODUCT_SKIN_NAME in layers, |
---|
| 38 | '%s layer is not registered for %s.' % (PRODUCT_SKIN_NAME, skin)) |
---|
[832] | 39 | |
---|
| 40 | def test_layer_install(self): |
---|
| 41 | from plone.browserlayer.utils import registered_layers |
---|
| 42 | from quintagroup.plonecomments.interfaces import IPloneCommentsLayer |
---|
[880] | 43 | self.failUnless(IPloneCommentsLayer in registered_layers(), |
---|
| 44 | '%s layer is not registered.' % IPloneCommentsLayer.getName()) |
---|
[832] | 45 | |
---|
| 46 | def test_propertysheet_install(self): |
---|
| 47 | portal_properties = getToolByName(self.portal, 'portal_properties', None) |
---|
[880] | 48 | self.failUnless(PROPERTY_SHEET in portal_properties.objectIds(), |
---|
| 49 | '%s properies not found in portal_properties.' % PROPERTY_SHEET) |
---|
[832] | 50 | property_ids = portal_properties[PROPERTY_SHEET].propertyIds() |
---|
[880] | 51 | self.failUnless(EMAIL_PID in property_ids, |
---|
| 52 | '%s propery not found in %s property.' % (EMAIL_PID, PROPERTY_SHEET)) |
---|
| 53 | self.failUnless(EMAIL_SUBJECT_PID in property_ids, |
---|
| 54 | '%s propery not found in %s property.' % (EMAIL_SUBJECT_PID, PROPERTY_SHEET)) |
---|
| 55 | self.failUnless(REQUIRE_EMAIL_PID in property_ids, |
---|
| 56 | '%s propery not found in %s property.' % (REQUIRE_EMAIL_PID, PROPERTY_SHEET)) |
---|
| 57 | self.failUnless(APPROVE_NOTIFICATION_PID in property_ids, |
---|
| 58 | '%s propery not found in %s property.' % (APPROVE_NOTIFICATION_PID, PROPERTY_SHEET)) |
---|
| 59 | self.failUnless(PUBLISHED_NOTIFICATION_PID in property_ids, |
---|
| 60 | '%s propery not found in %s property.' % (PUBLISHED_NOTIFICATION_PID, PROPERTY_SHEET)) |
---|
| 61 | self.failUnless(REJECTED_NOTIFICATION_PID in property_ids, |
---|
| 62 | '%s propery not found in %s property.' % (REJECTED_NOTIFICATION_PID, PROPERTY_SHEET)) |
---|
| 63 | self.failUnless(APPROVE_USER_NOTIFICATION_PID in property_ids, |
---|
| 64 | '%s propery not found in %s property.' % (APPROVE_USER_NOTIFICATION_PID, PROPERTY_SHEET)) |
---|
| 65 | self.failUnless(REPLY_USER_NOTIFICATION_PID in property_ids, |
---|
| 66 | '%s propery not found in %s property.' % (REPLY_USER_NOTIFICATION_PID, PROPERTY_SHEET)) |
---|
| 67 | self.failUnless(MODERATION_PID in property_ids, |
---|
| 68 | '%s propery not found in %s property.' % (MODERATION_PID, PROPERTY_SHEET)) |
---|
| 69 | self.failUnless(ANONYMOUS_COMMENTING_PID in property_ids, |
---|
| 70 | '%s propery not found in %s property.' % (ANONYMOUS_COMMENTING_PID, PROPERTY_SHEET)) |
---|
[832] | 71 | |
---|
| 72 | def test_permission_added(self): |
---|
| 73 | roles = [item['name'] for item in self.portal.rolesOfPermission(PERM_NAME)] |
---|
[880] | 74 | self.failIf( roles == [], '%s not installed.' % PERM_NAME) |
---|
[832] | 75 | |
---|
| 76 | |
---|
| 77 | def test_suite(): |
---|
| 78 | from unittest import TestSuite, makeSuite |
---|
| 79 | suite = TestSuite() |
---|
| 80 | suite.addTest(makeSuite(TestInstallation)) |
---|
| 81 | return suite |
---|