source: main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_export.py @ 14273

Last change on this file since 14273 was 14206, checked in by Henrik Bettermann, 8 years ago

Add imported_gpa and imported_cgpa fields and adjust exporters and batch processors.

  • Property svn:keywords set to Id
File size: 7.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 StudentImportExportSetup
7from waeup.aaue.utils.utils import CustomKofaUtils
8from waeup.aaue.students.export import (
9    CustomStudentExporter, CustomStudentPaymentExporter,
10    CustomStudentStudyLevelExporter,
11    CustomCourseTicketExporter)
12from waeup.aaue.testing import FunctionalLayer
13
14
15class CustomStudentExporterTest(StudentImportExportSetup):
16
17    layer = FunctionalLayer
18
19    def setUp(self):
20        super(CustomStudentExporterTest, self).setUp()
21        self.setup_for_export()
22        result_entry = ResultEntry(
23            CustomKofaUtils.EXAM_SUBJECTS_DICT.keys()[0],
24            CustomKofaUtils.EXAM_GRADES[0][0]
25            )
26        self.student.alr_results = [
27            result_entry]
28        self.student.fst_sit_results = [
29            result_entry]
30        self.student.scd_sit_results = [
31            result_entry]
32        return
33
34    def test_ifaces(self):
35        # make sure we fullfill interface contracts
36        obj = CustomStudentExporter()
37        verifyObject(ICSVExporter, obj)
38        verifyClass(ICSVExporter, CustomStudentExporter)
39        return
40
41
42    def disabled_test_export_all(self):
43        # we can really export students
44        # set values we can expect in export file
45        self.setup_student(self.student)
46        exporter = CustomStudentExporter()
47        exporter.export_all(self.app, self.outfile)
48        result = open(self.outfile, 'rb').read()
49        self.assertMatches(
50            'adm_code,alr_date,alr_fname,alr_no,alr_results,'
51            'application_number,clr_code,'
52            'date_of_birth,def_adm,disabled,email,emp2_end,emp2_position,'
53            'emp2_reason,emp2_start,emp_end,emp_position,emp_reason,'
54            'emp_start,employer,employer2,father_address,father_name,'
55            'father_phone,father_work,'
56            'financial_clearance_date,financially_cleared_by,'
57            'firstname,flash_notice,former_matric,fst_sit_date,'
58            'fst_sit_fname,fst_sit_no,fst_sit_results,fst_sit_type,hq2_degree,'
59            'hq2_disc,hq2_matric_no,hq2_school,hq2_session,hq2_type,'
60            'hq_degree,hq_disc,hq_fname,hq_matric_no,hq_school,hq_session,'
61            'hq_type,is_staff,lastname,lga,marit_stat,matric_number,'
62            'middlename,mother_address,mother_name,mother_phone,'
63            'mother_work,nationality,next_kin_address,next_kin_name,'
64            'next_kin_phone,next_kin_relation,nysc_lga,nysc_location,'
65            'nysc_year,officer_comment,perm_address,personal_updated,'
66            'phone,phone_personal,physical_clearance_date,reg_number,'
67            'religion,sc_pin,sc_serial_number,scd_sit_date,'
68            'scd_sit_fname,scd_sit_no,scd_sit_results,'
69            'scd_sit_type,sex,student_id,suspended,suspended_comment,password,'
70            'state,history,certcode,is_postgrad,current_level,current_session'
71            '\r\n'
72            'my adm code,,,,"[(\'printing_craft_practice\', \'A1\')]",,'
73            'my clr code,1981-02-04#,,,anna@sample.com,,,,,,,,,,,,,,,,,Anna,,,,,,'
74            '"[(\'printing_craft_practice\', \'A1\')]",,,,,,,,,,,,,,,,Tester,,,'
75            '234,M.,,,,,NG,,,,,,,,,"Studentroad 21\nLagos 123456\n",,'
76            '+234-123-12345#,,,123,,,,,,,'
77            '"[(\'printing_craft_practice\', \'A1\')]",,f,A111111,0,,,'
78            'created,[u\'2015-10-26 17:45:56 WAT - Record created by system\'],'
79            'CERT1,0,200,2012\r\n',
80            result
81            )
82        return
83
84class CustomStudentPaymentExporterTest(StudentImportExportSetup):
85
86    layer = FunctionalLayer
87
88    def setUp(self):
89        super(CustomStudentPaymentExporterTest, self).setUp()
90        self.setup_for_export()
91        return
92
93    def test_ifaces(self):
94        # make sure we fullfill interface contracts
95        obj = CustomStudentPaymentExporter()
96        verifyObject(ICSVExporter, obj)
97        verifyClass(ICSVExporter, CustomStudentPaymentExporter)
98        return
99
100    def test_export_all(self):
101        # we can really export students
102        # set values we can expect in export file
103        self.setup_student(self.student)
104        self.student['payments']['my-payment'].r_company = 'interswatch'
105        self.student['payments']['my-payment'].r_card_num = '789'
106        exporter = CustomStudentPaymentExporter()
107        exporter.export_all(self.app, self.outfile)
108        result = open(self.outfile, 'rb').read()
109        self.assertMatches(
110            'ac,amount_auth,creation_date,gateway_amt,p_category,p_current,'
111            'p_id,p_item,p_level,p_session,p_state,payment_date,provider_amt,'
112            'r_amount_approved,r_card_num,r_code,r_company,r_desc,'
113            'r_pay_reference,thirdparty_amt,student_id,state,'
114            'current_session\r\n'
115            '666,12.12,2012-04-01 13:12:01#,,schoolfee,1,my-id,p-item,'
116            '100,2012,paid,2012-04-01 14:12:01#,,12.12,'
117            '789,r-code,interswatch,,,,A111111,created,2012\r\n',
118            result
119            )
120        return
121
122class CustomStudentStudyLevelExporterTest(StudentImportExportSetup):
123
124    layer = FunctionalLayer
125
126    def setUp(self):
127        super(CustomStudentStudyLevelExporterTest, self).setUp()
128        self.setup_for_export()
129        return
130
131    def test_export_all(self):
132        # we can really export study levels
133        # set values we can expect in export file
134        self.setup_student(self.student)
135        exporter = CustomStudentStudyLevelExporter()
136        exporter.export_all(self.app, self.outfile)
137        result = open(self.outfile, 'rb').read()
138        self.assertEqual(
139            result,
140            'gpa,imported_cgpa,imported_gpa,'
141            'level,level_session,level_verdict,total_credits,'
142            'total_credits_s1,total_credits_s2,'
143            'validated_by,validation_date,'
144            'student_id,number_of_tickets,certcode\r\n'
145            '0.0,,,100,2012,A,100,,,,,A111111,1,CERT1\r\n'
146            )
147        return
148
149class CustomCourseTicketExporterTest(StudentImportExportSetup):
150
151    layer = FunctionalLayer
152
153    def setUp(self):
154        super(CustomCourseTicketExporterTest, self).setUp()
155        self.setup_for_export()
156        return
157
158    def test_export_all(self):
159        # we can really export all course tickets
160        # set values we can expect in export file
161        self.setup_student(self.student)
162        exporter = CustomCourseTicketExporter()
163        exporter.export_all(self.app, self.outfile)
164        result = open(self.outfile, 'rb').read()
165        self.assertEqual(
166            result,
167            'automatic,ca,carry_over,code,credits,dcode,fcode,level,level_session,'
168            'mandatory,passmark,score,semester,title,student_id,certcode,'
169            'display_fullname,matric_number\r\n'
170            '1,,1,CRS1,100,DEP1,FAC1,100,2012,0,100,,2,Course 1,A111111,CERT1,'
171            '"TESTER, Anna M.",234\r\n'
172            )
173        return
174
Note: See TracBrowser for help on using the repository browser.