Index: main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_export.py
===================================================================
--- main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_export.py	(revision 13886)
+++ main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_export.py	(revision 13949)
@@ -6,10 +6,11 @@
 import unittest
 from zope.catalog.interfaces import ICatalog
-from zope.component import queryUtility, getUtility
+from zope.component import queryUtility, getUtility, createObject
 from zope.interface.verify import verifyObject, verifyClass
 from zope.intid.interfaces import IIntIds
 from waeup.kofa.applicants import ApplicantsContainer
 from waeup.kofa.applicants.export import (
-    ApplicantsContainerExporter, ApplicantExporter)
+    ApplicantsContainerExporter, ApplicantExporter,
+    ApplicantPaymentExporter)
 from waeup.kofa.applicants.interfaces import (
     AppCatSource, ApplicationTypeSource)
@@ -233,2 +234,90 @@
             in result)
         return
+
+
+class ApplicantPaymentExporterTest(ApplicantImportExportSetup):
+
+    layer = FunctionalLayer
+
+    def setUp(self):
+        super(ApplicantPaymentExporterTest, self).setUp()
+        self.outfile = os.path.join(self.workdir, 'myoutput.csv')
+        self.cat = getUtility(ICatalog, name='applicants_catalog')
+        self.intids = getUtility(IIntIds)
+        return
+
+    def test_ifaces(self):
+        # make sure we fullfill interface contracts
+        obj = ApplicantPaymentExporter()
+        verifyObject(ICSVExporter, obj)
+        verifyClass(ICSVExporter, ApplicantPaymentExporter)
+        return
+
+    def test_get_as_utility(self):
+        # we can get an applicant exporter as utility
+        result = queryUtility(ICSVExporter, name="applicantpayments")
+        self.assertTrue(result is not None)
+        return
+
+    def setup_applicant(self, applicant):
+        # set predictable values for `applicant`
+        applicant.reg_number = u'123456'
+        applicant.applicant_id = u'dp2011_654321'
+        applicant.firstname = u'Anna'
+        applicant.lastname = u'Tester'
+        applicant.middlename = u'M.'
+        applicant.date_of_birth = datetime.date(1981, 2, 4)
+        applicant.sex = 'f'
+        applicant.email = 'anna@sample.com'
+        applicant.phone = u'+234-123-12345'
+        # Add payment
+        payment = createObject(u'waeup.ApplicantOnlinePayment')
+        payment.p_id = 'p120'
+        payment.p_session = 2012
+        payment.p_category = 'application'
+        payment.p_state = 'paid'
+        applicant['p120'] = payment
+        return applicant
+
+    def test_export(self):
+        applicant = self.setup_applicant(self.applicant)
+        exporter = ApplicantPaymentExporter()
+        exporter.export(applicant.values(), self.outfile)
+        result = open(self.outfile, 'rb').read()
+        cdate = str('%s#' % self.applicant['p120'].creation_date)
+        self.assertEqual(
+            'ac,amount_auth,creation_date,p_category,p_id,p_item,p_session,'
+            'p_state,payment_date,r_amount_approved,r_code,r_desc,'
+            'applicant_id\r\n,'
+            '0.0,%s,application,p120,,2012,'
+            'paid,,0.0,,,dp2011_654321\r\n' % cdate, result)
+        return
+
+    def test_export_all(self):
+        self.applicant = self.setup_applicant(self.applicant)
+        exporter = ApplicantPaymentExporter()
+        exporter.export_all(self.app, self.outfile)
+        result = open(self.outfile, 'rb').read()
+        cdate = str('%s#' % self.applicant['p120'].creation_date)
+        self.assertEqual(
+            'ac,amount_auth,creation_date,p_category,p_id,p_item,p_session,'
+            'p_state,payment_date,r_amount_approved,r_code,r_desc,'
+            'applicant_id\r\n,'
+            '0.0,%s,application,p120,,2012,'
+            'paid,,0.0,,,dp2011_654321\r\n' % cdate, result)
+        return
+
+    def test_export_filtered(self):
+        self.applicant = self.setup_applicant(self.applicant)
+        exporter = ApplicantPaymentExporter()
+        exporter.export_filtered(
+            self.app, self.outfile, container=self.container.code)
+        result = open(self.outfile, 'rb').read()
+        cdate = str('%s#' % self.applicant['p120'].creation_date)
+        self.assertEqual(
+            'ac,amount_auth,creation_date,p_category,p_id,p_item,p_session,'
+            'p_state,payment_date,r_amount_approved,r_code,r_desc,'
+            'applicant_id\r\n,'
+            '0.0,%s,application,p120,,2012,'
+            'paid,,0.0,,,dp2011_654321\r\n' % cdate, result)
+        return
