Ignore:
Timestamp:
21 Sep 2012, 06:10:00 (12 years ago)
Author:
Henrik Bettermann
Message:

Add StudyCourseCOEditFormPage (see Uniben ticket 626).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.uniben/trunk/src/waeup/uniben/students/tests/test_browser.py

    r9206 r9210  
    2020import tempfile
    2121from StringIO import StringIO
    22 from hurry.workflow.interfaces import IWorkflowState
     22from hurry.workflow.interfaces import IWorkflowState, IWorkflowInfo
     23from zope.securitypolicy.interfaces import IPrincipalRoleManager
    2324from zope.component.hooks import setSite, clearSite
    2425from zope.component import getUtility, createObject
    2526from zope.interface import verify
     27from zope.event import notify
     28from waeup.kofa.authentication import LocalRoleSetEvent
    2629from waeup.kofa.app import University
    2730from waeup.kofa.students.tests.test_browser import StudentsFullSetup
     
    372375        self.assertEqual(error, None)
    373376        return
     377
     378    def test_edit_level_by_co(self):
     379        # Create clearance officer
     380        self.app['users'].addUser('mrclear', 'mrclearsecret')
     381        self.app['users']['mrclear'].email = 'mrclear@foo.ng'
     382        self.app['users']['mrclear'].title = 'Carlo Pitter'
     383        # Assign local ClearanceOfficer role
     384        department = self.app['faculties']['fac1']['dep1']
     385        prmlocal = IPrincipalRoleManager(department)
     386        prmlocal.assignRoleToPrincipal('waeup.local.ClearanceOfficer', 'mrclear')
     387        notify(LocalRoleSetEvent(
     388            department, 'waeup.local.ClearanceOfficer', 'mrclear', granted=True))
     389        IWorkflowState(self.student).setState('clearance started')
     390        # Login as clearance officer
     391        self.browser.open(self.login_path)
     392        self.browser.getControl(name="form.login").value = 'mrclear'
     393        self.browser.getControl(name="form.password").value = 'mrclearsecret'
     394        self.browser.getControl("Login").click()
     395        self.assertMatches('...You logged in...', self.browser.contents)
     396        # Only in state clearance requested the CO does see the
     397        # 'Edit level' button ...
     398        self.browser.open(self.studycourse_path)
     399        self.assertFalse('Edit level' in self.browser.contents)
     400        # ... and can open the edit_level view
     401        self.browser.open(self.studycourse_path + '/edit_level')
     402        self.assertMatches('...is locked...', self.browser.contents)
     403        self.assertEqual(self.browser.url, self.studycourse_path)
     404        IWorkflowInfo(self.student).fireTransition('request_clearance')
     405        self.browser.open(self.studycourse_path)
     406        self.assertTrue('Edit level' in self.browser.contents)
     407        self.browser.getLink("Edit level").click()
     408        self.browser.getControl(name="form.current_level").value = ['200']
     409        self.browser.getControl("Save").click()
     410        self.assertMatches('...has been saved...', self.browser.contents)
     411        self.assertEqual(self.student.current_level, 200)
Note: See TracChangeset for help on using the changeset viewer.