Changeset 162
- Timestamp:
- 01/11/06 01:24:46
- Files:
-
- qPloneComments/trunk/tests/testQPloneComments.py (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
qPloneComments/trunk/tests/testQPloneComments.py
r161 r162 45 45 46 46 def afterSetUp(self): 47 self.loginAsPortalOwner() 48 47 49 self.qi = self.portal.portal_quickinstaller 48 50 self.qi.installProduct(PRODUCT) … … 124 126 125 127 def afterSetUp(self): 128 self.loginAsPortalOwner() 129 126 130 self.qi = self.portal.portal_quickinstaller 127 131 self.qi.installProduct(PRODUCT) 128 132 # VERY IMPORTANT to guarantee product skin's content visibility 129 133 self._refreshSkinData() 130 131 self.loginAsPortalOwner() 134 132 135 '''Preparation for functional testing''' 133 136 # add members … … 254 257 255 258 class TestModeration(PloneTestCase.FunctionalTestCase): 259 256 260 def afterSetUp(self): 261 self.loginAsPortalOwner() 262 257 263 self.qi = self.portal.portal_quickinstaller 258 264 self.qi.installProduct(PRODUCT) 259 265 # VERY IMPORTANT to guarantee product skin's content visibility 260 266 self._refreshSkinData() 261 262 #self.portal.changeSkin('Plone Default')263 264 self.loginAsPortalOwner()265 267 266 268 '''Preparation for functional testing''' … … 279 281 # add Discussion Manager group 280 282 portal_groups = self.portal.portal_groups 281 portal_groups.addGroup('DiscussionManager s', roles=['DiscussionManager'])282 dm_group = portal_groups.getGroupById(id='DiscussionManager s')283 portal_groups.addGroup('DiscussionManager', roles=['DiscussionManager']) 284 dm_group = portal_groups.getGroupById(id='DiscussionManager') 283 285 dm_group.addMember('dm_admin') 284 286 dm_group.addMember('dm_owner') … … 355 357 re.S|re.M) 356 358 # FOR user without DiscussionManager role 357 # publish button MUST BE ABSENT in document view form359 # publish reply button MUST BE ABSENT in document view form 358 360 for u in ['admin', 'reviewer','owner','member','anonym']: 359 361 self.logout() … … 365 367 html = str(self.publish(self.portal.id+'/%s' % doc_id, auth)) 366 368 m = pattern.match(html) 367 self.assert_(not m, "Publish button present for %s user without DiscussionManager role" % u)369 self.assert_(not m, "Publish reply button present for %s user without DiscussionManager role" % u) 368 370 369 371 # Check users with DiscussionManager role … … 373 375 auth = '%s:secret_%s' % (u,u) 374 376 doc_id = "doc_%s" % u 375 # 1. Must PRESENT publish button377 # 1. Must PRESENT publish reply button 376 378 html = str(self.publish(self.portal.id+'/%s' % doc_id, auth)) 377 379 m = pattern.match(html) … … 394 396 self.assert_(replies, "User %s with DiscussionManager role not publish discussion" % u) 395 397 396 397 #def testDeleting(self): 398 399 def testDeleting(self): 400 # Add testing documents and reply for it to portal 401 doc_ids = ['doc_dm_admin','doc_dm_reviewer','doc_dm_owner','doc_dm_member',\ 402 'doc_admin', 'doc_reviewer','doc_owner','doc_member','doc_anonym'] 403 for doc in doc_ids: 404 my_doc = self.portal.invokeFactory('Document', id=doc) 405 doc_obj = getattr(self.portal, doc) 406 doc_obj.edit(text_format='plain', text='hello world from %s' % doc) 407 # Create talkback for document and Add comment to my_doc 408 self.discussion.getDiscussionFor(doc_obj) 409 doc_obj.discussion_reply('A Reply for %s' % doc,'text of reply for %s' % doc) 410 411 # Prepare pattern for delete reply button presence checking 412 pattern = re.compile('.*<input\\s*class="destructive"\\s*type="submit"\\s*value="Remove This Discussion"\\s*/>',\ 413 re.S|re.M) 414 # FOR user without Manager role 415 # delete reply button MUST BE ABSENT in document view form 416 for u in ['dm_reviewer','dm_owner','dm_member','admin','reviewer','owner','member','anonym']: 417 self.logout() 418 auth = u 419 if not u=='anonym': 420 self.login(u) 421 auth = '%s:secret_%s' % (u,u) 422 doc_id = "doc_%s" % u 423 html = str(self.publish(self.portal.id+'/%s' % doc_id, auth)) 424 m = pattern.match(html) 425 self.assert_(not m, "Delete reply button present for %s user without both: DiscussionManager and Manager roles" % u) 426 427 # Publish doc_admin object, which has Manager role for checking 428 # is he can delete published discussion reply 429 self.logout() 430 self.login('dm_admin') 431 doc_obj = getattr(self.portal, "doc_admin") 432 getReplies = self.discussion.getDiscussionFor(doc_obj).getReplies 433 replies = getReplies()[0].discussion_publish_comment() 434 435 # Check users with Manager role for deleting 436 for u in ['dm_admin','admin']: 437 self.logout() 438 self.login(u) 439 auth = '%s:secret_%s' % (u,u) 440 doc_id = "doc_%s" % u 441 # 1. Must PRESENT delete reply button 442 html = str(self.publish(self.portal.id+'/%s' % doc_id, auth)) 443 m = pattern.match(html) 444 self.assert_(m, "It is absent Delete reply button for %s user with DiscussionManager role" % u) 445 # 2. Must perform real deleting 446 doc_obj = getattr(self.portal, doc_id) 447 getReplies = self.discussion.getDiscussionFor(doc_obj).getReplies 448 replies = getReplies() 449 self.assert_(replies, "User %s with Manager role not view discussion reply" % u) 450 replies[0].deleteDiscussion() 451 # Check whether discussion reply really deleted 452 replies = getReplies() 453 self.assert_(not replies, "User %s with Manager role not really delete discussion" % u) 454 398 455 399 456
