Ignore:
Timestamp:
21 Oct 2014, 07:07:04 (10 years ago)
Author:
Henrik Bettermann
Message:

Add permission, page and button to mass-clear all students in a department.

File:
1 edited

Legend:

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

    r11774 r11862  
    13841384        return
    13851385
    1386     def test_handle_clearance_by_co(self):
     1386    def init_clearance_officer(self):
    13871387        # Create clearance officer
    13881388        self.app['users'].addUser('mrclear', 'mrclearsecret')
     
    13941394        #prmglobal.assignRoleToPrincipal('waeup.StudentsOfficer', 'mrclear')
    13951395        # Assign local ClearanceOfficer role
    1396         department = self.app['faculties']['fac1']['dep1']
    1397         prmlocal = IPrincipalRoleManager(department)
     1396        self.department = self.app['faculties']['fac1']['dep1']
     1397        prmlocal = IPrincipalRoleManager(self.department)
    13981398        prmlocal.assignRoleToPrincipal('waeup.local.ClearanceOfficer', 'mrclear')
    13991399        IWorkflowState(self.student).setState('clearance started')
     1400        # Add another student for testing
     1401        other_student = Student()
     1402        other_student.firstname = u'Dep2'
     1403        other_student.lastname = u'Student'
     1404        self.app['students'].addStudent(other_student)
     1405        self.other_student_path = (
     1406            'http://localhost/app/students/%s' % other_student.student_id)
    14001407        # Login as clearance officer
    14011408        self.browser.open(self.login_path)
     
    14031410        self.browser.getControl(name="form.password").value = 'mrclearsecret'
    14041411        self.browser.getControl("Login").click()
     1412
     1413    def test_handle_clearance_by_co(self):
     1414        self.init_clearance_officer()
    14051415        self.assertMatches('...You logged in...', self.browser.contents)
    14061416        # CO is landing on index page
     
    14191429        # has changed
    14201430        notify(LocalRoleSetEvent(
    1421             department, 'waeup.local.ClearanceOfficer', 'mrclear', granted=True))
     1431            self.department, 'waeup.local.ClearanceOfficer', 'mrclear', granted=True))
    14221432        self.browser.open('http://localhost/app/users/mrclear/my_roles')
    14231433        self.assertTrue('Clearance Officer' in self.browser.contents)
     
    14301440        self.assertEqual(self.browser.url, self.clearance_path)
    14311441        # ... but not other students
    1432         other_student = Student()
    1433         other_student.firstname = u'Dep2'
    1434         other_student.lastname = u'Student'
    1435         self.app['students'].addStudent(other_student)
    1436         other_student_path = (
    1437             'http://localhost/app/students/%s' % other_student.student_id)
    14381442        self.assertRaises(
    1439             Unauthorized, self.browser.open, other_student_path)
     1443            Unauthorized, self.browser.open, self.other_student_path)
    14401444        # Clearance is disabled for this session
    14411445        self.browser.open(self.clearance_path)
     
    15361540        IWorkflowInfo(self.student).fireTransition('clear')
    15371541        self.assertEqual(self.student.officer_comment, None)
     1542        return
     1543
     1544    def test_handle_mass_clearance_by_co(self):
     1545        self.init_clearance_officer()
     1546        # Additional setups according to test above
     1547        notify(LocalRoleSetEvent(
     1548            self.department, 'waeup.local.ClearanceOfficer', 'mrclear', granted=True))
     1549        self.app['configuration']['2004'].clearance_enabled = True
     1550        IWorkflowState(self.student).setState('clearance requested')
     1551        # Update the catalog
     1552        notify(grok.ObjectModifiedEvent(self.student))
     1553        # The CO can go to the department and clear all students in department
     1554        self.browser.open('http://localhost/app/faculties/fac1/dep1')
     1555        self.browser.getLink("Clear all students").click()
     1556        self.assertTrue('1 students have been cleared' in self.browser.contents)
     1557        self.browser.open(self.history_path)
     1558        self.assertTrue('Cleared by Carlo Pitter' in self.browser.contents)
     1559        logfile = os.path.join(
     1560            self.app['datacenter'].storage, 'logs', 'students.log')
     1561        logcontent = open(logfile).read()
     1562        self.assertTrue(
     1563            'INFO - mrclear - K1000000 - Cleared' in logcontent)
     1564        self.browser.open('http://localhost/app/faculties/fac1/dep1')
     1565        self.browser.getLink("Clear all students").click()
     1566        self.assertTrue('0 students have been cleared' in self.browser.contents)
     1567        return
    15381568
    15391569    def test_handle_courses_by_ca(self):
Note: See TracChangeset for help on using the changeset viewer.