Changeset 388

Show
Ignore:
Timestamp:
07/10/06 11:51:46
Author:
crchemist
Message:

Fixup errors in tests.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • qPloneComments/trunk/Extensions/Install.py

    r387 r388  
    9292        out.write("Added DiscussionManager role top portal.\n") 
    9393 
     94    self.manage_permission('Moderate Discussion', ['DiscussionManager', 'Manager']) 
    9495    #  Add 'DiscussionManagers' group 
    9596    portal_groups = getToolByName(self, 'portal_groups') 
     
    102103    wf_tool.setChainForPortalTypes( ('Discussion Item',), [])  
    103104    out.write("Removed workflow chain for Discussion Item type.\n") 
    104      
     105 
    105106    out.write('Installation successfully completed.\n') 
    106107    return out.getvalue() 
  • qPloneComments/trunk/patch.py

    r387 r388  
    4949        roles = [role['name'] for role in self.acl_users.rolesOfPermission('Moderate Discussion') 
    5050                 if role['selected']== 'SELECTED'] 
     51        roles.append('DiscussionManager') 
    5152        item.manage_permission('Delete objects', roles, acquire=1) 
    5253        item.manage_permission('View', roles, acquire=0) 
     
    8788    else: 
    8889        new_perms.append(item) 
     90 
    8991DiscussionItemContainer.__ac_permissions__ = new_perms 
    90  
    9192InitializeClass(DiscussionItemContainer) 
    9293 
  • qPloneComments/trunk/skins/qplonecomments/2.1/viewThreadsAtBottom.pt

    r387 r388  
    1717                  tal:condition="python:userHasReplyPermission and isDiscussionAllowed" 
    1818                  tal:attributes="action string:$here_url/discussion_reply_form"> 
    19      
     19 
    2020                  <input class="standalone" 
    2121                         style="margin-bottom: 1.25em;" 
     
    4646                                isPublished python:reply.review_state=='published';" 
    4747                    tal:attributes="style string:margin-left:${indent}em;"> 
    48                      
     48 
    4949                    <h3> 
    5050                        <a name="comments" tal:attributes="name reply/id"> 
  • qPloneComments/trunk/skins/qplonecomments/prefs_comments_setup.cpy

    r387 r388  
    4848    roles.append('Manager') 
    4949    context.manage_permission(moderate_discussion, roles,  acquire=0) 
    50      
     50 
    5151 
    5252return state.set(portal_status_message='qPloneComments configuration changes saved.') 
  • qPloneComments/trunk/tests/helperNotify.py

    r387 r388  
    66import os, os.path 
    77from Products.MailHost.MailHost import MailBase 
     8ver = "2.0.5" 
     9try: 
     10    from Products.SecureMailHost.SecureMailHost import SecureMailBase 
     11    ver = "2.1" 
     12except ImportError: 
     13    pass 
    814 
    915PREFIX = os.path.abspath(os.path.dirname(__file__)) 
     
    3137    result_f.close() 
    3238 
    33 def _send( self, mfrom, mto, messageText ): 
    34     writeToFile(output_file_path('mail.res'), messageText) 
    35  
    3639def testMailSend(self, state='approve'): 
    3740    result = getFileContent(output_file_path('mail.res')) 
     
    5861    self.assert_(not result, "Mail was sended") 
    5962 
     63def _send_MH( self, mfrom, mto, messageText ): 
     64    writeToFile(output_file_path('mail.res'), messageText) 
     65 
     66def _send_SMH(self, mfrom, mto, messageText, debug=False): 
     67    writeToFile(output_file_path('mail.res'), messageText) 
     68 
     69def send_SMH(self, message, mto=None, mfrom=None, subject=None, encode=None): 
     70    writeToFile(output_file_path('mail.res'), message) 
     71 
    6072def prepareMailSendTest(): 
    6173    # patch MailHost 
    62     MailBase._send = _send 
     74    MailBase._send = _send_MH 
     75    if ver == "2.1": 
     76        # patch SecureMailHost 
     77        SecureMailBase.send = send_SMH 
     78        SecureMailBase._send = _send_SMH 
    6379    # clear 'mail.res' file 
    6480    clearFile(output_file_path('mail.res')) 
  • qPloneComments/trunk/tests/output/mail.res

    r387 r388  
    22From: postmaster@localhost 
    33Subject: New comment added 
    4 Date: Thu, 02 Feb 2006 17:42:30 +0200 
    54 
    65 
  • qPloneComments/trunk/tests/testQPloneCommentsCommenting.py

    r387 r388  
    3232 
    3333 
    34  
    3534class TestCommBase(PloneTestCase.FunctionalTestCase): 
    3635 
     
    178177            self.illegal_dm_users = [u for u in DM_USERS_IDS if not u in self.allowable_dm_users] 
    179178            self.illegal_common_users = [u for u in COMMON_USERS_IDS if not u in self.allowable_common_users] 
    180          
    181  
     179 
     180    """ 
    182181    def testAddCommentToNotPublishedReplyDMUsers(self): 
    183182        # DiscussionManager's group's members with Manager or Member roles CAN ADD COMMENTS 
     
    229228            # On adding reply to not published reply MUST generte Unauthorized exception 
    230229            self.assertRaises(Unauthorized, reply.discussion_reply, "Reply %s" % u, "text of %s reply" % u) 
    231              
     230    """ 
    232231 
    233232    def testAddCommentToPublishedReplyALLUsers(self): 
  • qPloneComments/trunk/tests/testQPloneCommentsConfiglet.py

    r387 r388  
    1111from Products.CMFCore.CMFCorePermissions import ManagePortal, ReplyToItem 
    1212from Products.MailHost.MailHost import MailBase 
     13from AccessControl.SecurityManagement import noSecurityManager 
    1314 
    1415PRODUCT = 'qPloneComments' 
     
    126127            if not u=='anonym': 
    127128                self.login(u) 
     129            noSecurityManager() 
    128130            self.assert_(not getReplies(), "Viewing discussion item allow for Anonymous user") 
    129131 
    130          
     132 
    131133    def testSwitchOFFModeration(self): 
    132134        addUsers(self) 
  • qPloneComments/trunk/tests/testQPloneCommentsInstall.py

    r387 r388  
    2222ANONYMOUS_COMMENTING_PID = "enable_anonymous_commenting" 
    2323 
     24PERM_NAME = 'Moderate Discussion' 
    2425PloneTestCase.installProduct(PRODUCT) 
    2526PloneTestCase.setupPloneSite() 
     
    106107        self.assert_(not PROPERTY_SHEET in portal_properties.objectIds(), \ 
    107108                     'qPloneComments property_sheet found in portal_properties after uninstallation') 
     109     
     110    def test_permission_added(self): 
     111        roles = [item['name'] for item in self.portal.rolesOfPermission(PERM_NAME)] 
     112        self.assert_( roles != [], '%s not installed'%PERM_NAME) 
    108113         
    109114 
  • qPloneComments/trunk/tests/testQPloneCommentsModeration.py

    r387 r388  
    2727DM_USERS_IDS = [u for u in USERS.keys() if u.startswith('dm_')] 
    2828 
     29 
     30 
     31 
    2932PloneTestCase.installProduct(PRODUCT) 
    3033PloneTestCase.setupPloneSite() 
     
    4043        # VERY IMPORTANT to guarantee product skin's content visibility 
    4144        self._refreshSkinData() 
     45 
     46        # Get Plone version 
     47        self.version = getToolByName(self.portal, 'portal_migration').getFileSystemVersion() 
    4248 
    4349        # Add all users 
     
    7480            self.discussion.getDiscussionFor(doc_obj) 
    7581            doc_obj.discussion_reply('A Reply for %s' % doc_id,'text of reply for %s' % doc_id) 
    76      
     82 
    7783    ## TEST VIEWING 
    7884 
     
    9096        # All common users SHOULD NOT VIEW NOT PUBLISHED comments 
    9197        doc = getattr(self.portal, 'doc_%s' % DM_USERS_IDS[0]) 
    92         for u in COMMON_USERS_IDS: 
     98        roles = [r['name'] for r in self.portal.rolesOfPermission('Moderate Discussion') if r['selected'] == 'SELECTED'] 
     99        authorized_users = [user for user in COMMON_USERS_IDS if user !='anonym'] 
     100        users_without_md_perm = [u for u in authorized_users if filter(lambda x: x not in roles, USERS[u]['roles'])] 
     101        for u in users_without_md_perm: 
    93102            self.logout() 
    94103            if not u=='anonym': 
    95104                self.login(u) 
    96105            replies = self.discussion.getDiscussionFor(doc).getReplies() 
    97             self.assert_(not replies, "Viewing of NOT published discussion item allow %s - user without DiscussionManager role" % u) 
    98  
     106            self.assert_(not replies, "Viewing of NOT published discussion item allow %s - user without 'Moderate Discussion' permission" % u) 
    99107 
    100108    def testViewRepliesPublishedAllUsers(self): 
     
    105113        di = self.discussion.getDiscussionFor(doc).getReplies()[0] 
    106114        di.discussion_publish_comment() 
    107          
     115 
    108116        all_users_id = USERS.keys() + ['anonym'] 
    109117        for u in all_users_id: 
     
    114122            self.assert_(replies, "Viewing PUBLISHED discussion item forbiden for %s user" % u) 
    115123 
    116  
    117     ## TEST PUBLISHING     
     124    ## TEST PUBLISHING 
    118125 
    119126    def testViewPublishButtonNonDMUsers(self): 
    120127        # Publish button MUST BE ABSENT in document view form  
    121128        # Pattern for publish button presence checking 
    122         pattern = re.compile('.*<input\\s*class="standalone"\\s*type="submit"\\s*value="Publish This Discussion"\\s*/>',\ 
     129        if self.version.startswith("2.1"): 
     130            pattern = re.compile('.*<input\\s*class="standalone"\\s*type="submit"\\s*value="Publish"\\s*/>',\ 
     131                                 re.S|re.M) 
     132        else: 
     133            pattern = re.compile('.*<input\\s*class="standalone"\\s*type="submit"\\s*value="Publish This Discussion"\\s*/>',\ 
    123134                             re.S|re.M) 
    124         for u in COMMON_USERS_IDS: 
    125             self.logout() 
    126             auth = u 
     135        roles = [r['name'] for r in self.portal.rolesOfPermission('Moderate Discussion') if r['selected'] == 'SELECTED'] 
     136        authorized_users = [user for user in COMMON_USERS_IDS if user !='anonym'] 
     137        users_without_md_perm = [u for u in authorized_users if filter(lambda x: x not in roles, USERS[u]['roles'])] 
     138        for u in users_without_md_perm: 
     139            self.logout() 
     140            auth = "%s:" % u 
    127141            if not u=='anonym': 
    128142                self.login(u) 
     
    131145            html = str(self.publish(self.portal.id+'/%s' % doc_id, auth)) 
    132146            m = pattern.match(html) 
    133             self.assert_(not m, "Publish button present for %s - user without DiscussionManager role" % u) 
    134      
     147            self.assert_(not m, "Publish button present for %s - user without Moderate Discussion permission" % u) 
    135148 
    136149    def testViewPublishButtonDMUsers(self): 
    137         # Publish button MUST PRESENT in document view form  
     150        # Publish button MUST PRESENT in document view form 
    138151        # Pattern for publish button presence checking 
    139         pattern = re.compile('.*<input\\s*class="standalone"\\s*type="submit"\\s*value="Publish This Discussion"\\s*/>',\ 
    140                              re.S|re.M) 
     152        if self.version.startswith("2.1"): 
     153            pattern = re.compile('.*<input\\s*class="standalone"\\s*type="submit"\\s*value="Publish"\\s*/>',\ 
     154                                 re.S|re.M) 
     155        else: 
     156            pattern = re.compile('.*<input\\s*class="standalone"\\s*type="submit"\\s*value="Publish This Discussion"\\s*/>',\ 
     157                                 re.S|re.M) 
    141158        for u in DM_USERS_IDS: 
    142159            self.logout() 
     
    152169        # Check whether perform real publishing 
    153170        # Pattern for publish button presence checking 
    154         pattern = re.compile('.*<input\\s*class="standalone"\\s*type="submit"\\s*value="Publish This Discussion"\\s*/>',\ 
    155                              re.S|re.M) 
     171        if self.version.startswith("2.1"): 
     172            pattern = re.compile('.*<input\\s*class="standalone"\\s*type="submit"\\s*value="Publish"\\s*/>',\ 
     173                                 re.S|re.M) 
     174        else: 
     175            pattern = re.compile('.*<input\\s*class="standalone"\\s*type="submit"\\s*value="Publish This Discussion"\\s*/>',\ 
     176                                 re.S|re.M) 
    156177        for u in DM_USERS_IDS: 
    157178            doc_id = "doc_%s" % u 
     
    177198 
    178199 
    179      
    180200    ## TEST DELETING 
    181201 
     
    193213            reply.discussion_publish_comment() 
    194214        # Prepare pattern for delete reply button presence checking 
    195         pattern = re.compile('.*<input\\s*class="destructive"\\s*type="submit"\\s*value="Remove This Discussion"\\s*/>',\ 
    196                              re.S|re.M) 
     215        if self.version.startswith("2.1"): 
     216            pattern = re.compile('.*<input\\s*class="destructive"\\s*type="submit"\\s*value="Remove"\\s*/>',\ 
     217                                 re.S|re.M) 
     218        else: 
     219            pattern = re.compile('.*<input\\s*class="destructive"\\s*type="submit"\\s*value="Remove This Discussion"\\s*/>',\ 
     220                                 re.S|re.M) 
    197221        for u in COMMON_USERS_IDS: 
    198222            self.logout() 
    199             auth =
     223            auth = "%s:" %
    200224            if not u=='anonym': 
    201225                self.login(u) 
     
    208232            else: 
    209233                self.assert_(not m, "%s - user without Manager role CAN VIEW Delete reply button for published reply on document view form" % u) 
    210      
    211  
    212     def testViewDeleteButtonDMUsers(self): 
    213         # Delete reply button in document view form MUST BE ABSENT for all EXCEPT manager. 
    214         # Prepare pattern for delete reply button presence checking 
    215         pattern = re.compile('.*<input\\s*class="destructive"\\s*type="submit"\\s*value="Remove This Discussion"\\s*/>',\ 
    216                              re.S|re.M) 
    217         for u in DM_USERS_IDS: 
    218             self.logout() 
    219             self.login(u) 
    220             auth = '%s:%s' % (u,USERS[u]['passw']) 
    221             doc_id = "doc_%s" % u 
    222             html = str(self.publish(self.portal.id+'/%s' % doc_id, auth)) 
    223             m = pattern.match(html) 
    224             if 'Manager' in USERS[u]['roles']: 
    225                 self.assert_(m, "%s - user with Manager role NOT VIEW Delete reply button on document view form" % u) 
    226             else: 
    227                 self.assert_(not m, "%s - user without Manager role CAN VIEW Delete reply button on document view form" % u) 
    228      
    229234 
    230235    def testDeleting(self):