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

Last change on this file since 16297 was 16249, checked in by Henrik Bettermann, 4 years ago

Customite personal data form.

  • Property svn:keywords set to Id
File size: 5.0 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 disabled_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.assertMatches(
49            'adm_code,alr_date,alr_fname,alr_no,alr_results,'
50            'clr_code,date_of_birth,def_adm,disabled,email,email2,emp2_end,'
51            'emp2_position,emp2_reason,emp2_start,emp_end,emp_position,'
52            'emp_reason,emp_start,employer,employer2,'
53            'financial_clearance_date,financially_cleared_by,'
54            'firstname,flash_notice,former_matric,'
55            'fst_sit_date,fst_sit_fname,fst_sit_no,fst_sit_results,'
56            'fst_sit_type,hq2_degree,hq2_disc,hq2_matric_no,hq2_school,'
57            'hq2_session,hq2_type,hq_degree,hq_disc,hq_fname,hq_matric_no,'
58            'hq_school,hq_session,hq_type,is_staff,lastname,lga,library,'
59            'marit_stat,matric_number,middlename,nationality,'
60            'next_kin_address,next_kin_name,next_kin_phone,next_kin_relation,'
61            'nysc_lga,nysc_location,nysc_year,officer_comment,parents_email,'
62            'perm_address,personal_updated,phone,'
63            'physical_clearance_date,provisionally_cleared,reg_number,'
64            'religion,scd_sit_date,scd_sit_fname,scd_sit_no,'
65            'scd_sit_results,scd_sit_type,sex,student_id,'
66            'suspended,suspended_comment,password,state,history,certcode,is_postgrad,'
67            'current_level,current_session\r\nmy adm code,,,,'
68            '"[(\'printing_craft_practice\', \'A1\')]",my clr code,1981-02-04#,,,'
69            'anna@sample.com,,,,,,,,,,,,,,Anna,,,,,,"[(\'printing_craft_practice\', \'A1\')]"'
70            ',,,,,,,,,,,,,,,,Tester,,,,234,M.,NG,,,,,,,,,,'
71            '"Studentroad 21\nLagos 123456\n",,+234-123-12345#,,,123,,,,,'
72            '"[(\'printing_craft_practice\', \'A1\')]",,f,A111111,0,,,created,'
73            '[u\'2012-11-06 13:16:41 WAT - Record created by system\'],'
74            'CERT1,0,200,2012\r\n',
75            result
76            )
77        return
78
79class CustomStudentPaymentExporterTest(StudentImportExportSetup):
80
81    layer = FunctionalLayer
82
83    def setUp(self):
84        super(CustomStudentPaymentExporterTest, self).setUp()
85        self.setup_for_export()
86        return
87
88    def test_ifaces(self):
89        # make sure we fullfill interface contracts
90        obj = CustomStudentPaymentExporter()
91        verifyObject(ICSVExporter, obj)
92        verifyClass(ICSVExporter, CustomStudentPaymentExporter)
93        return
94
95    def test_export_all(self):
96        # we can really export students
97        # set values we can expect in export file
98        self.setup_student(self.student)
99        self.student['payments']['my-payment'].r_company = 'interswatch'
100        self.student['payments']['my-payment'].r_card_num = '789'
101        exporter = CustomStudentPaymentExporter()
102        exporter.export_all(self.app, self.outfile)
103        result = open(self.outfile, 'rb').read()
104        self.assertMatches(
105            'ac,amount_auth,creation_date,gateway_amt,net_amt,p_category,p_combi,p_current,'
106            'p_id,p_item,p_level,p_session,p_state,payment_date,provider_amt,'
107            'r_amount_approved,r_card_num,r_code,r_company,r_desc,'
108            'r_pay_reference,thirdparty_amt,student_id,state,'
109            'current_session\r\n'
110            '666,12.12,%s-04-01 13:12:01#,,,schoolfee,[],1,my-id,p-item,'
111            '100,%s,paid,%s-04-01 14:12:01#,,12.12,'
112            '789,r-code,interswatch,,,,A111111,created,2012\r\n'
113            % (curr_year-6, curr_year-6, curr_year-6), result
114            )
115        return
Note: See TracBrowser for help on using the repository browser.