Index: main/waeup.kofa/trunk/src/waeup/kofa/university/tests/test_export.py
===================================================================
--- main/waeup.kofa/trunk/src/waeup/kofa/university/tests/test_export.py	(revision 8920)
+++ main/waeup.kofa/trunk/src/waeup/kofa/university/tests/test_export.py	(revision 8986)
@@ -22,6 +22,7 @@
 from zope.component import queryUtility
 from zope.interface.verify import verifyObject, verifyClass
+from zope.securitypolicy.interfaces import IPrincipalRoleManager
 from waeup.kofa.interfaces import ICSVExporter
-from waeup.kofa.testing import KofaUnitTestLayer
+from waeup.kofa.testing import KofaUnitTestLayer, FunctionalLayer
 from waeup.kofa.university import (
     FacultiesContainer, Faculty, Department, Course, Certificate,
@@ -34,5 +35,5 @@
 class FacultyExporterTest(unittest.TestCase):
 
-    layer = KofaUnitTestLayer
+    layer = FunctionalLayer
 
     def setUp(self):
@@ -66,6 +67,6 @@
         self.assertEqual(
             result,
-            'code,title,title_prefix\r\n'
-            'F1,Faculty of Cheese,faculty\r\n'
+            'code,title,title_prefix,users_with_local_roles\r\n'
+            'F1,Faculty of Cheese,faculty,[]\r\n'
             )
         return
@@ -78,6 +79,6 @@
         self.assertEqual(
             result,
-            'code,title,title_prefix\r\n'
-            'F1,Faculty of Cheese,faculty\r\n'
+            'code,title,title_prefix,users_with_local_roles\r\n'
+            'F1,Faculty of Cheese,faculty,[]\r\n'
             )
         return
@@ -96,7 +97,7 @@
         self.assertEqual(
             result,
-            'code,title,title_prefix\r\n'
-            'F1,Faculty of Cheese,faculty\r\n'
-            'F2,Centre of Onion,centre\r\n'
+            'code,title,title_prefix,users_with_local_roles\r\n'
+            'F1,Faculty of Cheese,faculty,[]\r\n'
+            'F2,Centre of Onion,centre,[]\r\n'
             )
         return
@@ -114,7 +115,7 @@
         self.assertEqual(
             result,
-            'code,title,title_prefix\r\n'
-            'F1,Faculty of Cheese,faculty\r\n'
-            'F2,Centre of Onion,centre\r\n'
+            'code,title,title_prefix,users_with_local_roles\r\n'
+            'F1,Faculty of Cheese,faculty,[]\r\n'
+            'F2,Centre of Onion,centre,[]\r\n'
             )
         return
@@ -123,5 +124,5 @@
     # Tests for DepartmentExporter
 
-    layer = KofaUnitTestLayer
+    layer = FunctionalLayer
 
     def setUp(self):
@@ -141,4 +142,6 @@
         self.fac1.addDepartment(self.dept2)
         self.fac2.addDepartment(self.dept3)
+        role_manager = IPrincipalRoleManager(self.dept1)
+        role_manager.assignRoleToPrincipal(u'bobsrole', u'bob')
         return
 
@@ -167,6 +170,7 @@
         self.assertEqual(
             result,
-            'code,faculty_code,title,title_prefix\r\n'
-            'D1,F1,Department of Cheddar,department\r\n'
+            'code,faculty_code,title,title_prefix,users_with_local_roles\r\n'
+            'D1,F1,Department of Cheddar,department,'
+            '"[{\'user_name\': u\'bob\', \'local_role\': u\'bobsrole\'}]"\r\n'
             )
         return
@@ -178,7 +182,8 @@
         self.assertEqual(
             result,
-            'code,faculty_code,title,title_prefix\r\n'
-            'D1,F1,Department of Cheddar,department\r\n'
-            'D2,F1,Institue of Gouda,institute\r\n'
+            'code,faculty_code,title,title_prefix,users_with_local_roles\r\n'
+            'D1,F1,Department of Cheddar,department,'
+            '"[{\'user_name\': u\'bob\', \'local_role\': u\'bobsrole\'}]"\r\n'
+            'D2,F1,Institue of Gouda,institute,[]\r\n'
             )
         return
@@ -191,8 +196,9 @@
         self.assertEqual(
             result,
-            'code,faculty_code,title,title_prefix\r\n'
-            'D1,F1,Department of Cheddar,department\r\n'
-            'D2,F1,Institue of Gouda,institute\r\n'
-            'D3,F2,Department of Rings,department\r\n'
+            'code,faculty_code,title,title_prefix,users_with_local_roles\r\n'
+            'D1,F1,Department of Cheddar,department,'
+            '"[{\'user_name\': u\'bob\', \'local_role\': u\'bobsrole\'}]"\r\n'
+            'D2,F1,Institue of Gouda,institute,[]\r\n'
+            'D3,F2,Department of Rings,department,[]\r\n'
             )
         return
@@ -204,8 +210,9 @@
         self.assertEqual(
             result,
-            'code,faculty_code,title,title_prefix\r\n'
-            'D1,F1,Department of Cheddar,department\r\n'
-            'D2,F1,Institue of Gouda,institute\r\n'
-            'D3,F2,Department of Rings,department\r\n'
+            'code,faculty_code,title,title_prefix,users_with_local_roles\r\n'
+            'D1,F1,Department of Cheddar,department,'
+            '"[{\'user_name\': u\'bob\', \'local_role\': u\'bobsrole\'}]"\r\n'
+            'D2,F1,Institue of Gouda,institute,[]\r\n'
+            'D3,F2,Department of Rings,department,[]\r\n'
             )
         return
@@ -214,5 +221,5 @@
     # Tests for CourseExporter
 
-    layer = KofaUnitTestLayer
+    layer = FunctionalLayer
 
     def setUp(self):
@@ -260,6 +267,7 @@
         self.assertEqual(
             result,
-            'code,faculty_code,department_code,title,credits,passmark,semester\r\n'
-            'C1,F1,D1,Cheese Basics,0,40,1\r\n'
+            'code,faculty_code,department_code,title,credits,'
+            'passmark,semester,users_with_local_roles\r\n'
+            'C1,F1,D1,Cheese Basics,0,40,1,[]\r\n'
             )
         return
@@ -271,7 +279,8 @@
         self.assertEqual(
             result,
-            'code,faculty_code,department_code,title,credits,passmark,semester\r\n'
-            'C1,F1,D1,Cheese Basics,0,40,1\r\n'
-            'C2,F1,D1,Advanced Cheese Making,0,40,1\r\n'
+            'code,faculty_code,department_code,title,credits,passmark,'
+            'semester,users_with_local_roles\r\n'
+            'C1,F1,D1,Cheese Basics,0,40,1,[]\r\n'
+            'C2,F1,D1,Advanced Cheese Making,0,40,1,[]\r\n'
             )
         return
@@ -284,8 +293,9 @@
         self.assertEqual(
             result,
-            'code,faculty_code,department_code,title,credits,passmark,semester\r\n'
-            'C1,F1,D1,Cheese Basics,0,40,1\r\n'
-            'C2,F1,D1,Advanced Cheese Making,0,40,1\r\n'
-            'C3,F1,D2,Selling Cheese,0,40,1\r\n'
+            'code,faculty_code,department_code,title,credits,passmark,'
+            'semester,users_with_local_roles\r\n'
+            'C1,F1,D1,Cheese Basics,0,40,1,[]\r\n'
+            'C2,F1,D1,Advanced Cheese Making,0,40,1,[]\r\n'
+            'C3,F1,D2,Selling Cheese,0,40,1,[]\r\n'
             )
         return
@@ -297,8 +307,9 @@
         self.assertEqual(
             result,
-            'code,faculty_code,department_code,title,credits,passmark,semester\r\n'
-            'C1,F1,D1,Cheese Basics,0,40,1\r\n'
-            'C2,F1,D1,Advanced Cheese Making,0,40,1\r\n'
-            'C3,F1,D2,Selling Cheese,0,40,1\r\n'
+            'code,faculty_code,department_code,title,credits,passmark,'
+            'semester,users_with_local_roles\r\n'
+            'C1,F1,D1,Cheese Basics,0,40,1,[]\r\n'
+            'C2,F1,D1,Advanced Cheese Making,0,40,1,[]\r\n'
+            'C3,F1,D2,Selling Cheese,0,40,1,[]\r\n'
             )
         return
@@ -307,5 +318,5 @@
     # Tests for CertificateExporter
 
-    layer = KofaUnitTestLayer
+    layer = FunctionalLayer
 
     def setUp(self):
@@ -339,4 +350,6 @@
         self.dept1.certificates.addCertificate(self.cert2)
         self.dept2.certificates.addCertificate(self.cert3)
+        role_manager = IPrincipalRoleManager(self.cert1)
+        role_manager.assignRoleToPrincipal(u'bobsrole', u'bob')
         return
 
@@ -365,6 +378,9 @@
         self.assertEqual(
             result,
-            'code,faculty_code,department_code,title,study_mode,start_level,end_level,application_category,school_fee_1,school_fee_2\r\n'
-            'CERT1,F1,D1,Master of Cheese,ct_ft,100,300,basic,,\r\n'
+            'code,faculty_code,department_code,title,study_mode,start_level,'
+            'end_level,application_category,school_fee_1,'
+            'school_fee_2,users_with_local_roles\r\n'
+            'CERT1,F1,D1,Master of Cheese,ct_ft,100,300,basic,,,'
+            '"[{\'user_name\': u\'bob\', \'local_role\': u\'bobsrole\'}]"\r\n'
             )
         return
@@ -376,7 +392,10 @@
         self.assertEqual(
             result,
-            'code,faculty_code,department_code,title,study_mode,start_level,end_level,application_category,school_fee_1,school_fee_2\r\n'
-            'CERT1,F1,D1,Master of Cheese,ct_ft,100,300,basic,,\r\n'
-            'CERT2,F1,D1,Master of Cheddar,ct_ft,400,700,cest,,\r\n'
+            'code,faculty_code,department_code,title,study_mode,start_level,'
+            'end_level,application_category,school_fee_1,'
+            'school_fee_2,users_with_local_roles\r\n'
+            'CERT1,F1,D1,Master of Cheese,ct_ft,100,300,basic,,,'
+            '"[{\'user_name\': u\'bob\', \'local_role\': u\'bobsrole\'}]"\r\n'
+            'CERT2,F1,D1,Master of Cheddar,ct_ft,400,700,cest,,,[]\r\n'
             )
         return
@@ -389,8 +408,11 @@
         self.assertEqual(
             result,
-            'code,faculty_code,department_code,title,study_mode,start_level,end_level,application_category,school_fee_1,school_fee_2\r\n'
-            'CERT1,F1,D1,Master of Cheese,ct_ft,100,300,basic,,\r\n'
-            'CERT2,F1,D1,Master of Cheddar,ct_ft,400,700,cest,,\r\n'
-            'CERT3,F1,D2,Cert. of Rubbish,dp_pt,100,200,no,,\r\n'
+            'code,faculty_code,department_code,title,study_mode,start_level,'
+            'end_level,application_category,'
+            'school_fee_1,school_fee_2,users_with_local_roles\r\n'
+            'CERT1,F1,D1,Master of Cheese,ct_ft,100,300,basic,,,'
+            '"[{\'user_name\': u\'bob\', \'local_role\': u\'bobsrole\'}]"\r\n'
+            'CERT2,F1,D1,Master of Cheddar,ct_ft,400,700,cest,,,[]\r\n'
+            'CERT3,F1,D2,Cert. of Rubbish,dp_pt,100,200,no,,,[]\r\n'
             )
         return
@@ -402,8 +424,11 @@
         self.assertEqual(
             result,
-            'code,faculty_code,department_code,title,study_mode,start_level,end_level,application_category,school_fee_1,school_fee_2\r\n'
-            'CERT1,F1,D1,Master of Cheese,ct_ft,100,300,basic,,\r\n'
-            'CERT2,F1,D1,Master of Cheddar,ct_ft,400,700,cest,,\r\n'
-            'CERT3,F1,D2,Cert. of Rubbish,dp_pt,100,200,no,,\r\n'
+            'code,faculty_code,department_code,title,study_mode,start_level,'
+            'end_level,application_category,'
+            'school_fee_1,school_fee_2,users_with_local_roles\r\n'
+            'CERT1,F1,D1,Master of Cheese,ct_ft,100,300,basic,,,'
+            '"[{\'user_name\': u\'bob\', \'local_role\': u\'bobsrole\'}]"\r\n'
+            'CERT2,F1,D1,Master of Cheddar,ct_ft,400,700,cest,,,[]\r\n'
+            'CERT3,F1,D2,Cert. of Rubbish,dp_pt,100,200,no,,,[]\r\n'
             )
         return
