Index: main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py
===================================================================
--- main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py	(revision 11774)
+++ main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py	(revision 11862)
@@ -1384,5 +1384,5 @@
         return
 
-    def test_handle_clearance_by_co(self):
+    def init_clearance_officer(self):
         # Create clearance officer
         self.app['users'].addUser('mrclear', 'mrclearsecret')
@@ -1394,8 +1394,15 @@
         #prmglobal.assignRoleToPrincipal('waeup.StudentsOfficer', 'mrclear')
         # Assign local ClearanceOfficer role
-        department = self.app['faculties']['fac1']['dep1']
-        prmlocal = IPrincipalRoleManager(department)
+        self.department = self.app['faculties']['fac1']['dep1']
+        prmlocal = IPrincipalRoleManager(self.department)
         prmlocal.assignRoleToPrincipal('waeup.local.ClearanceOfficer', 'mrclear')
         IWorkflowState(self.student).setState('clearance started')
+        # Add another student for testing
+        other_student = Student()
+        other_student.firstname = u'Dep2'
+        other_student.lastname = u'Student'
+        self.app['students'].addStudent(other_student)
+        self.other_student_path = (
+            'http://localhost/app/students/%s' % other_student.student_id)
         # Login as clearance officer
         self.browser.open(self.login_path)
@@ -1403,4 +1410,7 @@
         self.browser.getControl(name="form.password").value = 'mrclearsecret'
         self.browser.getControl("Login").click()
+
+    def test_handle_clearance_by_co(self):
+        self.init_clearance_officer()
         self.assertMatches('...You logged in...', self.browser.contents)
         # CO is landing on index page
@@ -1419,5 +1429,5 @@
         # has changed
         notify(LocalRoleSetEvent(
-            department, 'waeup.local.ClearanceOfficer', 'mrclear', granted=True))
+            self.department, 'waeup.local.ClearanceOfficer', 'mrclear', granted=True))
         self.browser.open('http://localhost/app/users/mrclear/my_roles')
         self.assertTrue('Clearance Officer' in self.browser.contents)
@@ -1430,12 +1440,6 @@
         self.assertEqual(self.browser.url, self.clearance_path)
         # ... but not other students
-        other_student = Student()
-        other_student.firstname = u'Dep2'
-        other_student.lastname = u'Student'
-        self.app['students'].addStudent(other_student)
-        other_student_path = (
-            'http://localhost/app/students/%s' % other_student.student_id)
         self.assertRaises(
-            Unauthorized, self.browser.open, other_student_path)
+            Unauthorized, self.browser.open, self.other_student_path)
         # Clearance is disabled for this session
         self.browser.open(self.clearance_path)
@@ -1536,4 +1540,30 @@
         IWorkflowInfo(self.student).fireTransition('clear')
         self.assertEqual(self.student.officer_comment, None)
+        return
+
+    def test_handle_mass_clearance_by_co(self):
+        self.init_clearance_officer()
+        # Additional setups according to test above
+        notify(LocalRoleSetEvent(
+            self.department, 'waeup.local.ClearanceOfficer', 'mrclear', granted=True))
+        self.app['configuration']['2004'].clearance_enabled = True
+        IWorkflowState(self.student).setState('clearance requested')
+        # Update the catalog
+        notify(grok.ObjectModifiedEvent(self.student))
+        # The CO can go to the department and clear all students in department
+        self.browser.open('http://localhost/app/faculties/fac1/dep1')
+        self.browser.getLink("Clear all students").click()
+        self.assertTrue('1 students have been cleared' in self.browser.contents)
+        self.browser.open(self.history_path)
+        self.assertTrue('Cleared by Carlo Pitter' in self.browser.contents)
+        logfile = os.path.join(
+            self.app['datacenter'].storage, 'logs', 'students.log')
+        logcontent = open(logfile).read()
+        self.assertTrue(
+            'INFO - mrclear - K1000000 - Cleared' in logcontent)
+        self.browser.open('http://localhost/app/faculties/fac1/dep1')
+        self.browser.getLink("Clear all students").click()
+        self.assertTrue('0 students have been cleared' in self.browser.contents)
+        return
 
     def test_handle_courses_by_ca(self):
