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

Last change on this file since 14000 was 13963, checked in by Henrik Bettermann, 9 years ago

Resolve ticket #228:

  1. The first column should be the Serial number.
  2. Under the column for Full name, surname should come first in capital letter with a coma before the other names.
  3. The heading for ‘score’ column should be renamed ‘exam score’.
  4. CA column should come before exam score column
  5. The column for Total should be added after exam score column.
  6. Extra column for letter grade should come after the ‘total’ column.
  • Property svn:keywords set to Id
File size: 6.9 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 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,scd_sit_date,scd_sit_fname,scd_sit_no,scd_sit_results,'
68            'scd_sit_type,sex,student_id,suspended,suspended_comment,password,'
69            'state,history,certcode,is_postgrad,current_level,current_session'
70            '\r\n'
71            'my adm code,,,,"[(\'printing_craft_practice\', \'A1\')]",,'
72            'my clr code,1981-02-04#,,,anna@sample.com,,,,,,,,,,,,,,,,,Anna,,,,,,'
73            '"[(\'printing_craft_practice\', \'A1\')]",,,,,,,,,,,,,,,,Tester,,,'
74            '234,M.,,,,,NG,,,,,,,,,"Studentroad 21\nLagos 123456\n",,'
75            '+234-123-12345#,,,123,,,,,'
76            '"[(\'printing_craft_practice\', \'A1\')]",,f,A111111,0,,,'
77            'created,[u\'2015-10-26 17:45:56 WAT - Record created by system\'],'
78            'CERT1,0,200,2012\r\n',
79            result
80            )
81        return
82
83class CustomStudentPaymentExporterTest(StudentImportExportSetup):
84
85    layer = FunctionalLayer
86
87    def setUp(self):
88        super(CustomStudentPaymentExporterTest, self).setUp()
89        self.setup_for_export()
90        return
91
92    def test_ifaces(self):
93        # make sure we fullfill interface contracts
94        obj = CustomStudentPaymentExporter()
95        verifyObject(ICSVExporter, obj)
96        verifyClass(ICSVExporter, CustomStudentPaymentExporter)
97        return
98
99    def test_export_all(self):
100        # we can really export students
101        # set values we can expect in export file
102        self.setup_student(self.student)
103        self.student['payments']['my-payment'].r_company = 'interswatch'
104        self.student['payments']['my-payment'].r_card_num = '789'
105        exporter = CustomStudentPaymentExporter()
106        exporter.export_all(self.app, self.outfile)
107        result = open(self.outfile, 'rb').read()
108        self.assertMatches(
109            'ac,amount_auth,creation_date,gateway_amt,p_category,p_current,'
110            'p_id,p_item,p_level,p_session,p_state,payment_date,provider_amt,'
111            'r_amount_approved,r_card_num,r_code,r_company,r_desc,'
112            'r_pay_reference,thirdparty_amt,student_id,state,'
113            'current_session\r\n'
114            '666,12.12,2012-04-01 13:12:01#,,schoolfee,1,my-id,p-item,'
115            '100,2012,paid,2012-04-01 14:12:01#,,12.12,'
116            '789,r-code,interswatch,,,,A111111,created,2012\r\n',
117            result
118            )
119        return
120
121class CustomStudentStudyLevelExporterTest(StudentImportExportSetup):
122
123    layer = FunctionalLayer
124
125    def setUp(self):
126        super(CustomStudentStudyLevelExporterTest, self).setUp()
127        self.setup_for_export()
128        return
129
130    def test_export_all(self):
131        # we can really export study levels
132        # set values we can expect in export file
133        self.setup_student(self.student)
134        exporter = CustomStudentStudyLevelExporter()
135        exporter.export_all(self.app, self.outfile)
136        result = open(self.outfile, 'rb').read()
137        self.assertEqual(
138            result,
139            'gpa,level,level_session,level_verdict,total_credits,'
140            'total_credits_s1,total_credits_s2,'
141            'validated_by,validation_date,'
142            'student_id,number_of_tickets,certcode\r\n'
143            '0.0,100,2012,A,100,,,,,A111111,1,CERT1\r\n'
144            )
145        return
146
147class CustomCourseTicketExporterTest(StudentImportExportSetup):
148
149    layer = FunctionalLayer
150
151    def setUp(self):
152        super(CustomCourseTicketExporterTest, self).setUp()
153        self.setup_for_export()
154        return
155
156    def test_export_all(self):
157        # we can really export all course tickets
158        # set values we can expect in export file
159        self.setup_student(self.student)
160        exporter = CustomCourseTicketExporter()
161        exporter.export_all(self.app, self.outfile)
162        result = open(self.outfile, 'rb').read()
163        self.assertEqual(
164            result,
165            'automatic,ca,carry_over,code,credits,dcode,fcode,level,level_session,'
166            'mandatory,passmark,score,semester,title,student_id,certcode,'
167            'display_fullname,matric_number\r\n'
168            '1,,1,CRS1,100,DEP1,FAC1,100,2012,0,100,,2,Course 1,A111111,CERT1,'
169            '"TESTER, Anna M.",234\r\n'
170            )
171        return
172
Note: See TracBrowser for help on using the repository browser.