Index: main/waeup.kofa/trunk/src/waeup/kofa/university/tests/sample_certificate_data.csv
===================================================================
--- main/waeup.kofa/trunk/src/waeup/kofa/university/tests/sample_certificate_data.csv	(revision 9000)
+++ main/waeup.kofa/trunk/src/waeup/kofa/university/tests/sample_certificate_data.csv	(revision 9000)
@@ -0,0 +1,8 @@
+faculty_code,department_code,code,local_roles
+FAC1,DEP1,CRT2,"[{'user_name':'anne','local_role':'waeup.local.CourseAdviser100'}]"
+FAC1,DEP1,CRT2,"[{'user_name':'alice','local_role':'waeup.local.CourseAdviser100'}]"
+FAC1,DEP1,CRT2,"[{'user_name':'anne','local_role':'waeup.local.Boss'}]"
+FAC1,DEP1,CRT2,"[('anything')]"
+FAC1,DEP1,CRT2,"["
+FAC1,DEP1,CRT2,"[{'user':'anne','local':'waeup.local.CourseAdviser100'}]"
+FAC11,DEP2,CRT2,"[{'user_name':'anne','local_role':'waeup.local.CourseAdviser100'}]"
Index: main/waeup.kofa/trunk/src/waeup/kofa/university/tests/test_batching.py
===================================================================
--- main/waeup.kofa/trunk/src/waeup/kofa/university/tests/test_batching.py	(revision 8999)
+++ main/waeup.kofa/trunk/src/waeup/kofa/university/tests/test_batching.py	(revision 9000)
@@ -49,4 +49,11 @@
 
 DEPARTMENT_HEADER_FIELDS = DEPARTMENT_SAMPLE_DATA.split(
+    '\n')[0].split(',')
+
+CERTIFICATE_SAMPLE_DATA = open(
+    os.path.join(os.path.dirname(__file__), 'sample_certificate_data.csv'),
+    'rb').read()
+
+CERTIFICATE_HEADER_FIELDS = CERTIFICATE_SAMPLE_DATA.split(
     '\n')[0].split(',')
 
@@ -208,4 +215,5 @@
         self.assertEqual(local_role, 'waeup.local.DepartmentManager')
         shutil.rmtree(os.path.dirname(fin_file))
+        return
 
 class TestDepartmentProcessor(UniversityProcessorSetup):
@@ -287,5 +295,5 @@
             'Not all parents do exist yet. Skipping\r\n'
             )
-        # Bob got a local role in department ABC.
+        # Anne got a local role in department ABC.
         dep = self.app['faculties']['FAC1']['DEP2']
         role_map = IPrincipalRoleMap(dep)
@@ -294,4 +302,5 @@
         self.assertEqual(local_role, 'waeup.local.DepartmentManager')
         shutil.rmtree(os.path.dirname(fin_file))
+        return
 
 class CourseProcessorTests(UniversityProcessorSetup):
@@ -358,4 +367,7 @@
         self.row3 = dict(department_code='DEP1', faculty_code='FAC1', code="CRT2")
         self.row4 = dict(department_code='DEP1', faculty_code='FAC1', code="CRT1")
+
+        self.csv_file_certificate = os.path.join(self.workdir, 'sample_certificate_data.csv')
+        open(self.csv_file_certificate, 'wb').write(CERTIFICATE_SAMPLE_DATA)
         return
 
@@ -401,4 +413,32 @@
         self.proc.delEntry(self.row4, self.app)
         self.assertTrue('CRT1' not in self.app['faculties']['FAC1']['DEP1'].certificates.keys())
+        return
+
+    def test_import(self):
+        num, num_warns, fin_file, fail_file = self.proc.doImport(
+            self.csv_file_certificate, CERTIFICATE_HEADER_FIELDS)
+        content = open(fail_file).read()
+        self.assertEqual(num_warns,6)
+        self.assertEqual(
+            content,
+            'faculty_code,department_code,code,local_roles,--ERRORS--\r\n'
+            'FAC1,DEP1,CRT2,"[{\'user_name\':\'alice\',\'local_role\':\'waeup.local.CourseAdviser100\'}]",'
+            'local_roles: alice does not exist\r\n'
+            'FAC1,DEP1,CRT2,"[{\'user_name\':\'anne\',\'local_role\':\'waeup.local.Boss\'}]",'
+            'local_roles: waeup.local.Boss not allowed\r\n'
+            'FAC1,DEP1,CRT2,[(\'anything\')],local_roles: no dicts\r\n'
+            'FAC1,DEP1,CRT2,[,local_roles: Error\r\n'
+            'FAC1,DEP1,CRT2,"[{\'user\':\'anne\',\'local\':\'waeup.local.CourseAdviser100\'}]",'
+            'local_roles: user_name or local_role missing\r\n'
+            'FAC11,DEP2,CRT2,"[{\'user_name\':\'anne\',\'local_role\':\'waeup.local.CourseAdviser100\'}]",'
+            'Not all parents do exist yet. Skipping\r\n'
+            )
+        # Anne got a local role in certificate ABC.
+        dep = self.app['faculties']['FAC1']['DEP1'].certificates['CRT2']
+        role_map = IPrincipalRoleMap(dep)
+        local_role, user_name, setting = role_map.getPrincipalsAndRoles()[0]
+        self.assertEqual(user_name, 'anne')
+        self.assertEqual(local_role, 'waeup.local.CourseAdviser100')
+        shutil.rmtree(os.path.dirname(fin_file))
         return
 
