1 | # |
---|
2 | # Test product's installation/uninstallation |
---|
3 | # |
---|
4 | |
---|
5 | from Products.PloneTestCase import PloneTestCase |
---|
6 | from Products.CMFCore.utils import getToolByName |
---|
7 | |
---|
8 | PRODUCT = 'qPloneComments' |
---|
9 | |
---|
10 | PRODUCT_SKIN_NAME = "qplonecomments" |
---|
11 | PROPERTY_SHEET = "qPloneComments" |
---|
12 | CONFIGLET_ID = "prefs_comments_setup_form" |
---|
13 | |
---|
14 | EMAIL_PID = "email_discussion_manager" |
---|
15 | APPROVE_NOTIFICATION_PID = "enable_approve_notification" |
---|
16 | PUBLISHED_NOTIFICATION_PID = "enable_published_notification" |
---|
17 | MODERATION_PID = "enable_moderation" |
---|
18 | ANONYMOUS_COMMENTING_PID = "enable_anonymous_commenting" |
---|
19 | |
---|
20 | PERM_NAME = 'Moderate Discussion' |
---|
21 | PloneTestCase.installProduct(PRODUCT) |
---|
22 | PloneTestCase.setupPloneSite() |
---|
23 | |
---|
24 | |
---|
25 | class TestInstallation(PloneTestCase.PloneTestCase): |
---|
26 | |
---|
27 | def afterSetUp(self): |
---|
28 | self.loginAsPortalOwner() |
---|
29 | self.qi = self.portal.portal_quickinstaller |
---|
30 | self.qi.installProduct(PRODUCT) |
---|
31 | |
---|
32 | def test_configlet_install(self): |
---|
33 | configTool = getToolByName(self.portal, 'portal_controlpanel', None) |
---|
34 | self.assert_(CONFIGLET_ID in [a.getId() for a in configTool.listActions()], 'Configlet not found') |
---|
35 | |
---|
36 | def test_skins_install(self): |
---|
37 | skinstool=getToolByName(self.portal, 'portal_skins') |
---|
38 | for skin in skinstool.getSkinSelections(): |
---|
39 | path = skinstool.getSkinPath(skin) |
---|
40 | path = map(str.strip, path.split(',')) |
---|
41 | self.assert_(PRODUCT_SKIN_NAME in path, 'qPloneComments layer not found in %s' % skin) |
---|
42 | |
---|
43 | def test_layer_install(self): |
---|
44 | from plone.browserlayer.utils import registered_layers |
---|
45 | from Products.qPloneComments.interfaces import IPloneCommentsLayer |
---|
46 | self.failUnless(IPloneCommentsLayer in registered_layers()) |
---|
47 | |
---|
48 | def test_propertysheet_install(self): |
---|
49 | portal_properties = getToolByName(self.portal, 'portal_properties', None) |
---|
50 | |
---|
51 | self.assert_(PROPERTY_SHEET in portal_properties.objectIds(), 'qPloneComments properies not found in portal_properties') |
---|
52 | |
---|
53 | property_ids = portal_properties[PROPERTY_SHEET].propertyIds() |
---|
54 | self.assert_(EMAIL_PID in property_ids, '%s propery not found in %s property' % (EMAIL_PID, PROPERTY_SHEET)) |
---|
55 | self.assert_(APPROVE_NOTIFICATION_PID in property_ids, '%s propery not found in %s property' % (APPROVE_NOTIFICATION_PID, PROPERTY_SHEET)) |
---|
56 | self.assert_(PUBLISHED_NOTIFICATION_PID in property_ids, '%s propery not found in %s property' % (PUBLISHED_NOTIFICATION_PID, PROPERTY_SHEET)) |
---|
57 | self.assert_(MODERATION_PID in property_ids, '%s propery not found in %s property' % (MODERATION_PID, PROPERTY_SHEET)) |
---|
58 | self.assert_(ANONYMOUS_COMMENTING_PID in property_ids, '%s propery not found in %s property' % (ANONYMOUS_COMMENTING_PID, PROPERTY_SHEET)) |
---|
59 | |
---|
60 | def test_skins_uninstall(self): |
---|
61 | self.qi.uninstallProducts([PRODUCT]) |
---|
62 | self.assertNotEqual(self.qi.isProductInstalled(PRODUCT), True,'qPloneComments is already installed') |
---|
63 | skinstool=getToolByName(self.portal, 'portal_skins') |
---|
64 | |
---|
65 | self.assert_(not PRODUCT_SKIN_NAME in skinstool.objectIds(), '%s directory view found in portal_skins after uninstallation' % PRODUCT_SKIN_NAME) |
---|
66 | for skin in skinstool.getSkinSelections(): |
---|
67 | path = skinstool.getSkinPath(skin) |
---|
68 | path = map(str.strip, path.split(',')) |
---|
69 | self.assert_(not PRODUCT_SKIN_NAME in path, '%s layer found in %s after uninstallation' % (PRODUCT_SKIN_NAME, skin)) |
---|
70 | |
---|
71 | def test_layer_uninstall(self): |
---|
72 | self.qi.uninstallProducts([PRODUCT]) |
---|
73 | self.assertNotEqual(self.qi.isProductInstalled(PRODUCT), True,'qPloneComments is already installed') |
---|
74 | |
---|
75 | from plone.browserlayer.utils import registered_layers |
---|
76 | from Products.qPloneComments.interfaces import IPloneCommentsLayer |
---|
77 | self.failIf(IPloneCommentsLayer in registered_layers()) |
---|
78 | |
---|
79 | def test_configlet_uninstall(self): |
---|
80 | self.qi.uninstallProducts([PRODUCT]) |
---|
81 | self.assertNotEqual(self.qi.isProductInstalled(PRODUCT), True,'qPloneComments is already installed') |
---|
82 | |
---|
83 | configTool = getToolByName(self.portal, 'portal_controlpanel', None) |
---|
84 | self.assert_(not CONFIGLET_ID in [a.getId() for a in configTool.listActions()], 'Configlet found after uninstallation') |
---|
85 | |
---|
86 | def test_propertysheet_uninstall(self): |
---|
87 | self.qi.uninstallProducts([PRODUCT]) |
---|
88 | self.assertNotEqual(self.qi.isProductInstalled(PRODUCT), True,'qPloneComments is already installed') |
---|
89 | |
---|
90 | portal_properties = getToolByName(self.portal, 'portal_properties') |
---|
91 | self.assert_(PROPERTY_SHEET in portal_properties.objectIds(), \ |
---|
92 | 'qPloneComments property_sheet not found in portal_properties after uninstallation') |
---|
93 | |
---|
94 | def test_permission_added(self): |
---|
95 | roles = [item['name'] for item in self.portal.rolesOfPermission(PERM_NAME)] |
---|
96 | self.assert_( roles != [], '%s not installed'%PERM_NAME) |
---|
97 | |
---|
98 | |
---|
99 | def test_suite(): |
---|
100 | from unittest import TestSuite, makeSuite |
---|
101 | suite = TestSuite() |
---|
102 | suite.addTest(makeSuite(TestInstallation)) |
---|
103 | return suite |
---|