Ignore:
Timestamp:
8 Nov 2012, 13:25:38 (12 years ago)
Author:
Henrik Bettermann
Message:

Add StudentPaymentsOverviewExporter?.

File:
1 edited

Legend:

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

    r9543 r9574  
    55from waeup.kofa.students.export import (
    66    StudentsExporter, StudentStudyCourseExporter, StudentStudyLevelExporter,
    7     CourseTicketExporter, PaymentsExporter, BedTicketsExporter)
     7    CourseTicketExporter, PaymentsExporter, BedTicketsExporter,
     8    StudentPaymentsOverviewExporter)
    89from waeup.kofa.students.payments import StudentOnlinePayment
    910from waeup.kofa.students.accommodation import BedTicket
     
    1213from waeup.kofa.students.tests.test_batching import StudentImportExportSetup
    1314from waeup.kofa.testing import FunctionalLayer
     15
     16curr_year = datetime.datetime.now().year
     17year_range = range(curr_year - 9, curr_year + 1)
     18year_range_str = ','.join([str(i) for i in year_range])
     19
    1420
    1521class StudentsExporterTest(StudentImportExportSetup):
     
    531537            )
    532538        return
     539
     540class StudentPaymentsOverviewExporterTest(StudentImportExportSetup):
     541
     542    layer = FunctionalLayer
     543
     544    def setUp(self):
     545        super(StudentPaymentsOverviewExporterTest, self).setUp()
     546        self.setup_for_export()
     547        return
     548
     549    def test_ifaces(self):
     550        # make sure we fullfill interface contracts
     551        obj = StudentPaymentsOverviewExporter()
     552        verifyObject(ICSVExporter, obj)
     553        verifyClass(ICSVExporter, StudentPaymentsOverviewExporter)
     554        return
     555
     556    def test_get_as_utility(self):
     557        # we can get a payments exporter as utility
     558        result = queryUtility(ICSVExporter, name="paymentsoverview")
     559        self.assertTrue(result is not None)
     560        return
     561
     562    def test_export(self):
     563        self.setup_student(self.student)
     564        exporter = StudentPaymentsOverviewExporter()
     565        exporter.export([self.student], self.outfile)
     566        result = open(self.outfile, 'rb').read()
     567        self.assertEqual(
     568            'student_id,state,certcode,faccode,depcode,is_postgrad,'
     569            'current_level,current_session,'
     570            '%s\r\n'
     571            'A111111,created,CERT1,NA,NA,0,200,2012,'
     572            ',,,,,,,,,\r\n' % year_range_str,
     573            result
     574            )
     575        return
     576
     577    def test_export_all(self):
     578        # we can really export students
     579        # set values we can expect in export file
     580        self.setup_student(self.student)
     581        # We add successful payments
     582        payment = StudentOnlinePayment()
     583        payment.p_id = 'my-id'
     584        payment.p_session = 2009
     585        payment.amount_auth = 12.12
     586        payment.p_state = u'paid'
     587        self.student['payments']['my-2ndpayment'] = payment
     588        exporter = StudentPaymentsOverviewExporter()
     589        exporter.export_all(self.app, self.outfile)
     590        result = open(self.outfile, 'rb').read()
     591        self.assertEqual(
     592            'student_id,state,certcode,faccode,depcode,is_postgrad,'
     593            'current_level,current_session,'
     594            '%s\r\nA111111,created,CERT1,NA,NA,0,'
     595            '200,2012,,,,,,,12.12,,,\r\n' % year_range_str,
     596            result
     597            )
     598        return
Note: See TracChangeset for help on using the changeset viewer.