Index: main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_browser.py
===================================================================
--- main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_browser.py	(revision 13909)
+++ main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_browser.py	(revision 13937)
@@ -21,4 +21,5 @@
 import pytz
 import grok
+from StringIO import StringIO
 from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState
 from zope.securitypolicy.interfaces import IPrincipalRoleManager
@@ -31,4 +32,5 @@
 from zope.catalog.interfaces import ICatalog
 from waeup.kofa.app import University
+from waeup.kofa.interfaces import VALIDATED
 from waeup.kofa.students.tests.test_browser import StudentsFullSetup
 from waeup.kofa.students.accommodation import BedTicket
@@ -72,8 +74,45 @@
         return
 
+UPLOAD_CSV_TEMPLATE = (
+    'matric_number,student_id,display_fullname,level,code,level_session,'
+    'score,ca\r\n'
+    '234,E1000000,Anna Tester,100,COURSE1,2004,%s,%s\r\n')
+
 class OfficerUITests(StudentsFullSetup):
     # Tests for Student class views and pages
 
     layer = FunctionalLayer
+
+    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()
+        # Store reused urls/paths
+        self.course_url = (
+            'http://localhost/app/faculties/fac1/dep1/courses/COURSE1')
+        self.edit_scores_url = '%s/edit_scores' % self.course_url
+        # Set standard parameters
+        self.app['configuration'].current_academic_session = 2004
+        self.app['faculties']['fac1']['dep1'].score_editing_disabled = False
+        IWorkflowState(self.student).setState(VALIDATED)
+
 
     def test_gpa_calculation(self):
@@ -281,4 +320,20 @@
         return
 
+    def test_scores_csv_upload_available(self):
+        # lecturers can upload a CSV file to set values.
+        self.login_as_lecturer()
+        # set value to change from
+        self.student['studycourse']['100']['COURSE1'].score = 55
+        self.browser.open(self.edit_scores_url)
+        upload_ctrl = self.browser.getControl(name='uploadfile:file')
+        upload_file = StringIO(UPLOAD_CSV_TEMPLATE % ('65','77'))
+        upload_ctrl.add_file(upload_file, 'text/csv', 'myscores.csv')
+        self.browser.getControl("Update editable scores from").click()
+        # value changed
+        self.assertEqual(
+            self.student['studycourse']['100']['COURSE1'].score, 65)
+        self.assertEqual(
+            self.student['studycourse']['100']['COURSE1'].ca, 77)
+
 class StudentUITests(StudentsFullSetup):
     """Tests for customized student class views and pages
@@ -688,9 +743,9 @@
             "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(name="cas", index=0).value = '66'
-        self.browser.getControl("Update scores").click()
+            'input type="text" name="scores:list"'
+            in self.browser.contents)
+        self.browser.getControl(name="scores:list", index=0).value = '55'
+        self.browser.getControl(name="cas:list", index=0).value = '66'
+        self.browser.getControl("Update scores from").click()
         # New score and ca has been set.
         self.assertEqual(
@@ -710,5 +765,5 @@
             "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(name="scores:list", index=0).value = 'abc'
         self.browser.getControl("Update scores").click()
         self.assertTrue('Error: Score(s) and CA(s) of Anna Tester have not be updated.'
@@ -717,5 +772,5 @@
         self.browser.open(
             "http://localhost/app/faculties/fac1/dep1/courses/COURSE1/edit_scores")
-        self.browser.getControl(name="scores", index=0).value = ''
+        self.browser.getControl(name="scores:list", index=0).value = ''
         self.browser.getControl("Update scores").click()
         self.assertEqual(
