Changeset 13227


Ignore:
Timestamp:
24 Aug 2015, 20:57:19 (9 years ago)
Author:
Henrik Bettermann
Message:

Add some lines to test whether the global role map is now properly adjusted after removing applicants.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_browser.py

    r13219 r13227  
    2929from mechanize import LinkNotFoundError
    3030from zc.async.testing import wait_for_result
     31from zope.securitypolicy.interfaces import IPrincipalRoleManager
    3132from zope.event import notify
    3233from zope.catalog.interfaces import ICatalog
     
    438439
    439440    def test_add_delete_applicants(self):
     441        # Check the global role map first
     442        role_manager = IPrincipalRoleManager(grok.getSite())
     443        principals = role_manager.getPrincipalsForRole('waeup.Applicant')
     444        self.assertEqual(len(principals), 1)
     445        self.assertEqual(principals[0][0], self.applicant.applicant_id)
    440446        # Managers can add and delete applicants
    441447        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     
    452458        self.browser.getControl("Create application record").click()
    453459        self.assertTrue('Application initialized' in self.browser.contents)
     460        # The global role map has been extended
     461        role_manager = IPrincipalRoleManager(grok.getSite())
     462        principals = role_manager.getPrincipalsForRole('waeup.Applicant')
     463        self.assertEqual(len(principals), 2)
    454464        self.browser.open(self.container_manage_path)
    455465        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    456466        ctrl = self.browser.getControl(name='val_id')
    457467        value = ctrl.options[0]
     468        self.assertEqual(principals[1][0].split('_')[1], value)
    458469        ctrl.getControl(value=value).selected = True
    459470        self.browser.getControl("Remove selected", index=0).click()
    460471        self.assertTrue('Successfully removed:' in self.browser.contents)
     472        # The global role map has been reduced
     473        role_manager = IPrincipalRoleManager(grok.getSite())
     474        principals = role_manager.getPrincipalsForRole('waeup.Applicant')
     475        self.assertEqual(len(principals), 1)
    461476        self.browser.open(self.add_applicant_path)
    462477        self.browser.getControl(name="form.firstname").value = 'Albert'
Note: See TracChangeset for help on using the changeset viewer.