Index: main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_browser.py
===================================================================
--- main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_browser.py	(revision 6602)
+++ main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_browser.py	(revision 6603)
@@ -27,6 +27,8 @@
 from StringIO import StringIO
 from datetime import datetime
+from mechanize import LinkNotFoundError
 from zope.component import createObject
 from zope.component.hooks import setSite, clearSite
+from zope.security.interfaces import Unauthorized
 from zope.testbrowser.testing import Browser
 from hurry.workflow.interfaces import IWorkflowInfo
@@ -70,5 +72,8 @@
 
         self.root_path = 'http://localhost/app/applicants'
+        self.manage_root_path = self.root_path + '/@@manage'
+        self.add_container_path = self.root_path + '/@@add'
         self.container_path = 'http://localhost/app/applicants/app2009'
+        self.manage_container_path = self.container_path + '/@@manage'
 
         # Add an applicants container
@@ -114,7 +119,6 @@
         clearSite()
         shutil.rmtree(self.dc_root)
-        #import pdb; pdb.set_trace()
-
-class ApplicantsUITests(ApplicantsFullSetup):
+
+class ApplicantsRootUITests(ApplicantsFullSetup):
     # Tests for ApplicantsRoot class
 
@@ -122,84 +126,66 @@
 
     def test_anonymous_access(self):
-        # Anonymous users can access applicants root and applicants containers
+        # Anonymous users can access applicants root
         self.browser.open(self.root_path)
         self.assertEqual(self.browser.headers['Status'], '200 Ok')
         self.assertFalse(
             'Manage' in self.browser.contents)
-        self.browser.open(self.container_path)
-        self.assertEqual(self.browser.headers['Status'], '200 Ok')
-        self.assertFalse(
-            'Manage' in self.browser.contents)
-        return
-
-    def test_manage_cert_access(self):
-        # Managers can access CERT1
-        cert_path = 'http://localhost/app/faculties/fac1/dep1/certificates/CERT1'
-        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
-        self.browser.open(cert_path)
-        self.assertEqual(self.browser.headers['Status'], '200 Ok')
+
+    def test_anonymous_no_actions(self):
+        # Make sure anonymous users cannot access actions
+        self.browser.open(self.root_path)
+        self.assertRaises(
+            LookupError, self.browser.getControl, "Add local role")
+        # Manage screen neither linked nor accessible for anonymous
+        self.assertRaises(
+            LinkNotFoundError,
+            self.browser.getLink, 'Manage application section')
+        self.assertRaises(
+            Unauthorized, self.browser.open, self.manage_root_path)
+        # Add container screen not accessible for anonymous
+        self.assertRaises(
+            Unauthorized, self.browser.open, self.add_container_path)
+        return
 
     def test_manage_access(self):
-        # Managers can access the manage pages of applicants root and
-        # applicants containers and can perform actions
+        # Managers can access the manage pages of applicants root
         self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
         self.browser.open(self.root_path)
-        self.assertTrue(
-            'Manage application section' in self.browser.contents)
-        self.manage_root_path = self.root_path + '/@@manage'
-        self.manage_container_path = self.container_path + '/@@manage'
+        self.assertTrue('Manage application section' in self.browser.contents)
+        # There is a manage link
+        link = self.browser.getLink('Manage application section')
+        link.click()
+        self.assertEqual(self.browser.headers['Status'], '200 Ok')
+        self.assertEqual(self.browser.url, self.manage_root_path)
+
+    def test_manage_actions_access(self):
+        # Managers can access the action on manage screen
+        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
         self.browser.open(self.manage_root_path)
-        self.assertEqual(self.browser.headers['Status'], '200 Ok')
-        self.assertEqual(self.browser.url, self.manage_root_path)
         self.browser.getControl("Add local role").click()
-        self.assertTrue(
-            'No user selected' in self.browser.contents)
-        self.browser.open(self.manage_container_path)
-        self.assertEqual(self.browser.headers['Status'], '200 Ok')
-        self.assertEqual(self.browser.url, self.manage_container_path)
-        self.browser.getControl("Save").click()
-        self.assertTrue(
-            'Data saved' in self.browser.contents)
-        self.browser.getControl("Remove selected", index=0).click()
-        self.assertTrue(
-            'No applicant selected' in self.browser.contents)
-        self.browser.getControl("Add local role").click()
-        self.assertTrue(
-            'No user selected' in self.browser.contents)
-        self.browser.getControl("Cancel", index=0).click()
-        self.assertEqual(self.browser.url, self.container_path)
-        # Managers can can assign local roles
+        self.assertTrue('No user selected' in self.browser.contents)
+        return
+
+    def test_local_roles_add_delete(self):
+        # Managers can assign and delete local roles of applicants root
         myusers = self.app['users']
         myusers.addUser('bob', 'bobssecret')
