source: main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/students/tests/test_export.py @ 17389

Last change on this file since 17389 was 17294, checked in by Henrik Bettermann, 22 months ago

Adjust to base package.

  • Property svn:keywords set to Id
File size: 3.4 KB
Line 
1import datetime
2from zope.component import queryUtility
3from zope.interface.verify import verifyObject, verifyClass
4from waeup.kofa.interfaces import ICSVExporter
5from waeup.kofa.schoolgrades import ResultEntry
6from waeup.kofa.students.tests.test_batching import (
7    StudentImportExportSetup, curr_year)
8from kofacustom.iuokada.utils.utils import CustomKofaUtils
9from kofacustom.iuokada.students.export import (
10    CustomStudentExporter, CustomStudentPaymentExporter)
11from kofacustom.iuokada.testing import FunctionalLayer
12
13
14class CustomStudentExporterTest(StudentImportExportSetup):
15
16    layer = FunctionalLayer
17
18    def setUp(self):
19        super(CustomStudentExporterTest, self).setUp()
20        self.setup_for_export()
21        result_entry = ResultEntry(
22            CustomKofaUtils.EXAM_SUBJECTS_DICT.keys()[0],
23            CustomKofaUtils.EXAM_GRADES[0][0]
24            )
25        self.student.alr_results = [
26            result_entry]
27        self.student.fst_sit_results = [
28            result_entry]
29        self.student.scd_sit_results = [
30            result_entry]
31        return
32
33    def test_ifaces(self):
34        # make sure we fullfill interface contracts
35        obj = CustomStudentExporter()
36        verifyObject(ICSVExporter, obj)
37        verifyClass(ICSVExporter, CustomStudentExporter)
38        return
39
40
41    def test_export_all(self):
42        # we can really export students
43        # set values we can expect in export file
44        self.setup_student(self.student)
45        exporter = CustomStudentExporter()
46        exporter.export_all(self.app, self.outfile)
47        result = open(self.outfile, 'rb').read()
48        self.assertTrue('entry_session' in result)
49        return
50
51class CustomStudentPaymentExporterTest(StudentImportExportSetup):
52
53    layer = FunctionalLayer
54
55    def setUp(self):
56        super(CustomStudentPaymentExporterTest, self).setUp()
57        self.setup_for_export()
58        return
59
60    def test_ifaces(self):
61        # make sure we fullfill interface contracts
62        obj = CustomStudentPaymentExporter()
63        verifyObject(ICSVExporter, obj)
64        verifyClass(ICSVExporter, CustomStudentPaymentExporter)
65        return
66
67    def test_export_all(self):
68        # we can really export students
69        # set values we can expect in export file
70        self.setup_student(self.student)
71        self.student['payments']['my-payment'].r_company = 'interswitch'
72        self.student['payments']['my-payment'].p_option = 'first'
73        self.student['payments']['my-payment'].r_card_num = '789'
74        exporter = CustomStudentPaymentExporter()
75        exporter.export_all(self.app, self.outfile)
76        result = open(self.outfile, 'rb').read()
77        self.assertMatches(
78            'ac,amount_auth,creation_date,gateway_amt,net_amt,p_category,p_combi,p_currency,p_current,'
79            'p_id,p_item,p_level,p_option,p_session,p_state,payment_date,provider_amt,'
80            'r_amount_approved,r_card_num,r_code,r_company,r_desc,'
81            'r_pay_reference,r_payment_link,thirdparty_amt,student_id,state,'
82            'current_session,entry_session,faculty,department\r\n'
83            '666,12.12,%s-04-01 13:12:01#,,,schoolfee,[],,1,my-id,p-item,'
84            '100,first,%s,paid,%s-04-01 14:12:01#,,12.12,'
85            '789,r-code,interswitch,,,,,A111111,created,2012,2010,'
86            'Unnamed Faculty,Unnamed Department\r\n'
87            % (curr_year-6, curr_year-6, curr_year-6), result
88            )
89        return
Note: See TracBrowser for help on using the repository browser.