Index: main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py
===================================================================
--- main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py	(revision 9795)
+++ main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py	(revision 9797)
@@ -183,13 +183,23 @@
         exporter = StudentsExporter()
 
-        exporter.export_filtered(self.app, None, None, filepath=self.outfile)
+        exporter.export_filtered(
+            self.app, self.outfile,
+            current_session=None, current_level=None)
         result1 = open(self.outfile, 'rb').read()
-        exporter.export_filtered(self.app, 2012, None, filepath=self.outfile)
+        exporter.export_filtered(
+            self.app, self.outfile,
+            current_session=2012, current_level=None)
         result2 = open(self.outfile, 'rb').read()
-        exporter.export_filtered(self.app, None, 200, filepath=self.outfile)
+        exporter.export_filtered(
+            self.app, self.outfile,
+            current_session=None, current_level=200)
         result3 = open(self.outfile, 'rb').read()
-        exporter.export_filtered(self.app, 2011, None, filepath=self.outfile)
+        exporter.export_filtered(
+            self.app, self.outfile,
+            current_session=2011, current_level=None)
         result4 = open(self.outfile, 'rb').read()
-        exporter.export_filtered(self.app, None, 100, filepath=self.outfile)
+        exporter.export_filtered(
+            self.app, self.outfile,
+            current_session=None, current_level=100)
         result5 = open(self.outfile, 'rb').read()
         self.assertTrue(self.std_csv_entry in result1)
@@ -207,9 +217,11 @@
         exporter = StudentsExporter()
 
-        exporter.export_filtered(self.app, 2012, 200, depcode='NA',
-                                 filepath=self.outfile)
+        exporter.export_filtered(
+            self.app, self.outfile,
+            current_session=2012, current_level=200, depcode='NA')
         result1 = open(self.outfile, 'rb').read()
-        exporter.export_filtered(self.app, 2012, 200, depcode='NODEPT',
-                                 filepath=self.outfile)
+        exporter.export_filtered(
+            self.app, self.outfile,
+            current_session=2012, current_level=200, depcode='NODEPT')
         result2 = open(self.outfile, 'rb').read()
         self.assertTrue(self.std_csv_entry in result1)
@@ -225,8 +237,10 @@
 
         exporter.export_filtered(
-            self.app, 2012, 200, faccode='NA', filepath=self.outfile)
+            self.app, self.outfile,
+            current_session=2012, current_level=200, faccode='NA')
         result1 = open(self.outfile, 'rb').read()
-        exporter.export_filtered(self.app, 2012, 200, faccode='NOFAC',
-                                 filepath=self.outfile)
+        exporter.export_filtered(
+            self.app, self.outfile,
+            current_session=2012, current_level=200, faccode='NOFAC')
         result2 = open(self.outfile, 'rb').read()
         self.assertTrue(self.std_csv_entry in result1)
@@ -234,5 +248,4 @@
         return
 
-
 class StudentStudyCourseExporterTest(StudentImportExportSetup):
 
@@ -247,6 +260,6 @@
         # make sure we fullfill interface contracts
         obj = StudentStudyCourseExporter()
-        verifyObject(ICSVExporter, obj)
-        verifyClass(ICSVExporter, StudentStudyCourseExporter)
+        verifyObject(ICSVStudentExporter, obj)
+        verifyClass(ICSVStudentExporter, StudentStudyCourseExporter)
         return
 
@@ -320,4 +333,25 @@
         return
 
+    def test_export_filtered(self):
+        # we can export studycourses of a filtered set of students
+        self.setup_student(self.student)
+        self.app['students'].addStudent(self.student)
+        notify(grok.ObjectModifiedEvent(self.student))
+
+        exporter = StudentStudyCourseExporter()
+        exporter.export_filtered(
+            self.student, self.outfile, current_session=2012)
+        result = open(self.outfile, 'rb').read()
+        self.assertEqual(
+            result,
+            'certificate,current_level,current_session,current_verdict,'
+            'entry_mode,entry_session,previous_verdict,student_id\r\n'
+
+            'CERT1,200,2012,0,ug_ft,2010,0,A111111\r\n'
+            )
+        return
+
+
+
 class StudentStudyLevelExporterTest(StudentImportExportSetup):
 
@@ -332,6 +366,6 @@
         # make sure we fullfill interface contracts
         obj = StudentStudyLevelExporter()
-        verifyObject(ICSVExporter, obj)
-        verifyClass(ICSVExporter, StudentStudyLevelExporter)
+        verifyObject(ICSVStudentExporter, obj)
+        verifyClass(ICSVStudentExporter, StudentStudyLevelExporter)
         return
 
@@ -406,4 +440,23 @@
         return
 
+    def test_export_filtered(self):
+        # we can export studylevels of a filtered set of students
+        self.setup_student(self.student)
+        self.app['students'].addStudent(self.student)
+        notify(grok.ObjectModifiedEvent(self.student))
+
+        exporter = StudentStudyLevelExporter()
+        exporter.export_filtered(
+            self.student, self.outfile, current_level=200)
+        result = open(self.outfile, 'rb').read()
+        self.assertEqual(
+            result,
+            'gpa,level,level_session,level_verdict,total_credits,'
+            'validated_by,validation_date,'
+            'student_id,number_of_tickets,certcode\r\n'
+            '0.0,100,2012,A,100,,,A111111,1,CERT1\r\n'
+            )
+        return
+
 class CourseTicketExporterTest(StudentImportExportSetup):
 