+        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
         self.browser.open(self.manage_root_path)
         self.browser.getControl(name="user").value = ['bob']
-        self.browser.getControl(name="local_role").value = ['waeup.ApplicationsOfficer']
+        self.browser.getControl(name="local_role").value = [
+            'waeup.ApplicationsOfficer']
         self.browser.getControl("Add local role").click()
-        self.assertTrue(
-            '<td>bob</td>' in self.browser.contents)
+        self.assertTrue('<td>bob</td>' in self.browser.contents)
+        # Remove the role assigned
         ctrl = self.browser.getControl(name='role_id')
         ctrl.getControl(value='bob|waeup.ApplicationsOfficer').selected = True
         self.browser.getControl("Remove selected local roles").click()
         self.assertTrue('Successfully removed:' in self.browser.contents)
-        self.assertFalse(
-            '<td>bob</td>' in self.browser.contents)
-        self.browser.open(self.manage_container_path)
-        self.browser.getControl(name="user").value = ['bob']
-        self.browser.getControl(name="local_role").value = ['waeup.ApplicationsOfficer']
-        self.browser.getControl("Add local role").click()
-        self.assertTrue(
-            '<td>bob</td>' in self.browser.contents)
-        ctrl = self.browser.getControl(name='role_id')
-        ctrl.getControl(value='bob|waeup.ApplicationsOfficer').selected = True
-        self.browser.getControl("Remove selected local roles").click()
-        self.assertTrue('Successfully removed:' in self.browser.contents)
-        self.assertFalse(
-            '<td>bob</td>' in self.browser.contents)
+        self.assertFalse('<td>bob</td>' in self.browser.contents)
         return
 
     def test_add_delete_container(self):
         # Managers can add and delete applicants containers
-        self.manage_root_path = self.root_path + '/@@manage'
-        self.add_container_path = self.root_path + '/@@add'
         self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
         self.browser.open(self.manage_root_path)
@@ -402,4 +388,52 @@
         return
 
+class ApplicantsContainerUITests(ApplicantsFullSetup):
+    # Tests for ApplicantsContainer class views and pages
+
+    layer = FunctionalLayer
+
+    def test_anonymous_access(self):
+        # Anonymous users can access applicants containers
+        self.browser.open(self.container_path)
+        self.assertEqual(self.browser.headers['Status'], '200 Ok')
+        self.assertFalse(
+            'Manage' in self.browser.contents)
+        return
+
+    def test_manage_access(self):
+        # Managers can access the manage pages of applicants
+        # containers and can perform actions
+        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
+        self.browser.open(self.manage_container_path)
+        self.assertEqual(self.browser.headers['Status'], '200 Ok')
+        self.assertEqual(self.browser.url, self.manage_container_path)
+        self.browser.getControl("Save").click()
+        self.assertTrue('Data saved' in self.browser.contents)
+        self.browser.getControl("Remove selected", index=0).click()
+        self.assertTrue('No applicant selected' in self.browser.contents)
+        self.browser.getControl("Add local role").click()
+        self.assertTrue('No user selected' in self.browser.contents)
+        self.browser.getControl("Cancel", index=0).click()
+        self.assertEqual(self.browser.url, self.container_path)
+        return
+
+    def test_local_roles_add_delete(self):
+        # Managers can assign and delete local roles of applicants containers
+        myusers = self.app['users']
+        myusers.addUser('bob', 'bobssecret')
+        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
+        self.browser.open(self.manage_container_path)
+        self.browser.getControl(name="user").value = ['bob']
+        self.browser.getControl(name="local_role").value = [
+            'waeup.ApplicationsOfficer']
+        self.browser.getControl("Add local role").click()
+        self.assertTrue('<td>bob</td>' in self.browser.contents)
+        ctrl = self.browser.getControl(name='role_id')
+        ctrl.getControl(value='bob|waeup.ApplicationsOfficer').selected = True
+        self.browser.getControl("Remove selected local roles").click()
+        self.assertTrue('Successfully removed:' in self.browser.contents)
+        self.assertFalse('<td>bob</td>' in self.browser.contents)
+        return
+
 class LoginTest(FunctionalTestCase):
     # Here we check login view of applicants containers.
