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 6851)
+++ main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py	(revision 6852)
@@ -25,4 +25,5 @@
 import shutil
 import tempfile
+import cStringIO
 from datetime import datetime
 from zope.component import createObject
@@ -39,4 +40,15 @@
 
 PH_LEN = 2059  # Length of placeholder file
+
+def lookup_submit_value(name, value, browser):
+    """Find a button with a certain value."""
+    for num in range(0, 100):
+        try:
+            button = browser.getControl(name=name, index=num)
+            if button.value.endswith(value):
+                return button
+        except IndexError:
+            break
+    return None
 
 class StudentsFullSetup(FunctionalTestCase):
@@ -388,4 +400,64 @@
         self.browser.getControl("Save").click()
         return
+
+    def test_manage_import(self):
+        # Managers can import student data files
+        datacenter_path = 'http://localhost/app/datacenter'
+        # Prepare a csv file for students
+        open('students.csv', 'wb').write(
+"""firstname,lastname,fullname,reg_number,date_of_birth,matric_number
+Aaren,Pieri,Aaren Pieri,1,1990-01-02,100000
+Claus,Finau,Claus Finau,2,1990-01-03,100001
+Brit,Berson,Brit Berson,3,1990-01-04,100001
+""")
+        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
+        self.browser.open(datacenter_path)
+        self.browser.getLink('Upload CSV file').click()
+        filecontents = cStringIO.StringIO(open('students.csv', 'rb').read())
+        filewidget = self.browser.getControl(name='uploadfile:file')
+        filewidget.add_file(filecontents, 'text/plain', 'students.csv')
+        self.browser.getControl(name='SUBMIT').click()
+        self.browser.getLink('Batch processing').click()
+        button = lookup_submit_value(
+            'select', 'students_zope.mgr.csv', self.browser)
+        button.click()
+        importerselect = self.browser.getControl(name='importer')
+        modeselect = self.browser.getControl(name='mode')
+        importerselect.getControl('Student Importer').selected = True
+        modeselect.getControl(value='create').selected = True
+        self.browser.getControl('Proceed to step 3...').click()
+        self.assertTrue('Header fields OK' in self.browser.contents)
+        self.browser.getControl('Perform import...').click()
+        self.assertTrue('Processing of 1 rows failed' in self.browser.contents)
+        self.assertTrue('Successfully processed 2 rows' in self.browser.contents)
+        self.assertTrue('Batch processing finished' in self.browser.contents)
+        open('studycourses.csv', 'wb').write(
+"""reg_number,matric_number,certificate,current_session,current_level
+1,,CERT1,2008,100
+,100001,CERT1,2008,100
+,100002,CERT1,2008,100
+""")
+        self.browser.open(datacenter_path)
+        self.browser.getLink('Upload CSV file').click()
+        filecontents = cStringIO.StringIO(open('studycourses.csv', 'rb').read())
+        filewidget = self.browser.getControl(name='uploadfile:file')
+        filewidget.add_file(filecontents, 'text/plain', 'studycourses.csv')
+        self.browser.getControl(name='SUBMIT').click()
+        self.browser.getLink('Batch processing').click()
+        button = lookup_submit_value(
+            'select', 'studycourses_zope.mgr.csv', self.browser)
+        button.click()
+        importerselect = self.browser.getControl(name='importer')
+        modeselect = self.browser.getControl(name='mode')
+        importerselect.getControl(
+            'StudentStudyCourse Importer (update only)').selected = True
+        modeselect.getControl(value='create').selected = True
+        self.browser.getControl('Proceed to step 3...').click()
+        self.assertTrue('Update mode only' in self.browser.contents)
+        self.browser.getControl('Proceed to step 3...').click()
+        self.assertTrue('Header fields OK' in self.browser.contents)
+        self.browser.getControl('Perform import...').click()
+        self.assertTrue('Processing of 1 rows failed' in self.browser.contents)
+        self.assertTrue('Successfully processed 2 rows' in self.browser.contents)
 
     def test_student_change_password(self):
