source: products/quintagroup.plonecomments/trunk/quintagroup/plonecomments/tests/testQPloneCommentsInstall.py @ 3112

Last change on this file since 3112 was 3112, checked in by kroman0, 13 years ago

Merged fixes for pyflakes and pylint

File size: 4.1 KB
Line 
1#
2# Test product's installation
3#
4
5from Products.CMFCore.utils import getToolByName
6from quintagroup.plonecomments.tests.base import TestCase
7from 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
13
14
15class TestInstallation(TestCase):
16
17    def afterSetUp(self):
18        self.loginAsPortalOwner()
19        self.qi = self.portal.portal_quickinstaller
20
21    def test_package_install(self):
22        self.failUnless(self.qi.isProductInstalled(PRODUCT),
23            '%s is not installed.' % PRODUCT)
24
25    def test_configlet_install(self):
26        configTool = getToolByName(self.portal, 'portal_controlpanel', None)
27        self.failUnless(CONFIGLET_ID in [a.getId() for a in configTool.listActions()],
28            'Configlet %s is not registered.' % CONFIGLET_ID)
29
30    def test_skins_install(self):
31        skinstool=getToolByName(self.portal, 'portal_skins')
32        self.failUnless(PRODUCT_SKIN_NAME in skinstool.objectIds(),
33                'There is no %s folder in portal_skins.' % PRODUCT_SKIN_NAME)
34        for skin in skinstool.getSkinSelections():
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))
39
40    def test_layer_install(self):
41        from plone.browserlayer.utils import registered_layers
42        from quintagroup.plonecomments.interfaces import IPloneCommentsLayer
43        self.failUnless(IPloneCommentsLayer in registered_layers(),
44            '%s layer is not registered.' % IPloneCommentsLayer.getName())
45
46    def test_propertysheet_install(self):
47        portal_properties = getToolByName(self.portal, 'portal_properties', None)
48        self.failUnless(PROPERTY_SHEET in portal_properties.objectIds(),
49            '%s properies not found in portal_properties.' % PROPERTY_SHEET)
50        property_ids = portal_properties[PROPERTY_SHEET].propertyIds()
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))
71
72    def test_permission_added(self):
73        roles = [item['name'] for item in self.portal.rolesOfPermission(PERM_NAME)]
74        self.failIf( roles == [], '%s not installed.' % PERM_NAME)
75
76
77def test_suite():
78    from unittest import TestSuite, makeSuite
79    suite = TestSuite()
80    suite.addTest(makeSuite(TestInstallation))
81    return suite
Note: See TracBrowser for help on using the repository browser.