Ignore:
Timestamp:
12 Jun 2018, 12:38:33 (7 years ago)
Author:
Henrik Bettermann
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py

    r15047 r15051  
    3232    SchoolFeePaymentsOverviewExporter, StudentStudyLevelsOverviewExporter,
    3333    ComboCardDataExporter, DataForBursaryExporter,
    34     StudentUnpaidPaymentExporter,
     34    StudentUnpaidPaymentExporter, SessionPaymentsOverviewExporter,
    3535    get_students,)
    3636from waeup.kofa.students.accommodation import BedTicket
     
    12321232        return
    12331233
     1234class SessionPaymentsOverviewExporterTest(StudentImportExportSetup):
     1235
     1236    layer = FunctionalLayer
     1237
     1238    def setUp(self):
     1239        super(SessionPaymentsOverviewExporterTest, self).setUp()
     1240        self.setup_for_export()
     1241        return
     1242
     1243    def test_ifaces(self):
     1244        # make sure we fullfill interface contracts
     1245        obj = SessionPaymentsOverviewExporter()
     1246        verifyObject(ICSVStudentExporter, obj)
     1247        verifyClass(ICSVStudentExporter, SessionPaymentsOverviewExporter)
     1248        return
     1249
     1250    def test_get_as_utility(self):
     1251        # we can get a payments exporter as utility
     1252        result = queryUtility(ICSVExporter, name="sessionpaymentsoverview")
     1253        self.assertTrue(result is not None)
     1254        return
     1255
     1256    def test_export(self):
     1257        self.setup_student(self.student)
     1258        exporter = SessionPaymentsOverviewExporter()
     1259        exporter.export([self.student], self.outfile)
     1260        result = open(self.outfile, 'rb').read()
     1261        self.assertTrue(
     1262            'student_id,matric_number,display_fullname,state,certcode,'
     1263            'faccode,depcode,is_postgrad,current_level,current_session,'
     1264            'current_mode,entry_session,reg_number,schoolfee,clearance,'
     1265            'gown,transcript\r\n'
     1266            'A111111,234,Anna M. Tester,created,CERT1,NA,NA,0,200,2012,'
     1267            'ug_ft,2010,123,2012,,,' in result
     1268            )
     1269        return
     1270
     1271    def test_export_all(self):
     1272        # we can really export students
     1273        # set values we can expect in export file
     1274        self.setup_student(self.student)
     1275        # We add successful payments.
     1276        payment_2 = StudentOnlinePayment()
     1277        payment_2.p_id = 'my-id'
     1278        payment_2.p_session = curr_year - 5
     1279        payment_2.amount_auth = 13.13
     1280        payment_2.p_state = 'paid'
     1281        payment_2.p_category = u'schoolfee'
     1282        self.student['payments']['my-2ndpayment'] = payment_2
     1283        # This one could be a balance payment.
     1284        # The amount is being added.
     1285        payment_3 = StudentOnlinePayment()
     1286        payment_3.p_id = 'my-id_2'
     1287        payment_3.p_session = curr_year - 5
     1288        payment_3.amount_auth = 1.01
     1289        payment_3.p_state = 'paid'
     1290        payment_3.p_category = u'schoolfee'
     1291        self.student['payments']['my-3rdpayment'] = payment_3
     1292        # One session school fee has been waived
     1293        payment_4 = StudentOnlinePayment()
     1294        payment_4.p_id = 'my-id_2'
     1295        payment_4.p_session = curr_year - 4
     1296        payment_4.amount_auth = 1.01
     1297        payment_4.p_state = 'waived'
     1298        payment_4.p_category = u'schoolfee'
     1299        self.student['payments']['my-4thpayment'] = payment_4
     1300        exporter = SessionPaymentsOverviewExporter()
     1301        exporter.export_all(self.app, self.outfile)
     1302        result = open(self.outfile, 'rb').read()
     1303        self.assertTrue(
     1304            'student_id,matric_number,display_fullname,state,certcode,'
     1305            'faccode,depcode,is_postgrad,current_level,current_session,'
     1306            'current_mode,entry_session,reg_number,schoolfee,clearance,'
     1307            'gown,transcript\r\nA111111,234,Anna M. Tester,created,CERT1,'
     1308            'NA,NA,0,200,2012,ug_ft,2010,123,2013+2013+2014+2012,,,\r\n'
     1309            in result
     1310            )
     1311        return
     1312
    12341313class StudentStudyLevelsOverviewExporterTest(StudentImportExportSetup):
    12351314
Note: See TracChangeset for help on using the changeset viewer.