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 9761)
+++ main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py	(revision 9763)
@@ -42,9 +42,9 @@
     def test_get_students_by_session(self):
         # we can filter out students of a certain session
-        my_filter1 = StudentsExportFilter(session=2012)
+        my_filter1 = StudentsExportFilter(current_session=2012)
         result = get_students(self.app, stud_filter=my_filter1)
         self.assertEqual(len(list(result)), 1)
 
-        my_filter2 = StudentsExportFilter(session=1964)
+        my_filter2 = StudentsExportFilter(current_session=1964)
         result = get_students(self.app, stud_filter=my_filter2)
         self.assertEqual(len(list(result)), 0)
@@ -53,16 +53,45 @@
     def test_get_students_by_level(self):
         # we can filter out students of a certain level
-        my_filter1 = StudentsExportFilter(level=200)
+        my_filter1 = StudentsExportFilter(current_level=200)
         result = get_students(self.app, stud_filter=my_filter1)
         self.assertEqual(len(list(result)), 1)
 
-        my_filter2 = StudentsExportFilter(level=300)
+        my_filter2 = StudentsExportFilter(current_level=300)
         result = get_students(self.app, stud_filter=my_filter2)
         self.assertEqual(len(list(result)), 0)
         return
 
+    def test_get_students_by_deptcode(self):
+        # we can filter out students of a certain dept.
+        my_filter1 = StudentsExportFilter(depcode='NA')
+        result = get_students(self.app, stud_filter=my_filter1)
+        self.assertEqual(len(list(result)), 1)
+
+        my_filter2 = StudentsExportFilter(depcode='NOTEXISTING')
+        result = get_students(self.app, stud_filter=my_filter2)
+        self.assertEqual(len(list(result)), 0)
+        return
+
+    def test_get_students_by_faccode(self):
+        # we can filter out students of a certain faculty.
+        my_filter1 = StudentsExportFilter(faccode='NA')
+        result = get_students(self.app, stud_filter=my_filter1)
+        self.assertEqual(len(list(result)), 1)
+
+        my_filter2 = StudentsExportFilter(faccode='NOTEXISTING')
+        result = get_students(self.app, stud_filter=my_filter2)
+        self.assertEqual(len(list(result)), 0)
+        return
+
+
 class StudentsExporterTest(StudentImportExportSetup):
 
     layer = FunctionalLayer
+
+    std_csv_entry = (
+        'my adm code,0,my clr code,1981-02-04#,anna@sample.com,,'
+        'Anna,Tester,234,M.,NG,,"Studentroad 21\nLagos 123456\n",,'
+        '+234-123-12345#,123,f,A111111,0,,,created'
+        )
 
     def setUp(self):
@@ -144,4 +173,62 @@
             in result
             )
+        return
+
+    def test_export_filtered(self):
+        # we can export a filtered set of students (filtered by session/level)
+        self.setup_student(self.student)
+        self.app['students'].addStudent(self.student)
+        notify(grok.ObjectModifiedEvent(self.student))
+        exporter = StudentsExporter()
+
+        exporter.export_filtered(self.app, None, None, filepath=self.outfile)
+        result1 = open(self.outfile, 'rb').read()
+        exporter.export_filtered(self.app, 2012, None, filepath=self.outfile)
+        result2 = open(self.outfile, 'rb').read()
+        exporter.export_filtered(self.app, None, 200, filepath=self.outfile)
+        result3 = open(self.outfile, 'rb').read()
+        exporter.export_filtered(self.app, 2011, None, filepath=self.outfile)
+        result4 = open(self.outfile, 'rb').read()
+        exporter.export_filtered(self.app, None, 100, filepath=self.outfile)
+        result5 = open(self.outfile, 'rb').read()
+        self.assertTrue(self.std_csv_entry in result1)
+        self.assertTrue(self.std_csv_entry in result2)
+        self.assertTrue(self.std_csv_entry in result3)
+        self.assertTrue(self.std_csv_entry not in result4)
+        self.assertTrue(self.std_csv_entry not in result5)
+        return
+
+    def test_export_filtered_by_dept(self):
+        # we can export a set of students filtered by department
+        self.setup_student(self.student)
+        self.app['students'].addStudent(self.student)
+        notify(grok.ObjectModifiedEvent(self.student))
+        exporter = StudentsExporter()
+
+        exporter.export_filtered(self.app, 2012, 200, depcode='NA',
+                                 filepath=self.outfile)
+        result1 = open(self.outfile, 'rb').read()
+        exporter.export_filtered(self.app, 2012, 200, depcode='NODEPT',
+                                 filepath=self.outfile)
+        result2 = open(self.outfile, 'rb').read()
+        self.assertTrue(self.std_csv_entry in result1)
+        self.assertTrue(self.std_csv_entry not in result2)
+        return
+
+    def test_export_filtered_by_faculty(self):
+        # we can export a set of students filtered by faculty
+        self.setup_student(self.student)
+        self.app['students'].addStudent(self.student)
+        notify(grok.ObjectModifiedEvent(self.student))
+        exporter = StudentsExporter()
+
+        exporter.export_filtered(
+            self.app, 2012, 200, faccode='NA', filepath=self.outfile)
+        result1 = open(self.outfile, 'rb').read()
+        exporter.export_filtered(self.app, 2012, 200, faccode='NOFAC',
+                                 filepath=self.outfile)
+        result2 = open(self.outfile, 'rb').read()
+        self.assertTrue(self.std_csv_entry in result1)
+        self.assertTrue(self.std_csv_entry not in result2)
         return
 
