Changeset 2474


Ignore:
Timestamp:
11/15/07 11:42:46 (8 years ago)
Author:
ems174@…
Message:

Fixing some unintentionally-committed code from [2467]. Fixed 4 tests to cover the changes to the committee and classification workflows.

Location:
weblion/FacultyStaffDirectory/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • weblion/FacultyStaffDirectory/trunk/Committee.py

    r2468 r2474  
    1515from Products.CMFCore.utils import getToolByName 
    1616from Products.membrane.interfaces import IPropertiesProvider, ICategoryMapper 
    17 from Products.FacultyStaffDirectory.interfaces.committee import ICommittee, ICommitteeExtender, ICommitteeModifiedEvent 
     17from Products.FacultyStaffDirectory.interfaces.committee import ICommittee, ICommitteeExtender 
    1818from Acquisition import aq_inner, aq_parent 
    1919from Products.FacultyStaffDirectory.permissions import ASSIGN_COMMITTIES_TO_PEOPLE, CHANGE_ROLES 
     
    4242 
    4343Committee_schema = getattr(PersonGrouping, 'schema', Schema(())).copy() + schema.copy() 
    44  
    45 class CommitteeModifiedEvent(object): 
    46     """Event that happens when edits to a Committee have been saved""" 
    47     implements(ICommitteeModifiedEvent) 
    48  
    49     def __init__(self, context): 
    50         self.context = context 
    5144 
    5245class Committee(PersonGrouping): 
     
    8275    # Methods 
    8376    security.declareProtected(View, 'at_post_create_script') 
    84     def at_post_create_script(self): 
    85         """Notify that the Person has been modified. 
    86         """ 
    87         notify(CommitteeModifiedEvent(self)) 
    8877 
    89     security.declareProtected(View, 'at_post_edit_script') 
    90     def at_post_edit_script(self): 
    91         """Notify that the Person has been modified. 
    92         """ 
    93         notify(CommitteeModifiedEvent(self)) 
    94  
     78    security.declareProtected(View, 'getMembershipInformation') 
    9579    def getMembershipInformation(self, person): 
    9680        """ Get the committee membership information for a specific person 
  • weblion/FacultyStaffDirectory/trunk/events/configure.zcml

    r2467 r2474  
    66  <subscriber for="..interfaces.person.IPersonModifiedEvent" 
    77              handler=".person.modifyPersonOwnership" /> 
    8   <subscriber for="..interfaces.committee.ICommitteeModifiedEvent" 
    9               handler=".committee.modifyCommitteeRoles" /> 
    108 
    119</configure> 
  • weblion/FacultyStaffDirectory/trunk/tests/testClassification.py

    r2451 r2474  
    4747        self.failUnless(g.Title()=='New Title',"IGroup.getTitle is not finding the correct title:\nexpected: %s\nfound: %s" % (self.classification.Title(),g.Title())) 
    4848         
    49         #roles are set on the object, but only available when object is published 
     49        #Let's start off with a deactivated object since we may want to change the default state at some point. 
     50        if wf.getInfoFor(self.classification, 'review_state') == 'active': 
     51            wf.doActionFor(self.classification,'deactivate') 
     52         
     53        #roles are set on the object, but only available when object is active 
    5054        self.classification.setRoles(('Reviewer',)) 
    5155        # at first, object is 'visible', but not published, roles should be empty 
    52         self.failIf('Reviewer' in g.getRoles(),"roles are active, but content unpublished\nRoles: %s\nReviewState: %s" % (g.getRoles(), wf.getInfoFor(self.classification,'review_state'))) 
    53         #publish object 
    54         wf.doActionFor(self.classification,'publish') 
     56        self.failIf('Reviewer' in g.getRoles(),"roles are active, but content deactivated\nRoles: %s\nReviewState: %s" % (g.getRoles(), wf.getInfoFor(self.classification,'review_state'))) 
     57        #make object 'active' 
     58        wf.doActionFor(self.classification,'activate') 
    5559        # now check again, role should be there 
    56         self.failUnless('Reviewer' in g.getRoles(),"Roles not active, but content published\nRoles: %s\nReviewState: %s" % (g.getRoles(), wf.getInfoFor(self.classification,'review_state'))) 
     60        self.failUnless('Reviewer' in g.getRoles(),"Roles not active, but content active\nRoles: %s\nReviewState: %s" % (g.getRoles(), wf.getInfoFor(self.classification,'review_state'))) 
    5761         
    5862        # group id is set on content object, uniqueness is enforced elsewhere 
     
    103107        #classify our test person 
    104108        self.person.setClassifications((self.classification,)) 
     109        #Let's start off with a deactivated object since we may want to change the default state at some point. 
     110        if wf.getInfoFor(self.classification, 'review_state') == 'active': 
     111            wf.doActionFor(self.classification,'deactivate') 
    105112         
    106113        user = self.portal.portal_membership.getMemberById('abc123') 
     
    113120        self.failIf('Reviewer' in user.getRolesInContext(self.portal),"roles from classification available on person, but classification unpublished %s" % user.getRolesInContext(self.portal)) 
    114121 
    115         wf.doActionFor(self.classification,'publish') 
     122        wf.doActionFor(self.classification,'activate') 
    116123        user = self.portal.portal_membership.getMemberById('abc123') 
    117124        self.failUnless('Reviewer' in user.getRolesInContext(self.portal),"roles from classification unavailable on person, but classification is published %s %s" % (user.getRolesInContext(self.portal),wf.getInfoFor(self.classification,'review_state'))) 
  • weblion/FacultyStaffDirectory/trunk/tests/testCommittee.py

    r2362 r2474  
    4646        self.committee.setTitle('New Title') 
    4747        self.failUnless(g.Title()=='New Title',"IGroup.getTitle is not finding the correct title:\nexpected: %s\nfound: %s" % (self.committee.Title(),g.Title())) 
    48          
    49         #roles are set on the object, but only available when object is published 
     48 
     49        #Let's start off with a deactivated object since we may want to change the default state at some point. 
     50        if wf.getInfoFor(self.committee, 'review_state') == 'active': 
     51            wf.doActionFor(self.committee,'deactivate') 
     52                 
     53        #roles are set on the object, but only available when object is active 
    5054        self.committee.setRoles(('Reviewer',)) 
    5155        # at first, object is 'visible', but not published, roles should be empty 
    52         self.failIf('Reviewer' in g.getRoles(),"roles are active, but content unpublished\nRoles: %s\nReviewState: %s" % (g.getRoles(), wf.getInfoFor(self.committee,'review_state'))) 
    53         #publish object 
    54         wf.doActionFor(self.committee,'publish') 
     56        self.failIf('Reviewer' in g.getRoles(),"roles are active, but content deactivated\nRoles: %s\nReviewState: %s" % (g.getRoles(), wf.getInfoFor(self.committee,'review_state'))) 
     57        #activate object 
     58        wf.doActionFor(self.committee,'activate') 
    5559        # now check again, role should be there 
    56         self.failUnless('Reviewer' in g.getRoles(),"Roles not active, but content published\nRoles: %s\nReviewState: %s" % (g.getRoles(), wf.getInfoFor(self.committee,'review_state'))) 
     60        self.failUnless('Reviewer' in g.getRoles(),"Roles not active, but content active\nRoles: %s\nReviewState: %s" % (g.getRoles(), wf.getInfoFor(self.committee,'review_state'))) 
    5761         
    5862        # group id is set on content object, uniqueness is enforced elsewhere 
     
    111115        self.person.setCommittees((self.committee,)) 
    112116         
     117        #Let's start off with a deactivated object since we may want to change the default state at some point. 
     118        if wf.getInfoFor(self.committee, 'review_state') == 'active': 
     119            wf.doActionFor(self.committee,'deactivate') 
     120 
    113121        user = self.portal.portal_membership.getMemberById('abc123') 
    114122        # no roles on directory yet, should not find one in the global roles for user 
     
    120128        # roles set,but directory is unpublished, should not find roles in global roles for user 
    121129        self.failIf('Reviewer' in user.getRolesInContext(self.portal), 
    122                     "roles from committee available on person, but committee unpublished %s" % user.getRolesInContext(self.portal)) 
     130                    "roles from committee available on person, but committee is inactive %s" % user.getRolesInContext(self.portal)) 
    123131 
    124         wf.doActionFor(self.committee,'publish') 
     132        wf.doActionFor(self.committee,'activate') 
    125133        user = self.portal.portal_membership.getMemberById('abc123') 
    126134        self.failUnless('Reviewer' in user.getRolesInContext(self.portal), 
    127                         "roles from committee unavailable on person, but committee is published %s %s" % (user.getRolesInContext(self.portal),wf.getInfoFor(self.committee,'review_state'))) 
     135                        "roles from committee unavailable on person, but committee is active %s %s" % (user.getRolesInContext(self.portal),wf.getInfoFor(self.committee,'review_state'))) 
    128136         
    129137    def testInvalidRolesUnavailable(self): 
  • weblion/FacultyStaffDirectory/trunk/tests/testPerson.py

    r2467 r2474  
    293293 
    294294    ## End tests for membrane stuff 
    295      
    296     def testUserPermissions(self): 
    297         """ Make sure permissions are working properly and that certain fields are only available to the user defined by the Person object. """ 
    298         self.loginAsPortalOwner() 
    299         self.anotherPerson = self.getPerson(id='bbb111', firstName="Another", lastName="Person", password="bbb111") 
    300         self.login('abc123') 
    301          
    302         user = IMembraneUserManagement(self.person); 
    303         auth = IUserAuthentication(self.person); 
    304         user.doChangeUser('bbb111', 'bbb111') 
    305  
    306          
    307          
    308         # A logged in user shouldn't be able to edit another Person without proper permissions. 
    309         try: 
    310             self.anotherPerson.base_edit() 
    311         except Unauthorized: 
    312             # Yup, that's what we want. 
    313             pass 
    314         else: 
    315             self.fail("User should not be able to edit another person without at least Editor role.") 
    316          
    317         #Make our user an Editor of anotherPerson 
    318         self.anotherPerson.manage_setLocalRoles('abc123', ['Editor']) 
    319         try: 
    320             html = self.anotherPerson.base_edit() 
    321         except Unauthorized: 
    322             self.fail("Users with the Editor role should be able to edit a Person object.") 
    323         else: 
    324             # Double-check to make sure our user is an Editor. 
    325             self.failUnlessEqual(self.anotherPerson.get_local_roles_for_userid('abc123'), ('Editor',)) 
    326             # Editor shouldn't be able to see the password field. 
    327             self.failIf('Password' in html, "Editor role is able to modify Person's password field.") 
    328             # Editor shouldn't be able to see any of the items in the User information schemata. 
    329             self.failIf('User information' in html, "Editor role is able to modify Person's user information fields.") 
    330          
    331         # Make sure the user defined by this Person can edit passwords and user settings. 
    332         self.login('bbb111') 
    333         try: 
    334             html = self.anotherPerson.base_edit() 
    335         except Unauthorized: 
    336             self.fail("User should be able to edit their own Person object.") 
    337         else: 
    338             # User should be able to see the password field. 
    339             self.failIf('Password' not in html, "User is unable to modify own password field.") 
    340             # Editor shouldn't be able to see any of the items in the User information schemata. 
    341             self.failIf('User information' not in html, "User is unable to modify own user information fields.") 
    342      
    343  
    344      
    345295 
    346296class testWithSpecialties(testPerson): 
Note: See TracChangeset for help on using the changeset viewer.