@@ -418,6 +471,6 @@
         # make sure we fullfill interface contracts
         obj = CourseTicketExporter()
-        verifyObject(ICSVExporter, obj)
-        verifyClass(ICSVExporter, CourseTicketExporter)
+        verifyObject(ICSVStudentExporter, obj)
+        verifyClass(ICSVStudentExporter, CourseTicketExporter)
         return
 
@@ -489,4 +542,22 @@
         return
 
+    def test_export_filtered(self):
+        # we can export studylevels of a filtered set of students
+        self.setup_student(self.student)
+        self.app['students'].addStudent(self.student)
+        notify(grok.ObjectModifiedEvent(self.student))
+
+        exporter = CourseTicketExporter()
+        exporter.export_filtered(
+            self.student, self.outfile, current_level=200)
+        result = open(self.outfile, 'rb').read()
+        self.assertEqual(
+            result,
+            'automatic,carry_over,code,credits,dcode,fcode,level,mandatory,'
+            'passmark,score,semester,title,student_id,certcode\r\n'
+            '1,1,CRS1,100,DEP1,FAC1,100,0,100,,2,Course 1,A111111,CERT1\r\n'
+            )
+        return
+
 class PaymentsExporterTest(StudentImportExportSetup):
 
@@ -501,6 +572,6 @@
         # make sure we fullfill interface contracts
         obj = PaymentsExporter()
-        verifyObject(ICSVExporter, obj)
-        verifyClass(ICSVExporter, PaymentsExporter)
+        verifyObject(ICSVStudentExporter, obj)
+        verifyClass(ICSVStudentExporter, PaymentsExporter)
         return
 
@@ -586,4 +657,26 @@
         return
 
+    def test_export_filtered(self):
+        # we can export payments of a filtered set of students
+        self.setup_student(self.student)
+        self.app['students'].addStudent(self.student)
+        notify(grok.ObjectModifiedEvent(self.student))
+
+        exporter = PaymentsExporter()
+        exporter.export_filtered(
+            self.student, self.outfile, current_level=200)
+        result = open(self.outfile, 'rb').read()
+        self.assertEqual(
+            result,
+            'ac,amount_auth,creation_date,p_category,p_current,p_id,'
+            'p_item,p_level,p_session,p_state,payment_date,r_amount_approved,'
+            'r_code,r_desc,student_id,student_state,current_session\r\n'
+
+            '666,0.0,2012-04-01 13:12:01,schoolfee,1,my-id,'
+            'p-item,100,2012,unpaid,2012-04-01 14:12:01,12.12,'
+            'r-code,,A111111,created,2012\r\n'
+            )
+        return
+
 class BedTicketsExporterTest(StudentImportExportSetup):
 
@@ -598,6 +691,6 @@
         # make sure we fullfill interface contracts
         obj = BedTicketsExporter()
-        verifyObject(ICSVExporter, obj)
-        verifyClass(ICSVExporter, BedTicketsExporter)
+        verifyObject(ICSVStudentExporter, obj)
+        verifyClass(ICSVStudentExporter, BedTicketsExporter)
         return
 
@@ -673,4 +766,23 @@
         return
 
+    def test_export_filtered(self):
+        # we can export payments of a filtered set of students
+        self.setup_student(self.student)
+        self.app['students'].addStudent(self.student)
+        notify(grok.ObjectModifiedEvent(self.student))
+
+        exporter = BedTicketsExporter()
+        exporter.export_filtered(
+            self.student, self.outfile, current_level=200)
+        result = open(self.outfile, 'rb').read()
+        self.assertMatches(
+            result,
+            'bed,bed_coordinates,bed_type,booking_code,booking_date,'
+            'booking_session,student_id,actual_bed_type\r\n'
+            'hall-1_A_101_A,,any bed type,,<YYYY-MM-DD hh:mm:ss>.<6-DIGITS>,'
+            '2004,A111111,regular_male_fr\r\n')
+        return
+
+
 class StudentPaymentsOverviewExporterTest(StudentImportExportSetup):
 
@@ -685,6 +797,6 @@
         # make sure we fullfill interface contracts
         obj = StudentPaymentsOverviewExporter()
-        verifyObject(ICSVExporter, obj)
-        verifyClass(ICSVExporter, StudentPaymentsOverviewExporter)
+        verifyObject(ICSVStudentExporter, obj)
+        verifyClass(ICSVStudentExporter, StudentPaymentsOverviewExporter)
         return
 
@@ -744,6 +856,6 @@
     def test_ifaces(self):
         obj = StudentStudyLevelsOverviewExporter()
-        verifyObject(ICSVExporter, obj)
-        verifyClass(ICSVExporter, StudentStudyLevelsOverviewExporter)
+        verifyObject(ICSVStudentExporter, obj)
+        verifyClass(ICSVStudentExporter, StudentStudyLevelsOverviewExporter)
         return
 
