Index: main/waeup.kofa/branches/uli-scores-upload/src/waeup/kofa/students/tests/test_browser.py
===================================================================
--- main/waeup.kofa/branches/uli-scores-upload/src/waeup/kofa/students/tests/test_browser.py	(revision 13916)
+++ main/waeup.kofa/branches/uli-scores-upload/src/waeup/kofa/students/tests/test_browser.py	(revision 13917)
@@ -1807,122 +1807,4 @@
         self.assertTrue(self.student_id in self.browser.contents)
 
-    def test_handle_courses_by_lecturer(self):
-        self.app['users'].addUser('mrslecturer', 'mrslecturersecret')
-        self.app['users']['mrslecturer'].email = 'mrslecturer@foo.ng'
-        self.app['users']['mrslecturer'].title = u'Mercedes Benz'
-        # Add course ticket
-        studylevel = createObject(u'waeup.StudentStudyLevel')
-        studylevel.level = 100
-        studylevel.level_session = 2004
-        self.student['studycourse'].addStudentStudyLevel(
-            self.certificate, studylevel)
-        # Assign local Lecturer role for a certificate.
-        course = self.app['faculties']['fac1']['dep1'].courses['COURSE1']
-        prmlocal = IPrincipalRoleManager(course)
-        prmlocal.assignRoleToPrincipal('waeup.local.Lecturer', 'mrslecturer')
-        notify(LocalRoleSetEvent(
-            course, 'waeup.local.Lecturer', 'mrslecturer', granted=True))
-        # Login as lecturer.
-        self.browser.open(self.login_path)
-        self.browser.getControl(name="form.login").value = 'mrslecturer'
-        self.browser.getControl(
-            name="form.password").value = 'mrslecturersecret'
-        self.browser.getControl("Login").click()
-        self.assertMatches('...You logged in...', self.browser.contents)
-        # Lecturer is on landing page
-        self.assertTrue('(<span>COURSE1</span>)' in self.browser.contents)
-        # Lecturer can click the 'My Roles' link.
-        self.browser.getLink("My Roles").click()
-        self.assertMatches(
-            '...<div>Academics Officer (view only)</div>...',
-            self.browser.contents)
-        self.assertMatches(
-            '...<a href="http://localhost/app/'
-            'faculties/fac1/dep1/courses/COURSE1">...',
-            self.browser.contents)
-        self.assertFalse('(<span>COURSE1</span>)' in self.browser.contents)
-        # Lecturer can click the 'My Courses' link ...
-        self.browser.getLink("My Courses").click()
-        # ... and is is back on landing page
-        self.assertTrue('(<span>COURSE1</span>)' in self.browser.contents)
-        # The lecturer can go to her course ...
-        self.browser.getLink("COURSE1").click()
-        # Lecturers can neither filter students ...
-        self.assertRaises(
-            Unauthorized, self.browser.open,
-            "http://localhost/app/faculties/fac1/dep1/courses/COURSE1/students")
-        # ... nor access the student ...
-        self.assertRaises(
-            Unauthorized, self.browser.open, self.student_path)
-        # ... nor the respective course ticket since
-        # editing course tickets by lecturers is not feasible.
-        self.assertTrue('COURSE1' in self.student['studycourse']['100'].keys())
-        course_ticket_path = self.student_path + '/studycourse/100/COURSE1'
-        self.assertRaises(
-            Unauthorized, self.browser.open, course_ticket_path)
-        # Course results can be batch edited via the edit_courses view.
-        self.app['faculties']['fac1']['dep1'].score_editing_disabled = True
-        self.browser.open(
-            "http://localhost/app/faculties/fac1/dep1/courses/COURSE1")
-        self.browser.getLink("Update scores").click()
-        self.assertTrue('Score editing disabled' in self.browser.contents)
-        self.app['faculties']['fac1']['dep1'].score_editing_disabled = False
-        self.browser.getLink("Update scores").click()
-        self.assertTrue(
-            'Current academic session not set' in self.browser.contents)
-        self.app['configuration'].current_academic_session = 2004
-        self.browser.getLink("Update scores").click()
-        self.assertFalse(
-            '<input type="text" name="scores" class="span1" />'
-            in self.browser.contents)
-        IWorkflowState(self.student).setState('courses validated')
-        # Student must be in state 'courses validated'.
-        self.browser.open(
-            'http://localhost/app/faculties/fac1/'
-            'dep1/courses/COURSE1/edit_scores')
-        self.assertTrue(
-            'input type="text" name="scores"' in self.browser.contents)
-        self.browser.getControl(name="scores", index=0).value = '55'
-        self.browser.getControl("Update scores").click()
-        # New score has been set.
-        self.assertEqual(
-            self.student['studycourse']['100']['COURSE1'].score, 55)
-        # Score editing has been logged.
-        logfile = os.path.join(
-            self.app['datacenter'].storage, 'logs', 'students.log')
-        logcontent = open(logfile).read()
-        self.assertTrue('mrslecturer - students.browser.EditScoresPage - '
-            'K1000000 100/COURSE1 score updated (55)' in logcontent)
-        # Non-integer scores won't be accepted.
-        self.browser.open(
-            'http://localhost/app/faculties/fac1/'
-            'dep1/courses/COURSE1/edit_scores')
-        self.assertTrue('value="55" />' in self.browser.contents)
-        self.browser.getControl(name="scores", index=0).value = 'abc'
-        self.browser.getControl("Update scores").click()
-        self.assertTrue('Error: Score(s) of Anna Tester have not be updated'
-            in self.browser.contents)
-        # Scores can be removed.
-        self.browser.open(
-            'http://localhost/app/faculties/fac1/'
-            'dep1/courses/COURSE1/edit_scores')
-        self.browser.getControl(name="scores", index=0).value = ''
-        self.browser.getControl("Update scores").click()
-        self.assertEqual(
-            self.student['studycourse']['100']['COURSE1'].score, None)
-        logcontent = open(logfile).read()
-        self.assertTrue('mrslecturer - students.browser.EditScoresPage - '
-            'K1000000 100/COURSE1 score updated (None)' in logcontent)
-        # A course ticket slip can be downloaded
-        self.browser.open(
-            'http://localhost/app/faculties/fac1/'
-            'dep1/courses/COURSE1/coursetickets.pdf')
-        self.assertEqual(self.browser.headers['Status'], '200 Ok')
-        self.assertEqual(self.browser.headers['Content-Type'],
-                         'application/pdf')
-        path = os.path.join(samples_dir(), 'coursetickets.pdf')
-        open(path, 'wb').write(self.browser.contents)
-        print "Sample PDF coursetickets.pdf written to %s" % path
-
     def test_change_current_mode(self):
         self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
