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 7738)
+++ main/waeup.sirp/trunk/src/waeup/sirp/university/tests/test_export.py	(revision 7739)
@@ -7,6 +7,10 @@
 from waeup.sirp.interfaces import ICSVExporter
 from waeup.sirp.testing import SIRPUnitTestLayer
-from waeup.sirp.university import FacultiesContainer, Faculty, Department
-from waeup.sirp.university.export import FacultyExporter, DepartmentExporter
+from waeup.sirp.university import (
+    FacultiesContainer, Faculty, Department, Course,
+    )
+from waeup.sirp.university.export import (
+    FacultyExporter, DepartmentExporter, CourseExporter,
+    )
 
 class FacultyExporterTest(unittest.TestCase):
@@ -133,5 +137,5 @@
 
     def test_get_as_utility(self):
-        # we can get a faculty exporter as utility
+        # we can get a department exporter as utility
         result = queryUtility(ICSVExporter, name="departments")
         self.assertTrue(result is not None)
@@ -188,2 +192,95 @@
             )
         return
+
+class CourseExporterTest(unittest.TestCase):
+    # Tests for CourseExporter
+
+    layer = SIRPUnitTestLayer
+
+    def setUp(self):
+        self.workdir = tempfile.mkdtemp()
+        self.outfile = os.path.join(self.workdir, 'myoutput.csv')
+        # create some departments and courses in a fake site
+        container = FacultiesContainer()
+        self.site = {'faculties':container}
+        self.fac = Faculty('Faculty of Cheese', 'faculty', 'F1')
+        container.addFaculty(self.fac)
+        self.dept1 = Department('Department of Cheddar', 'department', 'D1')
+        self.dept2 = Department('Institue of Gouda', 'institute', 'D2')
+        self.fac.addDepartment(self.dept1)
+        self.fac.addDepartment(self.dept2)
+        self.course1 = Course('Cheese Basics', 'C1')
+        self.course2 = Course('Advanced Cheese Making', 'C2')
+        self.course3 = Course('Selling Cheese', 'C3')
+        self.dept1.courses[u'C1'] = self.course1
+        self.dept1.courses['C2'] = self.course2
+        self.dept2.courses[u'C3'] = self.course3
+        return
+
+    def tearDown(self):
+        shutil.rmtree(self.workdir)
+        return
+
+    def test_ifaces(self):
+        # make sure we fullfill interface contracts
+        obj = CourseExporter()
+        verifyObject(ICSVExporter, obj)
+        verifyClass(ICSVExporter, CourseExporter)
+        return
+
+    def test_get_as_utility(self):
+        # we can get a course exporter as utility
+        result = queryUtility(ICSVExporter, name="courses")
+        self.assertTrue(result is not None)
+        return
+
+    def test_export(self):
+        # we can export an iterable of courses
+        exporter = CourseExporter()
+        exporter.export([self.course1], self.outfile)
+        result = open(self.outfile, 'rb').read()
+        self.assertEqual(
+            result,
+            'code,faculty,department,title,credits,passmark,semester\r\n'
+            'C1,F1,,Cheese Basics,0,40,1\r\n'
+            )
+        return
+
+    def test_export_to_string(self):
+        # we can export an iterable of courses to a string.
+        exporter = CourseExporter()
+        result = exporter.export([self.course1, self.course2], filepath=None)
+        self.assertEqual(
+            result,
+            'code,faculty,department,title,credits,passmark,semester\r\n'
+            'C1,F1,,Cheese Basics,0,40,1\r\n'
+            'C2,F1,,Advanced Cheese Making,0,40,1\r\n'
+            )
+        return
+
+    def test_export_all(self):
+        # we can export all courses in a site
+        exporter = CourseExporter()
+        exporter.export_all(self.site, self.outfile)
+        result = open(self.outfile, 'rb').read()
+        self.assertEqual(
+            result,
+            'code,faculty,department,title,credits,passmark,semester\r\n'
+            'C1,F1,,Cheese Basics,0,40,1\r\n'
+            'C2,F1,,Advanced Cheese Making,0,40,1\r\n'
+            'C3,F1,,Selling Cheese,0,40,1\r\n'
+            )
+        return
+
+    def test_export_all_to_string(self):
+        # we can export all courses in a site to a string
+        exporter = CourseExporter()
+        result = exporter.export_all(self.site, filepath=None)
+        self.assertEqual(
+            result,
+            'code,faculty,department,title,credits,passmark,semester\r\n'
+            'C1,F1,,Cheese Basics,0,40,1\r\n'
+            'C2,F1,,Advanced Cheese Making,0,40,1\r\n'
+            'C3,F1,,Selling Cheese,0,40,1\r\n'
+            )
+        return
