Index: /main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py
===================================================================
--- /main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py	(revision 7217)
+++ /main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py	(revision 7218)
@@ -368,16 +368,24 @@
         return
 
-    def test_manage_access_wo_certificate(self):
-        # Managers can access studycourse even if student
-        # doesn't have a certificate
-        student = Student()
-        student.fullname = u'Lazy Student'
-        self.app['students'].addStudent(student)
-        student_id = student.student_id
+    def test_manage_remove_department(self):
+        # Lazy student is studying CERT1
+        lazystudent = Student()
+        lazystudent.fullname = u'Lazy Student'
+        self.app['students'].addStudent(lazystudent)
+        student_id = lazystudent.student_id
         student_path = self.container_path + '/' + student_id
+        lazystudent['studycourse'].certificate = self.certificate
+        notify(grok.ObjectModifiedEvent(lazystudent))
         self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
         self.browser.open(student_path + '/studycourse')
+        self.assertTrue('CERT1' in self.browser.contents)
+        # After some years the department is removed
+        del self.app['faculties']['fac1']['dep1']
+        # So CERT1 does no longer exist and lazy student's
+        # certificate reference is removed too
+        self.browser.open(student_path + '/studycourse')
         self.assertEqual(self.browser.headers['Status'], '200 Ok')
         self.assertEqual(self.browser.url, student_path + '/studycourse')
+        self.assertFalse('CERT1' in self.browser.contents)
         self.assertMatches('...<div class="widget">Nothing</div>...',
                            self.browser.contents)
@@ -705,9 +713,18 @@
             '...<a href="http://localhost/app/faculties/fac1/dep1">...',
             self.browser.contents)
-        # CO can view the student
+        # CO can view the student ...
         self.browser.open(self.clearance_student_path)
         self.assertEqual(self.browser.headers['Status'], '200 Ok')
         self.assertEqual(self.browser.url, self.clearance_student_path)
+        # ... but not other students
+        other_student = Student()
+        other_student.fullname = u'Dep2 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)
         # Only in state clearance requested the CO does see the 'Clear' button
+        self.browser.open(self.clearance_student_path)
         self.assertFalse('Clear student' in self.browser.contents)
         IWorkflowInfo(self.student).fireTransition('request_clearance')
@@ -733,4 +750,10 @@
         self.assertTrue('Student is in the wrong state'
             in self.browser.contents)
+        # The CO can go to his department throug the my_roles page
+        self.browser.open('http://localhost/app/users/mrclear/my_roles')
+        self.browser.getLink("http://localhost/app/faculties/fac1/dep1").click()
+        # and view the list of students
+        self.browser.getLink("Show students").click()
+        self.assertTrue(self.student_id in self.browser.contents)
 
     def test_student_change_password(self):