@@ -4004,2 +3886,127 @@
         self.browser.getControl("Discard").click()
         self.assertEqual(len(self.app['datacenter'].running_exports), 0)
+
+
+class LecturerUITests(StudentsFullSetup):
+    # Tests for UI actions when acting as lecturer.
+
+    def login_as_lecturer(self):
+        self.app['users'].addUser('mrslecturer', 'mrslecturersecret')
+        self.app['users']['mrslecturer'].email = 'mrslecturer@foo.ng'
+        self.app['users']['mrslecturer'].title = u'Mercedes Benz'
+        # Add course ticket
+        studylevel = createObject(u'waeup.StudentStudyLevel')
+        studylevel.level = 100
+        studylevel.level_session = 2004
+        self.student['studycourse'].addStudentStudyLevel(
+            self.certificate, studylevel)
+        # Assign local Lecturer role for a certificate.
+        course = self.app['faculties']['fac1']['dep1'].courses['COURSE1']
+        prmlocal = IPrincipalRoleManager(course)
+        prmlocal.assignRoleToPrincipal('waeup.local.Lecturer', 'mrslecturer')
+        notify(LocalRoleSetEvent(
+            course, 'waeup.local.Lecturer', 'mrslecturer', granted=True))
+        # Login as lecturer.
+        self.browser.open(self.login_path)
+        self.browser.getControl(name="form.login").value = 'mrslecturer'
+        self.browser.getControl(
+            name="form.password").value = 'mrslecturersecret'
+        self.browser.getControl("Login").click()
+
+    def test_handle_courses_by_lecturer(self):
+        self.login_as_lecturer()
+        self.assertMatches('...You logged in...', self.browser.contents)
+        # Lecturer is on landing page
+        self.assertTrue('(<span>COURSE1</span>)' in self.browser.contents)
+        # Lecturer can click the 'My Roles' link.
+        self.browser.getLink("My Roles").click()
+        self.assertMatches(
+            '...<div>Academics Officer (view only)</div>...',
+            self.browser.contents)
+        self.assertMatches(
+            '...<a href="http://localhost/app/'
+            'faculties/fac1/dep1/courses/COURSE1">...',
+            self.browser.contents)
+        self.assertFalse('(<span>COURSE1</span>)' in self.browser.contents)
+        # Lecturer can click the 'My Courses' link ...
+        self.browser.getLink("My Courses").click()
+        # ... and is is back on landing page
+        self.assertTrue('(<span>COURSE1</span>)' in self.browser.contents)
+        # The lecturer can go to her course ...
+        self.browser.getLink("COURSE1").click()
+        # Lecturers can neither filter students ...
+        self.assertRaises(
+            Unauthorized, self.browser.open,
+            "http://localhost/app/faculties/fac1/dep1/courses/COURSE1/students")
+        # ... nor access the student ...
+        self.assertRaises(
+            Unauthorized, self.browser.open, self.student_path)
+        # ... nor the respective course ticket since
+        # editing course tickets by lecturers is not feasible.
+        self.assertTrue('COURSE1' in self.student['studycourse']['100'].keys())
+        course_ticket_path = self.student_path + '/studycourse/100/COURSE1'
+        self.assertRaises(
+            Unauthorized, self.browser.open, course_ticket_path)
+        # Course results can be batch edited via the edit_courses view.
+        self.app['faculties']['fac1']['dep1'].score_editing_disabled = True
+        self.browser.open(
+            "http://localhost/app/faculties/fac1/dep1/courses/COURSE1")
+        self.browser.getLink("Update scores").click()
+        self.assertTrue('Score editing disabled' in self.browser.contents)
+        self.app['faculties']['fac1']['dep1'].score_editing_disabled = False
+        self.browser.getLink("Update scores").click()
+        self.assertTrue(
+            'Current academic session not set' in self.browser.contents)
+        self.app['configuration'].current_academic_session = 2004
+        self.browser.getLink("Update scores").click()
+        self.assertFalse(
+            '<input type="text" name="scores" class="span1" />'
+            in self.browser.contents)
+        IWorkflowState(self.student).setState('courses validated')
+        # Student must be in state 'courses validated'.
+        self.browser.open(
+            'http://localhost/app/faculties/fac1/'
+            'dep1/courses/COURSE1/edit_scores')
+        self.assertTrue(
+            'input type="text" name="scores"' in self.browser.contents)
+        self.browser.getControl(name="scores", index=0).value = '55'
+        self.browser.getControl("Update scores").click()
+        # New score has been set.
+        self.assertEqual(
+            self.student['studycourse']['100']['COURSE1'].score, 55)
+        # Score editing has been logged.
+        logfile = os.path.join(
+            self.app['datacenter'].storage, 'logs', 'students.log')
+        logcontent = open(logfile).read()
+        self.assertTrue('mrslecturer - students.browser.EditScoresPage - '
+            'K1000000 100/COURSE1 score updated (55)' in logcontent)
+        # Non-integer scores won't be accepted.
+        self.browser.open(
+            'http://localhost/app/faculties/fac1/'
+            'dep1/courses/COURSE1/edit_scores')
+        self.assertTrue('value="55" />' in self.browser.contents)
+        self.browser.getControl(name="scores", index=0).value = 'abc'
+        self.browser.getControl("Update scores").click()
+        self.assertTrue('Error: Score(s) of Anna Tester have not be updated'
+            in self.browser.contents)
+        # Scores can be removed.
+        self.browser.open(
+            'http://localhost/app/faculties/fac1/'
+            'dep1/courses/COURSE1/edit_scores')
+        self.browser.getControl(name="scores", index=0).value = ''
+        self.browser.getControl("Update scores").click()
+        self.assertEqual(
+            self.student['studycourse']['100']['COURSE1'].score, None)
+        logcontent = open(logfile).read()
+        self.assertTrue('mrslecturer - students.browser.EditScoresPage - '
+            'K1000000 100/COURSE1 score updated (None)' in logcontent)
+        # A course ticket slip can be downloaded
+        self.browser.open(
+            'http://localhost/app/faculties/fac1/'
+            'dep1/courses/COURSE1/coursetickets.pdf')
+        self.assertEqual(self.browser.headers['Status'], '200 Ok')
+        self.assertEqual(self.browser.headers['Content-Type'],
+                         'application/pdf')
+        path = os.path.join(samples_dir(), 'coursetickets.pdf')
+        open(path, 'wb').write(self.browser.contents)
+        print "Sample PDF coursetickets.pdf written to %s" % path
