Index: main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py
===================================================================
--- main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py	(revision 11702)
+++ main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py	(revision 11730)
@@ -3233,4 +3233,65 @@
         return job_id
 
+    def test_datacenter_export(self):
+        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
+        self.browser.open('http://localhost/app/datacenter/@@exportconfig')
+        self.browser.getControl(name="exporter").value = ['bursary']
+        self.browser.getControl(name="session").value = ['2004']
+        self.browser.getControl(name="level").value = ['100']
+        self.browser.getControl(name="mode").value = ['ug_ft']
+        self.browser.getControl(name="payments_start").value = '13/12/2012'
+        self.browser.getControl(name="payments_end").value = '14/12/2012'
+        self.browser.getControl("Create CSV file").click()
+
+        # When the job is finished and we reload the page...
+        job_id = self.wait_for_export_job_completed()
+        # ... the csv file can be downloaded ...
+        self.browser.open('http://localhost/app/datacenter/@@export')
+        self.browser.getLink("Download").click()
+        self.assertEqual(self.browser.headers['content-type'],
+            'text/csv; charset=UTF-8')
+        self.assertTrue(
+            'filename="WAeUP.Kofa_bursary_%s.csv' % job_id in
+            self.browser.headers['content-disposition'])
+        self.assertEqual(len(self.app['datacenter'].running_exports), 1)
+        job_id = self.app['datacenter'].running_exports[0][0]
+        # ... and discarded
+        self.browser.open('http://localhost/app/datacenter/@@export')
+        self.browser.getControl("Discard").click()
+        self.assertEqual(len(self.app['datacenter'].running_exports), 0)
+        # Creation, downloading and discarding is logged
+        logfile = os.path.join(
+            self.app['datacenter'].storage, 'logs', 'datacenter.log')
+        logcontent = open(logfile).read()
+        self.assertTrue(
+            'zope.mgr - students.browser.DatacenterExportJobContainerJobConfig '
+            '- exported: bursary (2004, 100, ug_ft, None, None, '
+            '13/12/2012, 14/12/2012), job_id=%s'
+            % job_id in logcontent
+            )
+        self.assertTrue(
+            'zope.mgr - browser.pages.ExportCSVView '
+            '- downloaded: WAeUP.Kofa_bursary_%s.csv, job_id=%s'
+            % (job_id, job_id) in logcontent
+            )
+        self.assertTrue(
+            'zope.mgr - browser.pages.ExportCSVPage '
+            '- discarded: job_id=%s' % job_id in logcontent
+            )
+
+    def test_payment_dates(self):
+        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
+        self.browser.open('http://localhost/app/datacenter/@@exportconfig')
+        self.browser.getControl(name="exporter").value = ['bursary']
+        self.browser.getControl(name="session").value = ['2004']
+        self.browser.getControl(name="level").value = ['100']
+        self.browser.getControl(name="mode").value = ['ug_ft']
+        self.browser.getControl(name="payments_start").value = '13/12/2012'
+        # If one payment date is missing, an error message appears
+        self.browser.getControl(name="payments_end").value = ''
+        self.browser.getControl("Create CSV file").click()
+        self.assertTrue('Payment dates do not match format d/m/Y'
+            in self.browser.contents)
+
     def test_faculties_export(self):
         self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
@@ -3243,4 +3304,6 @@
         self.browser.getControl(name="level").value = ['100']
         self.browser.getControl(name="mode").value = ['ug_ft']
+        self.browser.getControl(name="payments_start").value = '13/12/2012'
+        self.browser.getControl(name="payments_end").value = '14/12/2012'
         self.browser.getControl("Create CSV file").click()
 
@@ -3267,5 +3330,6 @@
         self.assertTrue(
             'zope.mgr - students.browser.FacultiesExportJobContainerJobConfig '
-            '- exported: bursary (2004, 100, ug_ft, None, None), job_id=%s'
+            '- exported: bursary (2004, 100, ug_ft, None, None, '
+            '13/12/2012, 14/12/2012), job_id=%s'
             % job_id in logcontent
             )
@@ -3290,4 +3354,8 @@
         self.browser.getControl(name="level").value = ['100']
         self.browser.getControl(name="mode").value = ['ug_ft']
+        # The testbrowser does not hide the payment period fields, but
+        # values are ignored when using the students exporter.
+        self.browser.getControl(name="payments_start").value = '13/12/2012'
+        self.browser.getControl(name="payments_end").value = '14/12/2012'
         self.browser.getControl("Create CSV file").click()
 
@@ -3314,5 +3382,6 @@
         self.assertTrue(
             'zope.mgr - students.browser.DepartmentExportJobContainerJobConfig '
-            '- exported: students (2004, 100, ug_ft, dep1, None), job_id=%s'
+            '- exported: students (2004, 100, ug_ft, dep1, None, '
+            '13/12/2012, 14/12/2012), job_id=%s'
             % job_id in logcontent
             )
@@ -3360,5 +3429,6 @@
         self.assertTrue(
             'zope.mgr - students.browser.CertificateExportJobContainerJobConfig '
-            '- exported: students (2004, 100, None, None, CERT1), job_id=%s'
+            '- exported: students (2004, 100, None, None, CERT1, None, None), '
+            'job_id=%s'
             % job_id in logcontent
             )
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 11702)
+++ main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py	(revision 11730)
@@ -761,4 +761,62 @@
         return
 
+    def test_export_filtered_by_date(self):
+        # payments_start and payments_end are being ignored
+        self.setup_student(self.student)
+        self.app['students'].addStudent(self.student)
+        notify(grok.ObjectModifiedEvent(self.student))
+        exporter = StudentPaymentsExporter()
+        # A key xxx does not exist
+        self.assertRaises(
+            KeyError, exporter.export_filtered, self.app, self.outfile,
+            current_session=None,
+            current_level=None, xxx='nonsense')
+        # payments_start and payments_end do exist but must match format '%Y-%m-%d'
+        self.assertRaises(
+            ValueError, exporter.export_filtered, self.app, self.outfile,
+            current_session=None, current_level=None,
+            payments_start='nonsense', payments_end='nonsense')
+        # If they match the format they are ignored by get_filtered and the
+        # exporter works properly
+        exporter.export_filtered(
+            self.app, self.outfile,
+            current_session=None, current_level=None,
+            payments_start='01/04/2012', payments_end='02/04/2012')
+        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,state,current_session\r\n'
+
+            '666,12.12,2012-04-01 13:12:01,schoolfee,1,my-id,'
+            'p-item,100,2012,paid,2012-04-01 14:12:01,12.12,'
+            'r-code,,A111111,created,2012\r\n'
+            )
+        # no results if payment_date is outside the given period
+        exporter.export_filtered(
+            self.app, self.outfile,
+            current_session=None, current_level=None,
+            payments_start='31/03/2012', payments_end='01/04/2012')
+        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,state,current_session\r\n'
+            )
+        exporter.export_filtered(
+            self.app, self.outfile,
+            current_session=None, current_level=None,
+            payments_start='02/04/2012', payments_end='03/04/2012')
+        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,state,current_session\r\n'
+            )
+        return
+
 class BursaryDataExporterTest(StudentImportExportSetup):
 
