Changeset 3126 in products


Ignore:
Timestamp:
Apr 18, 2011 10:06:14 AM (13 years ago)
Author:
kroman0
Message:

pep8 passed

Location:
quintagroup.plonecomments/trunk/quintagroup/plonecomments
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.plonecomments/trunk/quintagroup/plonecomments/browser/comments.py

    r3120 r3126  
    1616from plone.app.layout.viewlets import comments 
    1717from plone.app.kss.plonekssview import PloneKSSView 
     18 
    1819 
    1920class CommentsViewlet(comments.CommentsViewlet): 
  • quintagroup.plonecomments/trunk/quintagroup/plonecomments/tests/testQPloneCommentsCommenting.py

    r3120 r3126  
    3737        # Make sure Documents are visible by default 
    3838        # 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') 
    4041 
    4142        # 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) 
    4447        self.all_users_id = DM_USERS_IDS + COMMON_USERS_IDS 
    4548        for user_id in self.all_users_id: 
     
    4750            self.portal.invokeFactory('Document', id=doc_id) 
    4851            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) 
    5054            # Create talkback for document and Add comment to doc_obj 
    5155            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) 
    5358 
    5459 
     
    6368        self.login('dm_admin') 
    6469        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()) 
    6672 
    6773        # Create talkback for document and Add comment 
     
    6975        doc_obj.discussion_reply("Anonym reply", "text of 'anonym' reply") 
    7076        self.login('dm_admin') 
    71         replies_after = len(self.discussion.getDiscussionFor(doc_obj).getReplies()) 
     77        replies_after = len(discussion_for.getReplies()) 
    7278        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*.") 
    7481 
    7582    def testAddCommentToDocNotAnonymUsers(self): 
     
    8289            doc_id = "doc_%s" % u 
    8390            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() 
    8593            self.login(u) 
    8694 
    8795            # 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) 
    8998 
    9099            # Check is comment added 
    91100            self.login('dm_admin') 
    92             replies_after = self.discussion.getDiscussionFor(doc_obj).getReplies() 
     101            replies_after = discussion_for.getReplies() 
    93102            disparity = len(replies_after) - len(replies_before) 
    94103            if not disparity: 
    95104                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) 
    97107 
    98108 
     
    102112        all_users_id = DM_USERS_IDS + COMMON_USERS_IDS 
    103113        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] 
    105117 
    106118    def testAddCommentToDocLikeAnonymUsers(self): 
     
    111123            self.login('dm_admin') 
    112124            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() 
    114127 
    115128            # Create talkback for document and Add comment 
    116129            self.logout() 
    117             if not u=='anonym': 
     130            if not u == 'anonym': 
    118131                self.login(u) 
    119132            self.assertRaises(Unauthorized, doc_obj.discussion_reply, 
    120133                "%s's reply" % u, "text of '%s' reply" % u) 
    121134            self.login('dm_admin') 
    122             replies_after = self.discussion.getDiscussionFor(doc_obj).getReplies() 
     135            replies_after = discussion_for.getReplies() 
    123136            disparity = len(replies_after) - len(replies_before) 
    124137            if disparity: 
     
    136149            doc_id = "doc_%s" % u 
    137150            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() 
    139153            self.login(u) 
    140154 
    141155            # 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) 
    143158 
    144159            # Check is comment added 
    145160            self.login('dm_admin') 
    146             replies_after = self.discussion.getDiscussionFor(doc_obj).getReplies() 
     161            replies_after = discussion_for.getReplies() 
    147162            disparity = len(replies_after) - len(replies_before) 
    148163            if not disparity: 
     
    171186            self.allowable_dm_users = ['dm_admin', 'dm_member'] 
    172187            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] 
    175194 
    176195    def testAddCommentToNotPublishedReplyDMUsers(self): 
    177196 
    178         # DiscussionManager's group's members with Manager or Member roles CAN ADD COMMENTS 
    179         # 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) 
    180199        failed_users = [] 
    181200        for u in self.allowable_dm_users: 
     
    187206            self.discussion.getDiscussionFor(reply) 
    188207            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() 
    190210            if not replies_to_reply: 
    191211                failed_users.append(u) 
    192         self.failIf(failed_users, 
    193             "%s - member(s) of DiscussionManager group CAN'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) 
    194214 
    195215        # This is actual only in terned OFF *Anonymous commenting mode* 
     
    202222            # Create talkback for reply and Add comment 
    203223            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() 
    206228            if replies_to_reply: 
    207229                failed_users.append(u) 
     
    219241            doc_obj = getattr(self.portal, "doc_%s" % u) 
    220242            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() 
    222245            reply_to_reply_before = len(reply_to_reply) 
    223246            self.logout() 
    224247            if not u=='anonym': 
    225248                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) 
    228253    """ 
    229254 
     
    247272        for u in allowable_users: 
    248273            self.logout() 
    249             if not u=='anonym': 
     274            if not u == 'anonym': 
    250275                self.login(u) 
    251276 
     
    256281            # Check is comment added 
    257282            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() 
    259285            if not reply_to_reply: 
    260286                failed_users.append(u) 
    261         self.failIf(failed_users, 
    262             "%s - user(s) can not really add comment to PUBLISHED reply." % failed_users) 
     287        self.failIf(failed_users, "%s - user(s) can not really add comment to" 
     288                                  " PUBLISHED reply." % failed_users) 
    263289 
    264290        # 3.Check adding reply to reply for illegal users 
    265291        for u in illegal_users: 
    266292            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 
    271298            self.discussion.getDiscussionFor(reply) 
    272299            self.assertRaises(Unauthorized, reply.discussion_reply, 
     
    289316        else: 
    290317            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] 
    292321 
    293322        # Add testing document to portal in Moderation OFF mode. 
     
    296325        self.portal.invokeFactory('Document', id=self.doc_moder_off_id) 
    297326        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') 
    299329 
    300330        # Create talkback for document and Add comment to 'doc_moderatio_off' 
     
    309339        for u in self.allowable_users: 
    310340            self.logout() 
    311             if not u=='anonym': 
     341            if not u == 'anonym': 
    312342                self.login(u) 
    313343            doc_obj = getattr(self.portal, self.doc_moder_off_id) 
    314344 
    315345            # 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] 
    317348 
    318349            # 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() 
    320352            if not replies_before: 
    321353                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() 
    324357            disparity = len(replies_after) - len(replies_before) 
    325358            if not disparity: 
     
    335368        for u in self.illegal_users: 
    336369            self.logout() 
    337             if not u=='anonym': 
     370            if not u == 'anonym': 
    338371                self.login(u) 
    339372            doc_obj = getattr(self.portal, self.doc_moder_off_id) 
    340373 
    341374            # 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] 
    343377 
    344378            # Create talkback for reply and Add comment 
     
    348382 
    349383 
    350 class TestModerationAnonymComm(TestCommBase, TestMixinAnonymOn, TestMixinModerationOn): 
     384class TestModerationAnonymComm(TestCommBase, TestMixinAnonymOn, 
     385                               TestMixinModerationOn): 
    351386 
    352387    def afterSetUp(self): 
     
    364399 
    365400 
    366 class TestModerationOFFAnonymComm(TestCommBase, TestMixinAnonymOff, TestMixinModerationOn): 
     401class TestModerationOFFAnonymComm(TestCommBase, TestMixinAnonymOff, 
     402                                  TestMixinModerationOn): 
    367403 
    368404    def afterSetUp(self): 
     
    379415 
    380416 
    381 class TestAnonymCommOFFModeration(TestCommBase, TestMixinAnonymOn, TestMixinModerationOff): 
     417class TestAnonymCommOFFModeration(TestCommBase, TestMixinAnonymOn, 
     418                                  TestMixinModerationOff): 
    382419 
    383420    def afterSetUp(self): 
     
    394431 
    395432 
    396 class TestOFFModerationOFFAnonymComm(TestCommBase, TestMixinAnonymOff, TestMixinModerationOff): 
     433class TestOFFModerationOFFAnonymComm(TestCommBase, TestMixinAnonymOff, 
     434                                     TestMixinModerationOff): 
    397435 
    398436    def afterSetUp(self): 
  • quintagroup.plonecomments/trunk/quintagroup/plonecomments/tests/testQPloneCommentsConfiglet.py

    r3118 r3126  
    1616    self.membership = getToolByName(self.portal, 'portal_membership', None) 
    1717    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'], []) 
    1920 
    2021    # Add users to Discussion Manager group 
     
    4041        # Make sure Documents are visible by default 
    4142        # 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') 
    4345 
    44         portal_properties = getToolByName(self.portal, 'portal_properties', None) 
     46        portal_properties = getToolByName(self.portal, 'portal_properties', 
     47                                          None) 
    4548        self.prefs = portal_properties[PROPERTY_SHEET] 
    4649        self.request = self.app.REQUEST 
    4750 
    4851        # 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                                                []) 
    5054        portal_groups = getToolByName(self.portal, 'portal_groups') 
    5155        dm_group = portal_groups.getGroupById('DiscussionManager') 
     
    5458        self.login('dm') 
    5559        # 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') 
    5762        member = self.portal.portal_membership.getAuthenticatedMember() 
    5863        member.setMemberProperties({'email': 'creator@test.com'}) 
     
    9499        # Create talkback for document and Add comment to my_doc 
    95100        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') 
    97102        # Check moderating discussion 
    98103        # MUST ALLOW for: members of 'DiscussionMnagers' group 
     
    102107            self.logout() 
    103108            self.login(u) 
    104             self.failUnless(getReplies(), 
    105                 "None discussion item added or discussion forbiden for %s user" % u) 
     109            self.failUnless(getReplies(), "None discussion item added or " 
     110                            "discussion forbiden for %s user" % u) 
    106111        for u in COMMON_USERS_IDS: 
    107112            self.logout() 
    108             if not u=='anonym': 
     113            if not u == 'anonym': 
    109114                self.login(u) 
    110115            noSecurityManager() 
    111             self.failIf(getReplies(), "Viewing discussion item allow for Anonymous user") 
     116            self.failIf(getReplies(), "Viewing discussion item allow for " 
     117                                      "Anonymous user") 
    112118 
    113119    def testSwitchOFFModeration(self): 
     
    118124        # Create talkback for document and Add comment to my_doc 
    119125        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() 
    121128        self.request.form['subject'] = "Reply 1" 
    122129        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') 
    124131        # Check moderating discussion 
    125132        # MUST ALLOW for: user with any role or Anonym 
     
    127134        for u in all_users_ids: 
    128135            self.logout() 
    129             if not u=='anonym': 
     136            if not u == 'anonym': 
    130137                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) 
    134142 
    135143    def testApproveNotification(self): 
     
    137145        self.request.form['enable_approve_notification'] = 'True' 
    138146        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, 
    140149            "Approve Notification not terned ON") 
    141150 
     
    144153            del self.request.form['enable_approve_notification'] 
    145154        self.portal.prefs_comments_setup() 
    146         self.failUnless(self.prefs.getProperty('enable_approve_notification')==0, 
     155        self.failUnless(getProperty('enable_approve_notification') == 0, 
    147156            "Approve Notification not terned OFF") 
    148157 
     
    151160        self.request.form['enable_published_notification'] = 'True' 
    152161        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, 
    154164            "Published Notification not terned ON") 
    155165 
     
    158168            del self.request.form['enable_published_notification'] 
    159169        self.portal.prefs_comments_setup() 
    160         self.failUnless(self.prefs.getProperty('enable_published_notification')==0, 
     170        self.failUnless(getProperty('enable_published_notification') == 0, 
    161171            "Published Notification not terned OFF") 
    162172 
  • quintagroup.plonecomments/trunk/quintagroup/plonecomments/tests/testQPloneCommentsInstall.py

    r3118 r3126  
    2525    def test_configlet_install(self): 
    2626        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()], 
    2829            'Configlet %s is not registered.' % CONFIGLET_ID) 
    2930 
    3031    def test_skins_install(self): 
    31         skinstool=getToolByName(self.portal, 'portal_skins') 
     32        skinstool = getToolByName(self.portal, 'portal_skins') 
    3233        self.failUnless(PRODUCT_SKIN_NAME in skinstool.objectIds(), 
    3334                'There is no %s folder in portal_skins.' % PRODUCT_SKIN_NAME) 
     
    3536            path = skinstool.getSkinPath(skin) 
    3637            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)) 
     38            self.failUnless(PRODUCT_SKIN_NAME in layers, '%s layer is not ' 
     39                            'registered for %s.' % (PRODUCT_SKIN_NAME, skin)) 
    3940 
    4041    def test_layer_install(self): 
     
    4546 
    4647    def test_propertysheet_install(self): 
    47         portal_properties = getToolByName(self.portal, 'portal_properties', None) 
     48        portal_properties = getToolByName(self.portal, 'portal_properties', 
     49                                          None) 
    4850        self.failUnless(PROPERTY_SHEET in portal_properties.objectIds(), 
    4951            '%s properies not found in portal_properties.' % PROPERTY_SHEET) 
    5052        property_ids = portal_properties[PROPERTY_SHEET].propertyIds() 
    5153        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)) 
    5356        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)) 
    5559        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)) 
    5762        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)) 
    5965        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)) 
    6168        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)) 
    6371        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)) 
    6574        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)) 
    6777        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)) 
    6980        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)) 
    7183 
    7284    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)] 
    7487        self.failIf(roles == [], '%s not installed.' % PERM_NAME) 
    7588 
  • quintagroup.plonecomments/trunk/quintagroup/plonecomments/tests/testQPloneCommentsModeration.py

    r3114 r3126  
    2828 
    2929        # 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') 
    3132 
    3233        # 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. 
    3436        self.discussion = getToolByName(self.portal, 'portal_discussion', None) 
    3537        all_users_id = DM_USERS_IDS + COMMON_USERS_IDS 
     
    3840            self.portal.invokeFactory('Document', id=doc_id) 
    3941            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) 
    4144            # Create talkback for document and Add comment to doc_obj 
    4245            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) 
    4448 
    4549    ## TEST VIEWING 
     
    5862        # All common users SHOULD NOT VIEW NOT PUBLISHED comments 
    5963        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'])] 
    6373        for u in users_without_md_perm: 
    6474            self.logout() 
    65             if not u=='anonym': 
     75            if not u == 'anonym': 
    6676                self.login(u) 
    6777            replies = self.discussion.getDiscussionFor(doc).getReplies() 
     
    8191        for u in all_users_id: 
    8292            self.logout() 
    83             if not u=='anonym': 
     93            if not u == 'anonym': 
    8494                self.login(u) 
    8595            replies = self.discussion.getDiscussionFor(doc).getReplies() 
     
    92102        # Publish button MUST BE ABSENT in document view form 
    93103        # 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'])] 
    98114        for u in users_without_md_perm: 
    99115            self.logout() 
    100116            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 without Moderate 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) 
    109125 
    110126    """ 
     
    113129        # Pattern for publish button presence checking 
    114130        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) 
    116133        for u in DM_USERS_IDS: 
    117134            self.login(u) 
     
    120137            html = str(self.publish(self.portal.id+'/%s' % doc_id, auth)) 
    121138            m = pattern.match(html) 
    122             self.failUnless(m, 
    123                 "Publish button NOT PRESENT for %s - member of DiscussionManager group" % u) 
     139            self.failUnless(m, "Publish button NOT PRESENT for %s - member " 
     140                               "of DiscussionManager group" % u) 
    124141    """ 
    125142 
     
    127144        # Check whether perform real publishing 
    128145        # 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) 
    130147        for u in DM_USERS_IDS: 
    131148            doc_id = "doc_%s" % u 
     
    134151            # Check whether anonymous get no reply 
    135152            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) 
    141160            getReplies()[0].discussion_publish_comment() 
    142161            # Check if Publish button still present in document view page 
    143162            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 - DiscussionManager role 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) 
    150169            # Check whether Anonym view published reply 
    151170            self.logout() 
     
    158177    def testViewDeleteButtonNonDMUsers(self): 
    159178        # 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. 
    162183        # Publish replies 
    163184        self.logout() 
     
    169190            reply.discussion_publish_comment() 
    170191        # 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) 
    172194        for u in COMMON_USERS_IDS: 
    173195            self.logout() 
     
    180202            m = pattern.match(html) 
    181203            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 document view 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) 
    185207            else: 
    186                 self.failIf(m, 
    187                     "%s - user without Manager role CAN VIEW Delete reply button for " 
    188                     "published reply on document view 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) 
    189211    """ 
    190212 
    191213    def testDeleting(self): 
    192214        # 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. 
    194217        # Get Managers 
    195218        managers = [u for u in USERS.keys() if 'Manager' in USERS[u]['roles']] 
     
    207230            doc_obj = getattr(self.portal, doc_id) 
    208231            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) 
    210234            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) 
    212237 
    213238 
  • quintagroup.plonecomments/trunk/quintagroup/plonecomments/tests/testQPloneCommentsNotification.py

    r3120 r3126  
    1212from quintagroup.plonecomments.tests.config import PROPERTY_SHEET 
    1313 
    14 REXP_TO = re.compile("To:\s*(.*?)$",re.M) 
    15 REXP_SUBJ = re.compile("Subject:\s*(.*?)$",re.M) 
     14REXP_TO = re.compile("To:\s*(.*?)$", re.M) 
     15REXP_SUBJ = re.compile("Subject:\s*(.*?)$", re.M) 
    1616 
    1717 
    1818class TestNotification(FunctionalTestCase): 
    1919 
    20     def setApprovePublished(self, swithA=1,swithP=1): 
     20    def setApprovePublished(self, swithA=1, swithP=1): 
    2121        self.prefs._updateProperty('enable_approve_notification', swithA) 
    2222        self.prefs._updateProperty('enable_published_notification', swithP) 
     
    4343        # Make sure Documents are visible by default 
    4444        # 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) 
    4850        self.prefs = portal_properties[PROPERTY_SHEET] 
    4951 
    5052        # 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                                                []) 
    5255        portal_groups = getToolByName(self.portal, 'portal_groups') 
    5356        dm_group = portal_groups.getGroupById('DiscussionManager') 
     
    5760        # For prepare mail sending - enter an e-mail adress 
    5861        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') 
    6064        member = self.portal.portal_membership.getAuthenticatedMember() 
    61         member.setMemberProperties({'email':'creator@test.com'}) 
     65        member.setMemberProperties({'email': 'creator@test.com'}) 
    6266 
    6367        # Add testing document to portal 
     
    6872        self.discussion.getDiscussionFor(self.my_doc) 
    6973        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() 
    7176        self.request.form['subject'] = "Reply 1" 
    7277        self.request.form['body_text'] = "text of reply" 
     
    7681    def test_bug_parent_reply(self): 
    7782        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] 
    8087        parent_reply.discussion_reply('reply', 'text') 
    8188 
    8289    def test_bug_mistakable_names(self): 
    8390        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]} 
    92101 
    93102        msg = getMsg(self.portal, 'reply_notify_template', args) 
     
    103112        self.portal.MailHost.reset() 
    104113        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.') 
    107118 
    108119    def test_published_comment_notification(self): 
    109120        self.portal.MailHost.reset() 
    110121        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.') 
    113126 
    114127    def test_approve_comment_notification(self): 
    115128        self.portal.MailHost.reset() 
    116129        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.') 
    119134 
    120135    def test_reply_comment_user_notification(self): 
    121136        self.portal.MailHost.reset() 
    122137        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') 
    128146        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.') 
    130149 
    131150    def test_rejected_comment_notification(self): 
    132151        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.') 
    136158 
    137159        reply = self.discussion.getDiscussionFor(self.my_doc).getReplies()[0] 
    138160        self.portal.REQUEST.set('ids', [reply.getId()]) 
    139161        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.') 
    141164 
    142165    def test_approve_comment_user__notification(self): 
    143166        self.portal.MailHost.reset() 
    144167        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.') 
    147172 
    148173    def test_bug_notification_on_single_reply_publish(self): 
     
    152177                             for document creator about adding new comment. 
    153178        """ 
    154         properties = ['enable_approve_user_notification', 'enable_reply_user_notification', 
     179        properties = ['enable_approve_user_notification', 
     180                      'enable_reply_user_notification', 
    155181                      'enable_published_notification'] 
    156182        setProperties(self.prefs, *properties) 
    157183        #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') 
    161189        reply2 = self.discussion.getDiscussionFor(reply).getReplies()[0] 
    162190 
     
    164192        reply2.discussion_publish_comment() 
    165193        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)], 
    167199            '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)], 
    169203            '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)], 
    171207            'No notification for publishing comment.' % properties) 
    172208 
     
    175211            Mail about rejecing comment should be sent to comentator. 
    176212        """ 
    177         properties = ['enable_rejected_user_notification',] 
     213        properties = ['enable_rejected_user_notification', ] 
    178214        setProperties(self.prefs, *properties) 
    179215        #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') 
    181218        reply = self.discussion.getDiscussionFor(self.my_doc).getReplies()[0] 
    182219 
     
    185222        mails = [str(m) for m in self.portal.MailHost.messages] 
    186223        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], 
    188229            'No notification for rejecting comment.' % properties) 
    189230 
  • quintagroup.plonecomments/trunk/quintagroup/plonecomments/tests/testQPloneCommentsNotificationRecipients.py

    r3116 r3126  
    1212 
    1313USERS = {   # 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']}, 
    1818            # Members for discussion manager group 
    19          'dm_admin':{'passw': 'secret_dm_admin', 'roles': ['Manager']}, 
     19         'dm_admin': {'passw': 'secret_dm_admin', 'roles': ['Manager']}, 
    2020        } 
    2121DM_USERS_IDS = [u for u in USERS.keys() if u.startswith('dm_')] 
    2222 
    23 REXP_TO = re.compile("To:\s*(.*?)$",re.M) 
    24 REXP_SUBJ = re.compile("Subject:\s*(.*?)$",re.M) 
     23REXP_TO = re.compile("To:\s*(.*?)$", re.M) 
     24REXP_SUBJ = re.compile("Subject:\s*(.*?)$", re.M) 
    2525 
    2626 
     
    3131        self.login(member_id) 
    3232        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 
    3537        self.request.form['body_text'] = "text of reply" 
    3638 
     
    5759        # Make sure Documents are visible by default 
    5860        # 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) 
    6165        self.prefs = portal_properties[PROPERTY_SHEET] 
    6266 
     
    6670        self.createMemberarea('owner') 
    6771 
    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 
    6974        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') 
    7481        self.prefs._updateProperty('email_subject_prefix', 'PREFIX') 
    7582 
    7683        # Add testing document to portal 
    7784        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") 
    7987        self.my_doc = self.portal.Members['owner']['my_doc'] 
    8088        self.my_doc.edit(text_format='plain', text='hello world') 
     
    8593 
    8694    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)) 
    91107 
    92108    def test_Reply(self): 
    93109        self.portal.MailHost.reset() 
    94110        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') 
    96113        mails = self.portal.MailHost.messages 
    97114        self.assertEqual(len(mails), 1) 
     
    101118    def test_PublishReply(self): 
    102119        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') 
    104122        self.login('dm_admin') 
    105123        reply = self.discussion.getDiscussionFor(self.my_doc).getReplies()[0] 
     
    108126        mails = self.portal.MailHost.messages 
    109127        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') 
    112132 
    113133    def test_Publish2ndReply(self): 
    114134        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') 
    116137        self.login('dm_admin') 
    117138        reply = self.discussion.getDiscussionFor(self.my_doc).getReplies()[0] 
    118139        reply.discussion_publish_comment() 
    119140        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') 
    121143        self.login('dm_admin') 
    122144        reply2 = self.discussion.getDiscussionFor(reply).getReplies()[0] 
     
    125147        mails = self.portal.MailHost.messages 
    126148        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') 
    130155 
    131156    def test_DeleteReply(self): 
    132157        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') 
    134160        self.login('dm_admin') 
    135161        reply = self.discussion.getDiscussionFor(self.my_doc).getReplies()[0] 
     
    138164        mails = self.portal.MailHost.messages 
    139165        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') 
    141168 
    142169 
  • quintagroup.plonecomments/trunk/quintagroup/plonecomments/tests/testQPloneCommentsReportAbuse.py

    r3120 r3126  
    2121            doc_obj.report_abuse("Anonymous Report Abuse") 
    2222        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*." 
    2425 
    2526    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'] 
    2728        failed_users = [] 
    2829        for u in not_anonym_users: 
     
    3940                failed_users.append(u) 
    4041 
    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) 
    4244 
    4345 
  • quintagroup.plonecomments/trunk/quintagroup/plonecomments/tests/testQPloneCommentsUninstall.py

    r3112 r3126  
    2626 
    2727    def test_skins_uninstall(self): 
    28         skinstool=getToolByName(self.portal, 'portal_skins') 
     28        skinstool = getToolByName(self.portal, 'portal_skins') 
    2929        self.failIf(PRODUCT_SKIN_NAME in skinstool.objectIds(), 
    3030            'There is still %s folder in portal_skins.' % PRODUCT_SKIN_NAME) 
     
    3838        from plone.browserlayer.utils import registered_layers 
    3939        from quintagroup.plonecomments.interfaces import IPloneCommentsLayer 
    40         self.failIf(IPloneCommentsLayer in registered_layers(), 
    41             '%s layer found after uninstallation.' % IPloneCommentsLayer.getName()) 
     40        self.failIf(IPloneCommentsLayer in registered_layers(), '%s layer ' 
     41            'found after uninstallation.' % IPloneCommentsLayer.getName()) 
    4242 
    4343    def test_configlet_uninstall(self): 
    4444        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()], 
    4647            'Configlet %s found after uninstallation.' % CONFIGLET_ID) 
    4748 
     
    4950        portal_properties = getToolByName(self.portal, 'portal_properties') 
    5051        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 
    5255 
    5356def test_suite(): 
  • quintagroup.plonecomments/trunk/quintagroup/plonecomments/tests/tests.py

    r3114 r3126  
    55#from Testing import ZopeTestCase as ztc 
    66#from base import TestCase 
     7 
    78 
    89def test_suite(): 
Note: See TracChangeset for help on using the changeset viewer.