Changeset 3126 in products
- Timestamp:
- Apr 18, 2011 10:06:14 AM (13 years ago)
- Location:
- quintagroup.plonecomments/trunk/quintagroup/plonecomments
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
quintagroup.plonecomments/trunk/quintagroup/plonecomments/browser/comments.py
r3120 r3126 16 16 from plone.app.layout.viewlets import comments 17 17 from plone.app.kss.plonekssview import PloneKSSView 18 18 19 19 20 class CommentsViewlet(comments.CommentsViewlet): -
quintagroup.plonecomments/trunk/quintagroup/plonecomments/tests/testQPloneCommentsCommenting.py
r3120 r3126 37 37 # Make sure Documents are visible by default 38 38 # XXX only do this for plone 3 39 self.portal.portal_workflow.setChainForPortalTypes(('Document',), 'plone_workflow') 39 self.portal.portal_workflow.setChainForPortalTypes(('Document',), 40 'plone_workflow') 40 41 41 42 # Add testing documents to portal. Add one document for avery user. 42 # For testing behaviors, where made some changes to document state it's more usefull. 43 self.discussion = getToolByName(self.portal, 'portal_discussion', None) 43 # For testing behaviors, where made some changes to document state 44 # it's more usefull. 45 self.discussion = getToolByName(self.portal, 'portal_discussion', 46 None) 44 47 self.all_users_id = DM_USERS_IDS + COMMON_USERS_IDS 45 48 for user_id in self.all_users_id: … … 47 50 self.portal.invokeFactory('Document', id=doc_id) 48 51 doc_obj = getattr(self.portal, doc_id) 49 doc_obj.edit(text_format='plain', text='hello world from %s' % doc_id) 52 doc_obj.edit(text_format='plain', 53 text='hello world from %s' % doc_id) 50 54 # Create talkback for document and Add comment to doc_obj 51 55 self.discussion.getDiscussionFor(doc_obj) 52 doc_obj.discussion_reply('A Reply for %s' % doc_id,'text of reply for %s' % doc_id) 56 doc_obj.discussion_reply('A Reply for %s' % doc_id, 57 'text of reply for %s' % doc_id) 53 58 54 59 … … 63 68 self.login('dm_admin') 64 69 doc_obj = getattr(self.portal, "doc_anonym") 65 replies_before = len(self.discussion.getDiscussionFor(doc_obj).getReplies()) 70 discussion_for = self.discussion.getDiscussionFor(doc_obj) 71 replies_before = len(discussion_for.getReplies()) 66 72 67 73 # Create talkback for document and Add comment … … 69 75 doc_obj.discussion_reply("Anonym reply", "text of 'anonym' reply") 70 76 self.login('dm_admin') 71 replies_after = len( self.discussion.getDiscussionFor(doc_obj).getReplies())77 replies_after = len(discussion_for.getReplies()) 72 78 self.failUnless(replies_after - replies_before, 73 "Anonymous user CAN'T really add comment in terned ON *Anonymous commenting mode*.") 79 "Anonymous user CAN'T really add comment in terned ON " 80 "*Anonymous commenting mode*.") 74 81 75 82 def testAddCommentToDocNotAnonymUsers(self): … … 82 89 doc_id = "doc_%s" % u 83 90 doc_obj = getattr(self.portal, doc_id) 84 replies_before = self.discussion.getDiscussionFor(doc_obj).getReplies() 91 discussion_for = self.discussion.getDiscussionFor(doc_obj) 92 replies_before = discussion_for.getReplies() 85 93 self.login(u) 86 94 87 95 # Create talkback for document and Add comment 88 doc_obj.discussion_reply("%s's reply" % u, "text of '%s' reply" % u) 96 doc_obj.discussion_reply("%s's reply" % u, 97 "text of '%s' reply" % u) 89 98 90 99 # Check is comment added 91 100 self.login('dm_admin') 92 replies_after = self.discussion.getDiscussionFor(doc_obj).getReplies()101 replies_after = discussion_for.getReplies() 93 102 disparity = len(replies_after) - len(replies_before) 94 103 if not disparity: 95 104 failed_users.append(u) 96 self.failIf(failed_users, "%s - user(s) can not really add comment." % failed_users) 105 self.failIf(failed_users, 106 "%s - user(s) can not really add comment." % failed_users) 97 107 98 108 … … 102 112 all_users_id = DM_USERS_IDS + COMMON_USERS_IDS 103 113 self.not_like_anonym = ['admin', 'member', 'dm_admin', 'dm_member'] 104 self.like_anonym = [u for u in all_users_id if u not in self.not_like_anonym] 114 self.like_anonym = [u 115 for u in all_users_id 116 if u not in self.not_like_anonym] 105 117 106 118 def testAddCommentToDocLikeAnonymUsers(self): … … 111 123 self.login('dm_admin') 112 124 doc_obj = getattr(self.portal, "doc_%s" % u) 113 replies_before = self.discussion.getDiscussionFor(doc_obj).getReplies() 125 discussion_for = self.discussion.getDiscussionFor(doc_obj) 126 replies_before = discussion_for.getReplies() 114 127 115 128 # Create talkback for document and Add comment 116 129 self.logout() 117 if not u =='anonym':130 if not u == 'anonym': 118 131 self.login(u) 119 132 self.assertRaises(Unauthorized, doc_obj.discussion_reply, 120 133 "%s's reply" % u, "text of '%s' reply" % u) 121 134 self.login('dm_admin') 122 replies_after = self.discussion.getDiscussionFor(doc_obj).getReplies()135 replies_after = discussion_for.getReplies() 123 136 disparity = len(replies_after) - len(replies_before) 124 137 if disparity: … … 136 149 doc_id = "doc_%s" % u 137 150 doc_obj = getattr(self.portal, doc_id) 138 replies_before = self.discussion.getDiscussionFor(doc_obj).getReplies() 151 discussion_for = self.discussion.getDiscussionFor(doc_obj) 152 replies_before = discussion_for.getReplies() 139 153 self.login(u) 140 154 141 155 # Create talkback for document and Add comment 142 doc_obj.discussion_reply("%s's reply" % u, "text of '%s' reply" % u) 156 doc_obj.discussion_reply("%s's reply" % u, 157 "text of '%s' reply" % u) 143 158 144 159 # Check is comment added 145 160 self.login('dm_admin') 146 replies_after = self.discussion.getDiscussionFor(doc_obj).getReplies()161 replies_after = discussion_for.getReplies() 147 162 disparity = len(replies_after) - len(replies_before) 148 163 if not disparity: … … 171 186 self.allowable_dm_users = ['dm_admin', 'dm_member'] 172 187 self.allowable_common_users = ['admin', 'member'] 173 self.illegal_dm_users = [u for u in DM_USERS_IDS if not u in self.allowable_dm_users] 174 self.illegal_common_users = [u for u in COMMON_USERS_IDS if not u in self.allowable_common_users] 188 self.illegal_dm_users = [u 189 for u in DM_USERS_IDS 190 if not u in self.allowable_dm_users] 191 self.illegal_common_users = [u 192 for u in COMMON_USERS_IDS 193 if not u in self.allowable_common_users] 175 194 176 195 def testAddCommentToNotPublishedReplyDMUsers(self): 177 196 178 # DiscussionManager's group's members with Manager or Member roles CAN ADD COMMENTS179 # to reply IN ANY STATE (published/not published)197 # DiscussionManager's group's members with Manager or Member roles 198 # CAN ADD COMMENTS to reply IN ANY STATE (published/not published) 180 199 failed_users = [] 181 200 for u in self.allowable_dm_users: … … 187 206 self.discussion.getDiscussionFor(reply) 188 207 reply.discussion_reply("%s's reply" % u, "text of '%s' reply" % u) 189 replies_to_reply = self.discussion.getDiscussionFor(reply).getReplies() 208 discussion_for = self.discussion.getDiscussionFor(reply) 209 replies_to_reply = discussion_for.getReplies() 190 210 if not replies_to_reply: 191 211 failed_users.append(u) 192 self.failIf(failed_users, 193 "%s - member(s) of DiscussionManager groupCAN'T really ADD comment" % failed_users)212 self.failIf(failed_users, "%s - member(s) of DiscussionManager group " 213 "CAN'T really ADD comment" % failed_users) 194 214 195 215 # This is actual only in terned OFF *Anonymous commenting mode* … … 202 222 # Create talkback for reply and Add comment 203 223 self.discussion.getDiscussionFor(reply) 204 self.assertRaises(Unauthorized, reply.discussion_reply, "%s's reply" % u, "text of '%s' reply" % u) 205 replies_to_reply = self.discussion.getDiscussionFor(reply).getReplies() 224 self.assertRaises(Unauthorized, reply.discussion_reply, 225 "%s's reply" % u, "text of '%s' reply" % u) 226 discussion_for = self.discussion.getDiscussionFor(reply) 227 replies_to_reply = discussion_for.getReplies() 206 228 if replies_to_reply: 207 229 failed_users.append(u) … … 219 241 doc_obj = getattr(self.portal, "doc_%s" % u) 220 242 reply = self.discussion.getDiscussionFor(doc_obj).getReplies()[0] 221 reply_to_reply = self.discussion.getDiscussionFor(reply).getReplies() 243 discussion_for = self.discussion.getDiscussionFor(reply) 244 reply_to_reply = discussion_for.getReplies() 222 245 reply_to_reply_before = len(reply_to_reply) 223 246 self.logout() 224 247 if not u=='anonym': 225 248 self.login(u) 226 # On adding reply to not published reply MUST generte Unauthorized exception 227 self.assertRaises(Unauthorized, reply.discussion_reply, "Reply %s" % u, "text of %s reply" % u) 249 # On adding reply to not published reply MUST generte 250 # Unauthorized exception 251 self.assertRaises(Unauthorized, reply.discussion_reply, 252 "Reply %s" % u, "text of %s reply" % u) 228 253 """ 229 254 … … 247 272 for u in allowable_users: 248 273 self.logout() 249 if not u =='anonym':274 if not u == 'anonym': 250 275 self.login(u) 251 276 … … 256 281 # Check is comment added 257 282 self.login(manager) 258 reply_to_reply = self.discussion.getDiscussionFor(reply).getReplies() 283 discussion_for = self.discussion.getDiscussionFor(reply) 284 reply_to_reply = discussion_for.getReplies() 259 285 if not reply_to_reply: 260 286 failed_users.append(u) 261 self.failIf(failed_users, 262 "%s - user(s) can not really add comment toPUBLISHED reply." % failed_users)287 self.failIf(failed_users, "%s - user(s) can not really add comment to" 288 " PUBLISHED reply." % failed_users) 263 289 264 290 # 3.Check adding reply to reply for illegal users 265 291 for u in illegal_users: 266 292 self.logout() 267 if not u=='anonym': 268 self.login(u) 269 270 # On adding reply to not published reply MUST generte Unauthorized exception 293 if not u == 'anonym': 294 self.login(u) 295 296 # On adding reply to not published reply MUST generte 297 # Unauthorized exception 271 298 self.discussion.getDiscussionFor(reply) 272 299 self.assertRaises(Unauthorized, reply.discussion_reply, … … 289 316 else: 290 317 self.allowable_users = ['dm_admin', 'dm_member', 'admin', 'member'] 291 self.illegal_users = [u for u in self.all_users_id if not u in self.allowable_users] 318 self.illegal_users = [u 319 for u in self.all_users_id 320 if not u in self.allowable_users] 292 321 293 322 # Add testing document to portal in Moderation OFF mode. … … 296 325 self.portal.invokeFactory('Document', id=self.doc_moder_off_id) 297 326 doc_obj = getattr(self.portal, self.doc_moder_off_id) 298 doc_obj.edit(text_format='plain', text='hello world from in moderation off mode') 327 doc_obj.edit(text_format='plain', 328 text='hello world from in moderation off mode') 299 329 300 330 # Create talkback for document and Add comment to 'doc_moderatio_off' … … 309 339 for u in self.allowable_users: 310 340 self.logout() 311 if not u =='anonym':341 if not u == 'anonym': 312 342 self.login(u) 313 343 doc_obj = getattr(self.portal, self.doc_moder_off_id) 314 344 315 345 # Get reply to this document 316 reply_to_doc = self.discussion.getDiscussionFor(doc_obj).getReplies()[0] 346 discussion_for = self.discussion.getDiscussionFor(doc_obj) 347 reply_to_doc = discussion_for.getReplies()[0] 317 348 318 349 # Create talkback for reply and Add comment 319 replies_before = self.discussion.getDiscussionFor(reply_to_doc).getReplies() 350 discussion_for = self.discussion.getDiscussionFor(reply_to_doc) 351 replies_before = discussion_for.getReplies() 320 352 if not replies_before: 321 353 self.discussion.getDiscussionFor(reply_to_doc) 322 reply_to_doc.discussion_reply("%s's reply" % u, "text of '%s' reply" % u) 323 replies_after = self.discussion.getDiscussionFor(reply_to_doc).getReplies() 354 reply_to_doc.discussion_reply("%s's reply" % u, 355 "text of '%s' reply" % u) 356 replies_after = discussion_for.getReplies() 324 357 disparity = len(replies_after) - len(replies_before) 325 358 if not disparity: … … 335 368 for u in self.illegal_users: 336 369 self.logout() 337 if not u =='anonym':370 if not u == 'anonym': 338 371 self.login(u) 339 372 doc_obj = getattr(self.portal, self.doc_moder_off_id) 340 373 341 374 # Get reply to this document 342 reply_to_doc = self.discussion.getDiscussionFor(doc_obj).getReplies()[0] 375 discussion_for = self.discussion.getDiscussionFor(doc_obj) 376 reply_to_doc = discussion_for.getReplies()[0] 343 377 344 378 # Create talkback for reply and Add comment … … 348 382 349 383 350 class TestModerationAnonymComm(TestCommBase, TestMixinAnonymOn, TestMixinModerationOn): 384 class TestModerationAnonymComm(TestCommBase, TestMixinAnonymOn, 385 TestMixinModerationOn): 351 386 352 387 def afterSetUp(self): … … 364 399 365 400 366 class TestModerationOFFAnonymComm(TestCommBase, TestMixinAnonymOff, TestMixinModerationOn): 401 class TestModerationOFFAnonymComm(TestCommBase, TestMixinAnonymOff, 402 TestMixinModerationOn): 367 403 368 404 def afterSetUp(self): … … 379 415 380 416 381 class TestAnonymCommOFFModeration(TestCommBase, TestMixinAnonymOn, TestMixinModerationOff): 417 class TestAnonymCommOFFModeration(TestCommBase, TestMixinAnonymOn, 418 TestMixinModerationOff): 382 419 383 420 def afterSetUp(self): … … 394 431 395 432 396 class TestOFFModerationOFFAnonymComm(TestCommBase, TestMixinAnonymOff, TestMixinModerationOff): 433 class TestOFFModerationOFFAnonymComm(TestCommBase, TestMixinAnonymOff, 434 TestMixinModerationOff): 397 435 398 436 def afterSetUp(self): -
quintagroup.plonecomments/trunk/quintagroup/plonecomments/tests/testQPloneCommentsConfiglet.py
r3118 r3126 16 16 self.membership = getToolByName(self.portal, 'portal_membership', None) 17 17 for user_id in USERS.keys(): 18 self.membership.addMember(user_id, USERS[user_id]['passw'], USERS[user_id]['roles'], []) 18 self.membership.addMember(user_id, USERS[user_id]['passw'], 19 USERS[user_id]['roles'], []) 19 20 20 21 # Add users to Discussion Manager group … … 40 41 # Make sure Documents are visible by default 41 42 # XXX only do this for plone 3 42 self.portal.portal_workflow.setChainForPortalTypes(('Document',), 'plone_workflow') 43 self.portal.portal_workflow.setChainForPortalTypes(('Document',), 44 'plone_workflow') 43 45 44 portal_properties = getToolByName(self.portal, 'portal_properties', None) 46 portal_properties = getToolByName(self.portal, 'portal_properties', 47 None) 45 48 self.prefs = portal_properties[PROPERTY_SHEET] 46 49 self.request = self.app.REQUEST 47 50 48 51 # Add Manager user - 'dm' and add him to Discussion Manager group 49 self.portal.portal_membership.addMember('dm', 'secret', ['Manager'], []) 52 self.portal.portal_membership.addMember('dm', 'secret', ['Manager'], 53 []) 50 54 portal_groups = getToolByName(self.portal, 'portal_groups') 51 55 dm_group = portal_groups.getGroupById('DiscussionManager') … … 54 58 self.login('dm') 55 59 # For prepare mail sending - enter an e-mail adress 56 self.prefs._updateProperty('email_discussion_manager', 'discussion.manager@test.com') 60 self.prefs._updateProperty('email_discussion_manager', 61 'discussion.manager@test.com') 57 62 member = self.portal.portal_membership.getAuthenticatedMember() 58 63 member.setMemberProperties({'email': 'creator@test.com'}) … … 94 99 # Create talkback for document and Add comment to my_doc 95 100 self.discussion.getDiscussionFor(self.my_doc) 96 self.my_doc.discussion_reply('Reply 1', 'text of reply')101 self.my_doc.discussion_reply('Reply 1', 'text of reply') 97 102 # Check moderating discussion 98 103 # MUST ALLOW for: members of 'DiscussionMnagers' group … … 102 107 self.logout() 103 108 self.login(u) 104 self.failUnless(getReplies(), 105 "None discussion item added ordiscussion forbiden for %s user" % u)109 self.failUnless(getReplies(), "None discussion item added or " 110 "discussion forbiden for %s user" % u) 106 111 for u in COMMON_USERS_IDS: 107 112 self.logout() 108 if not u =='anonym':113 if not u == 'anonym': 109 114 self.login(u) 110 115 noSecurityManager() 111 self.failIf(getReplies(), "Viewing discussion item allow for Anonymous user") 116 self.failIf(getReplies(), "Viewing discussion item allow for " 117 "Anonymous user") 112 118 113 119 def testSwitchOFFModeration(self): … … 118 124 # Create talkback for document and Add comment to my_doc 119 125 self.discussion.getDiscussionFor(self.my_doc) 120 self.request.form['Creator'] = self.portal.portal_membership.getAuthenticatedMember().getUserName() 126 creator = self.portal.portal_membership.getAuthenticatedMember() 127 self.request.form['Creator'] = creator.getUserName() 121 128 self.request.form['subject'] = "Reply 1" 122 129 self.request.form['body_text'] = "text of reply" 123 self.my_doc.discussion_reply('Reply 1', 'text of reply')130 self.my_doc.discussion_reply('Reply 1', 'text of reply') 124 131 # Check moderating discussion 125 132 # MUST ALLOW for: user with any role or Anonym … … 127 134 for u in all_users_ids: 128 135 self.logout() 129 if not u =='anonym':136 if not u == 'anonym': 130 137 self.login(u) 131 replies = self.discussion.getDiscussionFor(self.my_doc).getReplies() 132 self.failUnless(replies, 133 "No discussion item added or discussion forbidden for %s user" % u) 138 discussion_for = self.discussion.getDiscussionFor(self.doc_obj) 139 replies = discussion_for.getReplies() 140 self.failUnless(replies, "No discussion item added or discussion " 141 "forbidden for %s user" % u) 134 142 135 143 def testApproveNotification(self): … … 137 145 self.request.form['enable_approve_notification'] = 'True' 138 146 self.portal.prefs_comments_setup() 139 self.failUnless(self.prefs.getProperty('enable_approve_notification')==1, 147 getProperty = self.prefs.getProperty 148 self.failUnless(getProperty('enable_approve_notification') == 1, 140 149 "Approve Notification not terned ON") 141 150 … … 144 153 del self.request.form['enable_approve_notification'] 145 154 self.portal.prefs_comments_setup() 146 self.failUnless( self.prefs.getProperty('enable_approve_notification')==0,155 self.failUnless(getProperty('enable_approve_notification') == 0, 147 156 "Approve Notification not terned OFF") 148 157 … … 151 160 self.request.form['enable_published_notification'] = 'True' 152 161 self.portal.prefs_comments_setup() 153 self.failUnless(self.prefs.getProperty('enable_published_notification')==1, 162 getProperty = self.prefs.getProperty 163 self.failUnless(getProperty('enable_published_notification') == 1, 154 164 "Published Notification not terned ON") 155 165 … … 158 168 del self.request.form['enable_published_notification'] 159 169 self.portal.prefs_comments_setup() 160 self.failUnless( self.prefs.getProperty('enable_published_notification')==0,170 self.failUnless(getProperty('enable_published_notification') == 0, 161 171 "Published Notification not terned OFF") 162 172 -
quintagroup.plonecomments/trunk/quintagroup/plonecomments/tests/testQPloneCommentsInstall.py
r3118 r3126 25 25 def test_configlet_install(self): 26 26 configTool = getToolByName(self.portal, 'portal_controlpanel', None) 27 self.failUnless(CONFIGLET_ID in [a.getId() for a in configTool.listActions()], 27 self.failUnless(CONFIGLET_ID in [a.getId() 28 for a in configTool.listActions()], 28 29 'Configlet %s is not registered.' % CONFIGLET_ID) 29 30 30 31 def test_skins_install(self): 31 skinstool =getToolByName(self.portal, 'portal_skins')32 skinstool = getToolByName(self.portal, 'portal_skins') 32 33 self.failUnless(PRODUCT_SKIN_NAME in skinstool.objectIds(), 33 34 'There is no %s folder in portal_skins.' % PRODUCT_SKIN_NAME) … … 35 36 path = skinstool.getSkinPath(skin) 36 37 layers = map(str.strip, path.split(',')) 37 self.failUnless(PRODUCT_SKIN_NAME in layers, 38 '%s layer is notregistered for %s.' % (PRODUCT_SKIN_NAME, skin))38 self.failUnless(PRODUCT_SKIN_NAME in layers, '%s layer is not ' 39 'registered for %s.' % (PRODUCT_SKIN_NAME, skin)) 39 40 40 41 def test_layer_install(self): … … 45 46 46 47 def test_propertysheet_install(self): 47 portal_properties = getToolByName(self.portal, 'portal_properties', None) 48 portal_properties = getToolByName(self.portal, 'portal_properties', 49 None) 48 50 self.failUnless(PROPERTY_SHEET in portal_properties.objectIds(), 49 51 '%s properies not found in portal_properties.' % PROPERTY_SHEET) 50 52 property_ids = portal_properties[PROPERTY_SHEET].propertyIds() 51 53 self.failUnless(EMAIL_PID in property_ids, 52 '%s propery not found in %s property.' % (EMAIL_PID, PROPERTY_SHEET)) 54 '%s propery not found in %s property.' % \ 55 (EMAIL_PID, PROPERTY_SHEET)) 53 56 self.failUnless(EMAIL_SUBJECT_PID in property_ids, 54 '%s propery not found in %s property.' % (EMAIL_SUBJECT_PID, PROPERTY_SHEET)) 57 '%s propery not found in %s property.' % \ 58 (EMAIL_SUBJECT_PID, PROPERTY_SHEET)) 55 59 self.failUnless(REQUIRE_EMAIL_PID in property_ids, 56 '%s propery not found in %s property.' % (REQUIRE_EMAIL_PID, PROPERTY_SHEET)) 60 '%s propery not found in %s property.' % \ 61 (REQUIRE_EMAIL_PID, PROPERTY_SHEET)) 57 62 self.failUnless(APPROVE_NOTIFICATION_PID in property_ids, 58 '%s propery not found in %s property.' % (APPROVE_NOTIFICATION_PID, PROPERTY_SHEET)) 63 '%s propery not found in %s property.' % \ 64 (APPROVE_NOTIFICATION_PID, PROPERTY_SHEET)) 59 65 self.failUnless(PUBLISHED_NOTIFICATION_PID in property_ids, 60 '%s propery not found in %s property.' % (PUBLISHED_NOTIFICATION_PID, PROPERTY_SHEET)) 66 '%s propery not found in %s property.' % \ 67 (PUBLISHED_NOTIFICATION_PID, PROPERTY_SHEET)) 61 68 self.failUnless(REJECTED_NOTIFICATION_PID in property_ids, 62 '%s propery not found in %s property.' % (REJECTED_NOTIFICATION_PID, PROPERTY_SHEET)) 69 '%s propery not found in %s property.' % \ 70 (REJECTED_NOTIFICATION_PID, PROPERTY_SHEET)) 63 71 self.failUnless(APPROVE_USER_NOTIFICATION_PID in property_ids, 64 '%s propery not found in %s property.' % (APPROVE_USER_NOTIFICATION_PID, PROPERTY_SHEET)) 72 '%s propery not found in %s property.' % \ 73 (APPROVE_USER_NOTIFICATION_PID, PROPERTY_SHEET)) 65 74 self.failUnless(REPLY_USER_NOTIFICATION_PID in property_ids, 66 '%s propery not found in %s property.' % (REPLY_USER_NOTIFICATION_PID, PROPERTY_SHEET)) 75 '%s propery not found in %s property.' % \ 76 (REPLY_USER_NOTIFICATION_PID, PROPERTY_SHEET)) 67 77 self.failUnless(MODERATION_PID in property_ids, 68 '%s propery not found in %s property.' % (MODERATION_PID, PROPERTY_SHEET)) 78 '%s propery not found in %s property.' % \ 79 (MODERATION_PID, PROPERTY_SHEET)) 69 80 self.failUnless(ANONYMOUS_COMMENTING_PID in property_ids, 70 '%s propery not found in %s property.' % (ANONYMOUS_COMMENTING_PID, PROPERTY_SHEET)) 81 '%s propery not found in %s property.' % \ 82 (ANONYMOUS_COMMENTING_PID, PROPERTY_SHEET)) 71 83 72 84 def test_permission_added(self): 73 roles = [item['name'] for item in self.portal.rolesOfPermission(PERM_NAME)] 85 roles = [item['name'] 86 for item in self.portal.rolesOfPermission(PERM_NAME)] 74 87 self.failIf(roles == [], '%s not installed.' % PERM_NAME) 75 88 -
quintagroup.plonecomments/trunk/quintagroup/plonecomments/tests/testQPloneCommentsModeration.py
r3114 r3126 28 28 29 29 # Make sure Documents are visible by default 30 self.portal.portal_workflow.setChainForPortalTypes(('Document',), 'plone_workflow') 30 self.portal.portal_workflow.setChainForPortalTypes(('Document',), 31 'plone_workflow') 31 32 32 33 # Add testing documents to portal. Add one document for avery user. 33 # For testing behaviors, where made some changes to document state it's more usefull. 34 # For testing behaviors, where made some changes to document state 35 # it's more usefull. 34 36 self.discussion = getToolByName(self.portal, 'portal_discussion', None) 35 37 all_users_id = DM_USERS_IDS + COMMON_USERS_IDS … … 38 40 self.portal.invokeFactory('Document', id=doc_id) 39 41 doc_obj = getattr(self.portal, doc_id) 40 doc_obj.edit(text_format='plain', text='hello world from %s' % doc_id) 42 doc_obj.edit(text_format='plain', 43 text='hello world from %s' % doc_id) 41 44 # Create talkback for document and Add comment to doc_obj 42 45 self.discussion.getDiscussionFor(doc_obj) 43 doc_obj.discussion_reply('A Reply for %s' % doc_id,'text of reply for %s' % doc_id) 46 doc_obj.discussion_reply('A Reply for %s' % doc_id, 47 'text of reply for %s' % doc_id) 44 48 45 49 ## TEST VIEWING … … 58 62 # All common users SHOULD NOT VIEW NOT PUBLISHED comments 59 63 doc = getattr(self.portal, 'doc_%s' % DM_USERS_IDS[0]) 60 roles = [r['name'] for r in self.portal.rolesOfPermission('Moderate Discussion') if r['selected'] == 'SELECTED'] 61 authorized_users = [user for user in COMMON_USERS_IDS if user !='anonym'] 62 users_without_md_perm = [u for u in authorized_users if filter(lambda x: x not in roles, USERS[u]['roles'])] 64 roles = [r['name'] 65 for r in self.portal.rolesOfPermission('Moderate Discussion') 66 if r['selected'] == 'SELECTED'] 67 authorized_users = [user 68 for user in COMMON_USERS_IDS 69 if user != 'anonym'] 70 users_without_md_perm = [u 71 for u in authorized_users 72 if filter(lambda x: x not in roles, USERS[u]['roles'])] 63 73 for u in users_without_md_perm: 64 74 self.logout() 65 if not u =='anonym':75 if not u == 'anonym': 66 76 self.login(u) 67 77 replies = self.discussion.getDiscussionFor(doc).getReplies() … … 81 91 for u in all_users_id: 82 92 self.logout() 83 if not u =='anonym':93 if not u == 'anonym': 84 94 self.login(u) 85 95 replies = self.discussion.getDiscussionFor(doc).getReplies() … … 92 102 # Publish button MUST BE ABSENT in document view form 93 103 # Pattern for publish button presence checking 94 pattern = re.compile('.*<input.+?value="Publish"', re.S|re.M) 95 roles = [r['name'] for r in self.portal.rolesOfPermission('Moderate Discussion') if r['selected'] == 'SELECTED'] 96 authorized_users = [user for user in COMMON_USERS_IDS if user !='anonym'] 97 users_without_md_perm = [u for u in authorized_users if filter(lambda x: x not in roles, USERS[u]['roles'])] 104 pattern = re.compile('.*<input.+?value="Publish"', re.S | re.M) 105 roles = [r['name'] 106 for r in self.portal.rolesOfPermission('Moderate Discussion') 107 if r['selected'] == 'SELECTED'] 108 authorized_users = [user 109 for user in COMMON_USERS_IDS 110 if user != 'anonym'] 111 users_without_md_perm = [u 112 for u in authorized_users 113 if filter(lambda x: x not in roles, USERS[u]['roles'])] 98 114 for u in users_without_md_perm: 99 115 self.logout() 100 116 auth = "%s:" % u 101 if not u =='anonym':102 self.login(u) 103 auth = '%s:%s' % (u, USERS[u]['passw'])104 doc_id = "doc_%s" % u 105 html = str(self.publish(self.portal.id +'/%s' % doc_id, auth))106 m = pattern.match(html) 107 self.failIf(m, 108 "Publish button present for %s - user withoutModerate Discussion permission" % u)117 if not u == 'anonym': 118 self.login(u) 119 auth = '%s:%s' % (u, USERS[u]['passw']) 120 doc_id = "doc_%s" % u 121 html = str(self.publish(self.portal.id + '/%s' % doc_id, auth)) 122 m = pattern.match(html) 123 self.failIf(m, "Publish button present for %s - user without " 124 "Moderate Discussion permission" % u) 109 125 110 126 """ … … 113 129 # Pattern for publish button presence checking 114 130 pattern = re.compile('.*<input.+?value="Publish"',re.S|re.M) 115 # pattern = re.compile('.*<input\\s*class="standalone"\\s*type="submit"\\s*value="Publish"\\s*/>', re.S|re.M) 131 # pattern = re.compile('.*<input\\s*class="standalone"\\s*type=' 132 '"submit"\\s*value="Publish"\\s*/>', re.S|re.M) 116 133 for u in DM_USERS_IDS: 117 134 self.login(u) … … 120 137 html = str(self.publish(self.portal.id+'/%s' % doc_id, auth)) 121 138 m = pattern.match(html) 122 self.failUnless(m, 123 "Publish button NOT PRESENT for %s - memberof DiscussionManager group" % u)139 self.failUnless(m, "Publish button NOT PRESENT for %s - member " 140 "of DiscussionManager group" % u) 124 141 """ 125 142 … … 127 144 # Check whether perform real publishing 128 145 # Pattern for publish button presence checking 129 pattern = re.compile('.*<input.+?value="Publish"', re.S|re.M)146 pattern = re.compile('.*<input.+?value="Publish"', re.S | re.M) 130 147 for u in DM_USERS_IDS: 131 148 doc_id = "doc_%s" % u … … 134 151 # Check whether anonymous get no reply 135 152 self.logout() 136 self.failIf(getReplies(), "View not published reply ALLOW for Anonymous") 137 # Login with actual (tested) user with DiscussionManager role and publish discussion 138 self.login(u) 139 self.failUnless(getReplies(), 140 "%s - member of DiscussionManager group NOT VIEW not published reply" % u) 153 self.failIf(getReplies(), 154 "View not published reply ALLOW for Anonymous") 155 # Login with actual (tested) user with DiscussionManager role and 156 # publish discussion 157 self.login(u) 158 self.failUnless(getReplies(), "%s - member of DiscussionManager " 159 "group NOT VIEW not published reply" % u) 141 160 getReplies()[0].discussion_publish_comment() 142 161 # Check if Publish button still present in document view page 143 162 auth = "%s:" % u 144 if not u =='anonym':145 auth = '%s:%s' % (u, USERS[u]['passw'])146 html = str(self.publish(self.portal.id +'/%s' % doc_id, auth))147 m = pattern.match(html) 148 self.failIf(m, 149 "Publish button present for %s - DiscussionManagerrole user after publishing" % u)163 if not u == 'anonym': 164 auth = '%s:%s' % (u, USERS[u]['passw']) 165 html = str(self.publish(self.portal.id + '/%s' % doc_id, auth)) 166 m = pattern.match(html) 167 self.failIf(m, "Publish button present for %s - DiscussionManager " 168 "role user after publishing" % u) 150 169 # Check whether Anonym view published reply 151 170 self.logout() … … 158 177 def testViewDeleteButtonNonDMUsers(self): 159 178 # Check Delete reply button presense ONLY for PUBLISHED reply. 160 # Because of NOT PUBLUISHED replies is not visible at all for common users. 161 # Delete reply button in document view form MUST BE ABSENT for all EXCEPT manager. 179 # Because of NOT PUBLUISHED replies is not visible at all for common 180 # users. 181 # Delete reply button in document view form MUST BE ABSENT for all 182 # EXCEPT manager. 162 183 # Publish replies 163 184 self.logout() … … 169 190 reply.discussion_publish_comment() 170 191 # Prepare pattern for delete reply button presence checking 171 pattern = re.compile('.*<input\\s*class="destructive"\\s*type="submit"\\s*value="Remove"\\s*/>', re.S|re.M) 192 pattern = re.compile('.*<input\\s*class="destructive"\\s*type="submit"' 193 '\\s*value="Remove"\\s*/>', re.S|re.M) 172 194 for u in COMMON_USERS_IDS: 173 195 self.logout() … … 180 202 m = pattern.match(html) 181 203 if not u=='anonym' and 'Manager' in USERS[u]['roles']: 182 self.failUnless(m, 183 " %s - user with Manager role NOT VIEW Delete reply button for"184 " published reply on documentview form" % u)204 self.failUnless(m, "%s - user with Manager role NOT VIEW " 205 "Delete reply button for published reply on document " 206 "view form" % u) 185 207 else: 186 self.failIf(m, 187 " %s - user without Manager role CAN VIEW Delete reply button for"188 " published reply on documentview form" % u)208 self.failIf(m, "%s - user without Manager role CAN VIEW " 209 "Delete reply button for published reply on document " 210 "view form" % u) 189 211 """ 190 212 191 213 def testDeleting(self): 192 214 # Manager with DiscussionManager role CAN delete ANY REPLY. 193 # Manager without DiscussionManager role [common manager] CAN delete ONLY PUBLISHED REPLY. 215 # Manager without DiscussionManager role [common manager] CAN delete 216 # ONLY PUBLISHED REPLY. 194 217 # Get Managers 195 218 managers = [u for u in USERS.keys() if 'Manager' in USERS[u]['roles']] … … 207 230 doc_obj = getattr(self.portal, doc_id) 208 231 getReplies = self.discussion.getDiscussionFor(doc_obj).getReplies 209 self.failUnless(getReplies(), "%s - user with Manager role not view discussion reply" % u) 232 self.failUnless(getReplies(), "%s - user with Manager role not " 233 "view discussion reply" % u) 210 234 getReplies()[0].deleteDiscussion() 211 self.failIf(getReplies(), "%s - user with Manager role not really delete discussion" % u) 235 self.failIf(getReplies(), "%s - user with Manager role not really " 236 "delete discussion" % u) 212 237 213 238 -
quintagroup.plonecomments/trunk/quintagroup/plonecomments/tests/testQPloneCommentsNotification.py
r3120 r3126 12 12 from quintagroup.plonecomments.tests.config import PROPERTY_SHEET 13 13 14 REXP_TO = re.compile("To:\s*(.*?)$", re.M)15 REXP_SUBJ = re.compile("Subject:\s*(.*?)$", re.M)14 REXP_TO = re.compile("To:\s*(.*?)$", re.M) 15 REXP_SUBJ = re.compile("Subject:\s*(.*?)$", re.M) 16 16 17 17 18 18 class TestNotification(FunctionalTestCase): 19 19 20 def setApprovePublished(self, swithA=1, swithP=1):20 def setApprovePublished(self, swithA=1, swithP=1): 21 21 self.prefs._updateProperty('enable_approve_notification', swithA) 22 22 self.prefs._updateProperty('enable_published_notification', swithP) … … 43 43 # Make sure Documents are visible by default 44 44 # XXX only do this for plone 3 45 self.portal.portal_workflow.setChainForPortalTypes(('Document',), 'plone_workflow') 46 47 portal_properties = getToolByName(self.portal, 'portal_properties', None) 45 self.portal.portal_workflow.setChainForPortalTypes(('Document',), 46 'plone_workflow') 47 48 portal_properties = getToolByName(self.portal, 'portal_properties', 49 None) 48 50 self.prefs = portal_properties[PROPERTY_SHEET] 49 51 50 52 # Add Manager user - 'dm' and add him to Discussion Manager group 51 self.portal.portal_membership.addMember('dm', 'secret', ['Manager'], []) 53 self.portal.portal_membership.addMember('dm', 'secret', ['Manager'], 54 []) 52 55 portal_groups = getToolByName(self.portal, 'portal_groups') 53 56 dm_group = portal_groups.getGroupById('DiscussionManager') … … 57 60 # For prepare mail sending - enter an e-mail adress 58 61 self.portal.email_from_address = 'mail@plone.test' 59 self.prefs._updateProperty('email_discussion_manager', 'discussion.manager@test.com') 62 self.prefs._updateProperty('email_discussion_manager', 63 'discussion.manager@test.com') 60 64 member = self.portal.portal_membership.getAuthenticatedMember() 61 member.setMemberProperties({'email': 'creator@test.com'})65 member.setMemberProperties({'email': 'creator@test.com'}) 62 66 63 67 # Add testing document to portal … … 68 72 self.discussion.getDiscussionFor(self.my_doc) 69 73 self.request = self.app.REQUEST 70 self.request.form['Creator'] = self.portal.portal_membership.getAuthenticatedMember().getUserName() 74 creator = self.portal.portal_membership.getAuthenticatedMember() 75 self.request.form['Creator'] = creator.getUserName() 71 76 self.request.form['subject'] = "Reply 1" 72 77 self.request.form['body_text'] = "text of reply" … … 76 81 def test_bug_parent_reply(self): 77 82 setProperties(self.prefs, 'enable_reply_user_notification') 78 self.my_doc.discussion_reply('A Reply for my_doc', 'text of reply for my_doc') 79 parent_reply = self.discussion.getDiscussionFor(self.my_doc).getReplies()[0] 83 self.my_doc.discussion_reply('A Reply for my_doc', 84 'text of reply for my_doc') 85 discussion_for = self.discussion.getDiscussionFor(self.my_doc) 86 parent_reply = discussion_for.getReplies()[0] 80 87 parent_reply.discussion_reply('reply', 'text') 81 88 82 89 def test_bug_mistakable_names(self): 83 90 setProperties(self.prefs, 'enable_reply_user_notification') 84 self.my_doc.discussion_reply('A Reply for my_doc' ,'text of reply for my_doc') 85 parent_reply = self.discussion.getDiscussionFor(self.my_doc).getReplies()[0] 86 87 args={'mto': 'user_email@gmail.com', 88 'mfrom': 'admin_email@gmail.com', 89 'obj': parent_reply, 90 'organization_name': 'org_name', 91 'name': parent_reply.getOwnerTuple()[1]} 91 self.my_doc.discussion_reply('A Reply for my_doc', 92 'text of reply for my_doc') 93 discussion_for = self.discussion.getDiscussionFor(self.my_doc) 94 parent_reply = discussion_for.getReplies()[0] 95 96 args = {'mto': 'user_email@gmail.com', 97 'mfrom': 'admin_email@gmail.com', 98 'obj': parent_reply, 99 'organization_name': 'org_name', 100 'name': parent_reply.getOwnerTuple()[1]} 92 101 93 102 msg = getMsg(self.portal, 'reply_notify_template', args) … … 103 112 self.portal.MailHost.reset() 104 113 setProperties(self.prefs) 105 self.my_doc.discussion_reply('A Reply for my_doc' ,'text of reply for my_doc') 106 self.failIf(testMailExistance(self), 'Mail was sended when all notification was disabled.') 114 self.my_doc.discussion_reply('A Reply for my_doc', 115 'text of reply for my_doc') 116 self.failIf(testMailExistance(self), 117 'Mail was sended when all notification was disabled.') 107 118 108 119 def test_published_comment_notification(self): 109 120 self.portal.MailHost.reset() 110 121 setProperties(self.prefs, 'enable_published_notification') 111 self.my_doc.discussion_reply('A Reply for my_doc' ,'text of reply for my_doc') 112 self.failUnless(testMailExistance(self), 'Mail was not sended when enable_published_notification.') 122 self.my_doc.discussion_reply('A Reply for my_doc', 123 'text of reply for my_doc') 124 self.failUnless(testMailExistance(self), 125 'Mail was not sended when enable_published_notification.') 113 126 114 127 def test_approve_comment_notification(self): 115 128 self.portal.MailHost.reset() 116 129 setProperties(self.prefs, 'enable_approve_notification') 117 self.my_doc.discussion_reply('A Reply for my_doc' ,'text of reply for my_doc') 118 self.failUnless(testMailExistance(self), 'Mail was not sended when enable_approve_notification.') 130 self.my_doc.discussion_reply('A Reply for my_doc', 131 'text of reply for my_doc') 132 self.failUnless(testMailExistance(self), 133 'Mail was not sended when enable_approve_notification.') 119 134 120 135 def test_reply_comment_user_notification(self): 121 136 self.portal.MailHost.reset() 122 137 setProperties(self.prefs, 'enable_reply_user_notification') 123 self.my_doc.discussion_reply('A Reply for my_doc' ,'text of reply for my_doc') 124 self.failIf(testMailExistance(self), 'Mail was sended for simple reply when enable_reply_user_notification.') 125 126 reply = self.discussion.getDiscussionFor(self.my_doc).getReplies()[0] 127 reply.discussion_reply('A Reply for comment' ,'text of reply for comment') 138 self.my_doc.discussion_reply('A Reply for my_doc', 139 'text of reply for my_doc') 140 self.failIf(testMailExistance(self), 'Mail was sended for simple reply' 141 ' when enable_reply_user_notification.') 142 143 reply = self.discussion.getDiscussionFor(self.my_doc).getReplies()[0] 144 reply.discussion_reply('A Reply for comment', 145 'text of reply for comment') 128 146 self.discussion.getDiscussionFor(self.my_doc).getReplies()[0] 129 self.failUnless(testMailExistance(self), 'Mail was not sended when enable_reply_user_notification.') 147 self.failUnless(testMailExistance(self), 148 'Mail was not sended when enable_reply_user_notification.') 130 149 131 150 def test_rejected_comment_notification(self): 132 151 self.portal.MailHost.reset() 133 setProperties(self.prefs, 'enable_rejected_user_notification', 'enable_moderation') 134 self.my_doc.discussion_reply('A Reply for my_doc' ,'text of reply for my_doc') 135 self.failIf(testMailExistance(self), 'Mail was sended when enable_rejected_user_notification was enabled.') 152 setProperties(self.prefs, 'enable_rejected_user_notification', 153 'enable_moderation') 154 self.my_doc.discussion_reply('A Reply for my_doc', 155 'text of reply for my_doc') 156 self.failIf(testMailExistance(self), 'Mail was sended when ' 157 'enable_rejected_user_notification was enabled.') 136 158 137 159 reply = self.discussion.getDiscussionFor(self.my_doc).getReplies()[0] 138 160 self.portal.REQUEST.set('ids', [reply.getId()]) 139 161 self.portal.prefs_recent_comments_delete() 140 self.failUnless(testMailExistance(self), 'Mail was not sended when enable_rejected_user_notification.') 162 self.failUnless(testMailExistance(self), 163 'Mail was not sended when enable_rejected_user_notification.') 141 164 142 165 def test_approve_comment_user__notification(self): 143 166 self.portal.MailHost.reset() 144 167 setProperties(self.prefs, 'enable_approve_user_notification') 145 self.my_doc.discussion_reply('A Reply for my_doc' ,'text of reply for my_doc') 146 self.failUnless(testMailExistance(self), 'Mail was not sended when enable_approve_user_notification.') 168 self.my_doc.discussion_reply('A Reply for my_doc', 169 'text of reply for my_doc') 170 self.failUnless(testMailExistance(self), 171 'Mail was not sended when enable_approve_user_notification.') 147 172 148 173 def test_bug_notification_on_single_reply_publish(self): … … 152 177 for document creator about adding new comment. 153 178 """ 154 properties = ['enable_approve_user_notification', 'enable_reply_user_notification', 179 properties = ['enable_approve_user_notification', 180 'enable_reply_user_notification', 155 181 'enable_published_notification'] 156 182 setProperties(self.prefs, *properties) 157 183 #setProperties(self.prefs, 'enable_published_notification', ) 158 self.my_doc.discussion_reply('A Reply for my_doc' ,'text of reply for my_doc') 159 reply = self.discussion.getDiscussionFor(self.my_doc).getReplies()[0] 160 reply.discussion_reply('A Reply for reply for my_doc' ,'text of reply on reply for my_doc') 184 self.my_doc.discussion_reply('A Reply for my_doc', 185 'text of reply for my_doc') 186 reply = self.discussion.getDiscussionFor(self.my_doc).getReplies()[0] 187 reply.discussion_reply('A Reply for reply for my_doc', 188 'text of reply on reply for my_doc') 161 189 reply2 = self.discussion.getDiscussionFor(reply).getReplies()[0] 162 190 … … 164 192 reply2.discussion_publish_comment() 165 193 mails = [str(m) for m in self.portal.MailHost.messages] 166 self.failUnless([1 for m in mails if REXP_SUBJ.search(m) and 'replied' in REXP_SUBJ.search(m).group(1)], 194 subjects = lambda m: REXP_SUBJ.search(m).group(1) 195 is_subject = lambda m: REXP_SUBJ.search(m) 196 self.failUnless([1 197 for m in mails 198 if is_subject(m) and 'replied' in subjects(m)], 167 199 'No notification for reply.' % properties) 168 self.failUnless([1 for m in mails if REXP_SUBJ.search(m) and 'added' in REXP_SUBJ.search(m).group(1)], 200 self.failUnless([1 201 for m in mails 202 if is_subject(m) and 'added' in subjects(m)], 169 203 'No notification for adding comment.' % properties) 170 self.failUnless([1 for m in mails if REXP_SUBJ.search(m) and 'published' in REXP_SUBJ.search(m).group(1)], 204 self.failUnless([1 205 for m in mails 206 if is_subject(m) and 'published' in subjects(m)], 171 207 'No notification for publishing comment.' % properties) 172 208 … … 175 211 Mail about rejecing comment should be sent to comentator. 176 212 """ 177 properties = ['enable_rejected_user_notification', ]213 properties = ['enable_rejected_user_notification', ] 178 214 setProperties(self.prefs, *properties) 179 215 #setProperties(self.prefs, 'enable_published_notification', ) 180 self.my_doc.discussion_reply('A Reply for my_doc' ,'text of reply for my_doc') 216 self.my_doc.discussion_reply('A Reply for my_doc', 217 'text of reply for my_doc') 181 218 reply = self.discussion.getDiscussionFor(self.my_doc).getReplies()[0] 182 219 … … 185 222 mails = [str(m) for m in self.portal.MailHost.messages] 186 223 subject = 'Your comment on Doc was not approved' 187 self.failUnless([1 for m in mails if REXP_SUBJ.search(m) and REXP_SUBJ.search(m).group(1)==subject], 224 subjects = REXP_SUBJ.search(m).group(1) 225 self.failUnless([1 226 for m in mails 227 if REXP_SUBJ.search(m) and \ 228 REXP_SUBJ.search(m).group(1) == subject], 188 229 'No notification for rejecting comment.' % properties) 189 230 -
quintagroup.plonecomments/trunk/quintagroup/plonecomments/tests/testQPloneCommentsNotificationRecipients.py
r3116 r3126 12 12 13 13 USERS = { # Common Members 14 'admin': {'passw': 'secret_admin', 'roles': ['Manager']},15 'owner': {'passw': 'secret_creator', 'roles': ['Member']},16 'replier1': {'passw': 'secret_member', 'roles': ['Member']},17 'replier2': {'passw': 'secret_member', 'roles': ['Member']},14 'admin': {'passw': 'secret_admin', 'roles': ['Manager']}, 15 'owner': {'passw': 'secret_creator', 'roles': ['Member']}, 16 'replier1': {'passw': 'secret_member', 'roles': ['Member']}, 17 'replier2': {'passw': 'secret_member', 'roles': ['Member']}, 18 18 # Members for discussion manager group 19 'dm_admin': {'passw': 'secret_dm_admin', 'roles': ['Manager']},19 'dm_admin': {'passw': 'secret_dm_admin', 'roles': ['Manager']}, 20 20 } 21 21 DM_USERS_IDS = [u for u in USERS.keys() if u.startswith('dm_')] 22 22 23 REXP_TO = re.compile("To:\s*(.*?)$", re.M)24 REXP_SUBJ = re.compile("Subject:\s*(.*?)$", re.M)23 REXP_TO = re.compile("To:\s*(.*?)$", re.M) 24 REXP_SUBJ = re.compile("Subject:\s*(.*?)$", re.M) 25 25 26 26 … … 31 31 self.login(member_id) 32 32 self.request = self.app.REQUEST 33 self.request.form['Creator'] = self.membership.getAuthenticatedMember().getUserName() 34 self.request.form['subject'] = "Reply of '%s'" % self.request.form['Creator'] 33 creator = self.membership.getAuthenticatedMember() 34 subject = "Reply of '%s'" % self.request.form['Creator'] 35 self.request.form['Creator'] = creator.getUserName() 36 self.request.form['subject'] = subject 35 37 self.request.form['body_text'] = "text of reply" 36 38 … … 57 59 # Make sure Documents are visible by default 58 60 # XXX only do this for plone 3 59 self.portal.portal_workflow.setChainForPortalTypes(('Document',), 'plone_workflow') 60 portal_properties = getToolByName(self.portal, 'portal_properties', None) 61 self.portal.portal_workflow.setChainForPortalTypes(('Document',), 62 'plone_workflow') 63 portal_properties = getToolByName(self.portal, 'portal_properties', 64 None) 61 65 self.prefs = portal_properties[PROPERTY_SHEET] 62 66 … … 66 70 self.createMemberarea('owner') 67 71 68 # Prepare mail sending - enter an e-mail adress, and allow all possible notifications 72 # Prepare mail sending - enter an e-mail adress, 73 # and allow all possible notifications 69 74 self.portal.email_from_address = 'mail@plone.test' 70 setProperties(self.prefs, 'enable_moderation', 'enable_approve_notification', 71 'enable_approve_user_notification','enable_reply_user_notification', 72 'enable_published_notification', 'enable_rejected_user_notification') 73 self.prefs._updateProperty('email_discussion_manager', 'discussion.manager@test.com') 75 setProperties(self.prefs, 'enable_moderation', 76 'enable_approve_notification', 'enable_approve_user_notification', 77 'enable_reply_user_notification', 'enable_published_notification', 78 'enable_rejected_user_notification') 79 self.prefs._updateProperty('email_discussion_manager', 80 'discussion.manager@test.com') 74 81 self.prefs._updateProperty('email_subject_prefix', 'PREFIX') 75 82 76 83 # Add testing document to portal 77 84 self.login('owner') 78 self.portal.Members['owner'].invokeFactory('Document', id='my_doc', title="Test document") 85 self.portal.Members['owner'].invokeFactory('Document', id='my_doc', 86 title="Test document") 79 87 self.my_doc = self.portal.Members['owner']['my_doc'] 80 88 self.my_doc.edit(text_format='plain', text='hello world') … … 85 93 86 94 def checkToANDSubj(self, mails, to, subj): 87 messages = [str(m) for m in mails if REXP_TO.search(str(m)) and REXP_TO.search(str(m)).group(1)==to] 88 self.failUnless(len(messages) > 0, "No message sent to '%s' recipient" % to) 89 self.failUnless([1 for m in messages if REXP_SUBJ.search(m) and REXP_SUBJ.search(m).group(1)==subj],\ 90 "There is no message for '%s' recipient with '%s' subject" % (to,subj)) 95 messages = [str(m) 96 for m in mails 97 if REXP_TO.search(str(m)) and \ 98 REXP_TO.search(str(m)).group(1) == to] 99 self.failUnless(len(messages) > 0, 100 "No message sent to '%s' recipient" % to) 101 self.failUnless([1 102 for m in messages 103 if REXP_SUBJ.search(m) and \ 104 REXP_SUBJ.search(m).group(1) == subj], 105 "There is no message for '%s' recipient with '%s' subject" % \ 106 (to, subj)) 91 107 92 108 def test_Reply(self): 93 109 self.portal.MailHost.reset() 94 110 self.prepareRequest4Reply('replier1') 95 self.my_doc.discussion_reply('A Reply for my_doc' ,'text of reply for my_doc') 111 self.my_doc.discussion_reply('A Reply for my_doc', 112 'text of reply for my_doc') 96 113 mails = self.portal.MailHost.messages 97 114 self.assertEqual(len(mails), 1) … … 101 118 def test_PublishReply(self): 102 119 self.prepareRequest4Reply('replier1') 103 self.my_doc.discussion_reply('A Reply for my_doc' ,'text of reply for my_doc') 120 self.my_doc.discussion_reply('A Reply for my_doc', 121 'text of reply for my_doc') 104 122 self.login('dm_admin') 105 123 reply = self.discussion.getDiscussionFor(self.my_doc).getReplies()[0] … … 108 126 mails = self.portal.MailHost.messages 109 127 self.assertEqual(len(mails), 2) 110 self.checkToANDSubj(mails, to="owner@test.com", subj="[PREFIX] New comment added") 111 self.checkToANDSubj(mails, to="replier1@test.com", subj='Your comment on Test document is now published') 128 self.checkToANDSubj(mails, to="owner@test.com", 129 subj="[PREFIX] New comment added") 130 self.checkToANDSubj(mails, to="replier1@test.com", 131 subj='Your comment on Test document is now published') 112 132 113 133 def test_Publish2ndReply(self): 114 134 self.prepareRequest4Reply('replier1') 115 self.my_doc.discussion_reply('A Reply for my_doc' ,'text of reply for my_doc') 135 self.my_doc.discussion_reply('A Reply for my_doc', 136 'text of reply for my_doc') 116 137 self.login('dm_admin') 117 138 reply = self.discussion.getDiscussionFor(self.my_doc).getReplies()[0] 118 139 reply.discussion_publish_comment() 119 140 self.prepareRequest4Reply('replier2') 120 reply.discussion_reply('A Reply for reply for my_doc' ,'text of reply on reply for my_doc') 141 reply.discussion_reply('A Reply for reply for my_doc', 142 'text of reply on reply for my_doc') 121 143 self.login('dm_admin') 122 144 reply2 = self.discussion.getDiscussionFor(reply).getReplies()[0] … … 125 147 mails = self.portal.MailHost.messages 126 148 self.assertEqual(len(mails), 3) 127 self.checkToANDSubj(mails, to="owner@test.com", subj="[PREFIX] New comment added") 128 self.checkToANDSubj(mails, to="replier1@test.com", subj='Someone replied to your comment on Test document') 129 self.checkToANDSubj(mails, to="replier2@test.com", subj='Your comment on Test document is now published') 149 self.checkToANDSubj(mails, to="owner@test.com", 150 subj="[PREFIX] New comment added") 151 self.checkToANDSubj(mails, to="replier1@test.com", 152 subj='Someone replied to your comment on Test document') 153 self.checkToANDSubj(mails, to="replier2@test.com", 154 subj='Your comment on Test document is now published') 130 155 131 156 def test_DeleteReply(self): 132 157 self.prepareRequest4Reply('replier1') 133 self.my_doc.discussion_reply('A Reply for my_doc' ,'text of reply for my_doc') 158 self.my_doc.discussion_reply('A Reply for my_doc', 159 'text of reply for my_doc') 134 160 self.login('dm_admin') 135 161 reply = self.discussion.getDiscussionFor(self.my_doc).getReplies()[0] … … 138 164 mails = self.portal.MailHost.messages 139 165 self.assertEqual(len(mails), 1) 140 self.checkToANDSubj(mails, to="replier1@test.com", subj='Your comment on Test document was not approved') 166 self.checkToANDSubj(mails, to="replier1@test.com", 167 subj='Your comment on Test document was not approved') 141 168 142 169 -
quintagroup.plonecomments/trunk/quintagroup/plonecomments/tests/testQPloneCommentsReportAbuse.py
r3120 r3126 21 21 doc_obj.report_abuse("Anonymous Report Abuse") 22 22 except: 23 raise "Anonymous user CAN'T report abuse in turned ON *Anonymous report abuse mode*." 23 raise "Anonymous user CAN'T report abuse in turned ON *Anonymous"\ 24 " report abuse mode*." 24 25 25 26 def testAuthenticatedReportAbuse(self): 26 not_anonym_users = [u for u in self.all_users_id if not u =='anonym']27 not_anonym_users = [u for u in self.all_users_id if not u == 'anonym'] 27 28 failed_users = [] 28 29 for u in not_anonym_users: … … 39 40 failed_users.append(u) 40 41 41 self.assert_(not failed_users, "%s - user(s) can not report abuse" % failed_users) 42 self.assert_(not failed_users, 43 "%s - user(s) can not report abuse" % failed_users) 42 44 43 45 -
quintagroup.plonecomments/trunk/quintagroup/plonecomments/tests/testQPloneCommentsUninstall.py
r3112 r3126 26 26 27 27 def test_skins_uninstall(self): 28 skinstool =getToolByName(self.portal, 'portal_skins')28 skinstool = getToolByName(self.portal, 'portal_skins') 29 29 self.failIf(PRODUCT_SKIN_NAME in skinstool.objectIds(), 30 30 'There is still %s folder in portal_skins.' % PRODUCT_SKIN_NAME) … … 38 38 from plone.browserlayer.utils import registered_layers 39 39 from quintagroup.plonecomments.interfaces import IPloneCommentsLayer 40 self.failIf(IPloneCommentsLayer in registered_layers(), 41 ' %s layerfound after uninstallation.' % IPloneCommentsLayer.getName())40 self.failIf(IPloneCommentsLayer in registered_layers(), '%s layer ' 41 'found after uninstallation.' % IPloneCommentsLayer.getName()) 42 42 43 43 def test_configlet_uninstall(self): 44 44 configTool = getToolByName(self.portal, 'portal_controlpanel', None) 45 self.failIf(CONFIGLET_ID in [a.getId() for a in configTool.listActions()], 45 self.failIf(CONFIGLET_ID in [a.getId() 46 for a in configTool.listActions()], 46 47 'Configlet %s found after uninstallation.' % CONFIGLET_ID) 47 48 … … 49 50 portal_properties = getToolByName(self.portal, 'portal_properties') 50 51 self.failUnless(PROPERTY_SHEET in portal_properties.objectIds(), 51 '%s property_sheet not found in portal_properties after uninstallation.' % PROPERTY_SHEET) 52 '%s property_sheet not found in portal_properties after ' 53 'uninstallation.' % PROPERTY_SHEET) 54 52 55 53 56 def test_suite(): -
quintagroup.plonecomments/trunk/quintagroup/plonecomments/tests/tests.py
r3114 r3126 5 5 #from Testing import ZopeTestCase as ztc 6 6 #from base import TestCase 7 7 8 8 9 def test_suite():
Note: See TracChangeset
for help on using the changeset viewer.