Index: /main/waeup.sirp/trunk/src/waeup/sirp/university/tests/test_export.py
===================================================================
--- /main/waeup.sirp/trunk/src/waeup/sirp/university/tests/test_export.py	(revision 7730)
+++ /main/waeup.sirp/trunk/src/waeup/sirp/university/tests/test_export.py	(revision 7731)
@@ -7,6 +7,6 @@
 from waeup.sirp.interfaces import ICSVExporter
 from waeup.sirp.testing import SIRPUnitTestLayer
-from waeup.sirp.university import FacultiesContainer, Faculty
-from waeup.sirp.university.export import FacultyExporter
+from waeup.sirp.university import FacultiesContainer, Faculty, Department
+from waeup.sirp.university.export import FacultyExporter, DepartmentExporter
 
 class FacultyExporterTest(unittest.TestCase):
@@ -32,13 +32,13 @@
     def test_get_as_utility(self):
         # we can get a faculty exporter as utility
-        result = queryUtility(ICSVExporter, name="Faculty Exporter")
+        result = queryUtility(ICSVExporter, name="faculties")
         self.assertTrue(result is not None)
         return
 
     def test_export(self):
-        # we can export single faculties (for what it's worth)
+        # we can export a set of faculties
         fac = Faculty('Faculty of Cheese', 'faculty', 'F1')
         exporter = FacultyExporter()
-        exporter.export(fac, self.outfile)
+        exporter.export([fac], self.outfile)
         result = open(self.outfile, 'rb').read()
         self.assertEqual(
@@ -50,8 +50,8 @@
 
     def test_export_to_string(self):
-        # we can export single faculties to a string.
+        # we can export a set of faculties to a string.
         fac = Faculty('Faculty of Cheese', 'faculty', 'F1')
         exporter = FacultyExporter()
-        result = exporter.export(fac, filepath=None)
+        result = exporter.export([fac], filepath=None)
         self.assertEqual(
             result,
@@ -97,2 +97,93 @@
             )
         return
+
+class DepartmentExporterTest(unittest.TestCase):
+    # Tests for DepartmentExporter
+
+    layer = SIRPUnitTestLayer
+
+    def setUp(self):
+        self.workdir = tempfile.mkdtemp()
+        self.outfile = os.path.join(self.workdir, 'myoutput.csv')
+        # create some departments in a fake site
+        container = FacultiesContainer()
+        self.site = {'faculties':container}
+        self.fac1 = Faculty('Faculty of Cheese', 'faculty', 'F1')
+        self.fac2 = Faculty('Centre of Onion', 'centre', 'F2')
+        container.addFaculty(self.fac1)
+        container.addFaculty(self.fac2)
+        self.dept1 = Department('Department of Cheddar', 'department', 'D1')
+        self.dept2 = Department('Institue of Gouda', 'institute', 'D2')
+        self.dept3 = Department('Department of Rings', 'department', 'D3')
+        self.fac1.addDepartment(self.dept1)
+        self.fac1.addDepartment(self.dept2)
+        self.fac2.addDepartment(self.dept3)
+        return
+
+    def tearDown(self):
+        shutil.rmtree(self.workdir)
+        return
+
+    def test_ifaces(self):
+        # make sure we fullfill interface contracts
+        obj = DepartmentExporter()
+        verifyObject(ICSVExporter, obj)
+        verifyClass(ICSVExporter, DepartmentExporter)
+        return
+
+    def test_get_as_utility(self):
+        # we can get a faculty exporter as utility
+        result = queryUtility(ICSVExporter, name="departments")
+        self.assertTrue(result is not None)
+        return
+
+    def test_export(self):
+        # we can export an iterable of departments
+        exporter = DepartmentExporter()
+        exporter.export([self.dept1], self.outfile)
+        result = open(self.outfile, 'rb').read()
+        self.assertEqual(
+            result,
+            'code,faculty,title,title_prefix\r\n'
+            'D1,F1,Department of Cheddar,department\r\n'
+            )
+        return
+
+    def test_export_to_string(self):
+        # we can export an iterable of departments to a string.
+        exporter = DepartmentExporter()
+        result = exporter.export([self.dept1, self.dept2], filepath=None)
+        self.assertEqual(
+            result,
+            'code,faculty,title,title_prefix\r\n'
+            'D1,F1,Department of Cheddar,department\r\n'
+            'D2,F1,Institue of Gouda,institute\r\n'
+            )
+        return
+
+    def test_export_all(self):
+        # we can export all depts in a site
+        exporter = DepartmentExporter()
+        exporter.export_all(self.site, self.outfile)
+        result = open(self.outfile, 'rb').read()
+        self.assertEqual(
+            result,
+            'code,faculty,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'
+            )
+        return
+
+    def test_export_all_to_string(self):
+        # we can export all depts in a site to a string
+        exporter = DepartmentExporter()
+        result = exporter.export_all(self.site, filepath=None)
+        self.assertEqual(
+            result,
+            'code,faculty,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'
+            )
+        return
