Changeset 2479


Ignore:
Timestamp:
11/15/07 19:15:01 (7 years ago)
Author:
cxe5014@…
Message:

Wrote three tests to cover potential problems in fsdMyFolder, fsdMemberProfile and fsdShowMyFolder. Also made sure to cover regresseion on #396

File:
1 edited

Legend:

Unmodified
Added
Removed
  • weblion/FacultyStaffDirectory/trunk/tests/testFacultyStaffDirectoryTool.py

    r2449 r2479  
    2626        self.person = self.getPerson(id='abc123', firstName="Test", lastName="Person") 
    2727        self.fsd_tool = getToolByName(self.person,TOOLNAME) 
     28        # set up an additional, non-fsd user for testing folder and profile methods 
     29        self.portal.acl_users._doAddUser('user1','secret',['Member'],[]) 
     30        self.mt = getToolByName(self.person,'portal_membership') 
    2831         
    2932    def testUseInternalPasswordControlsAuth(self): 
     
    8689        self.failUnlessEqual(self.fsd_tool.getDirectoryRoot(), None) 
    8790         
     91    def testFsdMyFolder(self): 
     92        """fsdMyFolder method should return the appropriate url for non-fsd users or  
     93        for fsd users 
     94        """ 
     95        self.login(self.person.id) 
     96        # logged in as an fsd user, the substring <directory_id/user_id> should be in the  return value for the function 
     97        self.failUnless(self.fsd_tool.fsdMyFolder().find(self.directory.id + '/' + self.person.id), "bad url returned for %s: %s" % (self.person.id, self.fsd_tool.fsdMyFolder())) 
     98        self.logout() 
     99         
     100        self.login('user1') 
     101        # set up a memberarea 
     102        if (not self.mt.getMemberareaCreationFlag()): 
     103            self.mt.setMemberareaCreationFlag() 
     104        self.mt.createMemberArea() 
     105        try: 
     106            self.failUnless(self.fsd_tool.fsdMyFolder().find(self.mt.getMembersFolder().id + '/user1'), "bad url returned for user1: %s" % self.fsd_tool.fsdMyFolder()) 
     107        except IndexError: 
     108            self.fail("Index Error indicates that there are no search results from the membrane tool") 
     109             
     110    def testFsdMemberProfile(self): 
     111        """fsdMemberProfile should return the location of the editor for member profile information. 
     112        This will change depending on whether the member is an fsd person or an acl_users member 
     113        """ 
     114        self.login(self.person.id) 
     115        # logged in as an fsd user, the substring <directory_id/user_id/edit> should be in the return value for the function 
     116        self.failUnless(self.fsd_tool.fsdMemberProfile().find(self.directory.id + '/' + self.person.id), "bad url returned for %s: %s" % (self.person.id, self.fsd_tool.fsdMemberProfile())) 
     117        self.logout() 
     118        # now as an acl_users user 
     119        self.login('user1') 
     120        try: 
     121            self.failUnless(self.fsd_tool.fsdMemberProfile().find('/personalize_form'), "bad url returned for user1: %s" % self.fsd_tool.fsdMyFolder()) 
     122        except IndexError: 
     123            self.fail("Index Error indicates that there are no search results from the membrane tool") 
     124             
     125    def testFsdShowMyFolder(self): 
     126        """fsdShowMyFolder tries to intelligently decide whether to show the 'my folder' action 
     127        button or not.  It tests to see if a member is an fsd person, and acts accordingly 
     128        """ 
     129        self.login(self.person.id) 
     130        # logged in as an fsd user, the method should always return true 
     131        self.failUnless(self.fsd_tool.fsdShowMyFolder, "fsdShowMyFolder returning false for fsd user") 
     132        self.logout 
     133        # now as acl_users user 
     134        self.login('user1') 
     135        try: 
     136            if (self.mt.getMemberareaCreationFlag() and (self.mt.getHomeFolder() is not None)): 
     137                self.failUnless(self.fsd_tool.fsdShowMyFolder, "should be showing my folder for acl_users, but we aren't") 
     138            else: 
     139                self.failIf(self.fsd_tool.fsdShowMyFolder, "should not be showing my folder for acl_users, but we are") 
     140        except IndexError: 
     141            self.fail("Index Error indicates that there are no search results from the membrane tool") 
     142         
    88143def test_suite(): 
    89144    from unittest import TestSuite, makeSuite 
Note: See TracChangeset for help on using the changeset viewer.