Changeset 7925 for main/waeup.kofa/trunk/src/waeup/kofa/applicants
- Timestamp:
- 20 Mar 2012, 01:21:22 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_export.py
r7913 r7925 12 12 ApplicantsContainerExporter, ApplicantsExporter) 13 13 from waeup.kofa.applicants.interfaces import ( 14 IApplicantsContainerProvider, AppCatSource )14 IApplicantsContainerProvider, AppCatSource, ApplicationTypeSource) 15 15 from waeup.kofa.applicants.tests.test_batching import ( 16 16 ApplicantImportExportSetup) 17 17 from waeup.kofa.interfaces import ICSVExporter 18 from waeup.kofa.schoolgrades import ResultEntry 18 19 from waeup.kofa.testing import KofaUnitTestLayer, FunctionalLayer 20 from waeup.kofa.utils.utils import KofaUtils 19 21 20 22 class ApplicantsContainersExporterTest(unittest.TestCase): … … 48 50 container.code = u'dp2012' 49 51 container.title = u'General Studies 2012/13' 50 from waeup.kofa.applicants.interfaces import (51 ApplicationTypeSource, ApplicantContainerProviderSource,)52 52 container.prefix = list(ApplicationTypeSource()(container))[0] 53 53 container.year = 2012 … … 106 106 return 107 107 108 def setup_applicant(self, applicant): 109 # set predictable values for `applicant` 110 applicant.reg_number = u'123456' 111 applicant.applicant_id = u'dp2011_654321' 112 applicant.firstname = u'Anna' 113 applicant.lastname = u'Tester' 114 applicant.middlename = u'M.' 115 applicant.date_of_birth = datetime.date(1981, 2, 4) 116 applicant.sex = 'f' 117 applicant.email = 'anna@sample.com' 118 applicant.phone = u'+234-123-12345' 119 applicant.course1 = self.certificate 120 applicant.course2 = self.certificate 121 applicant.course_admitted = self.certificate 122 applicant.notice = u'Some notice\nin lines.' 123 applicant.screening_score = 98 124 applicant.screening_venue = u'Exam Room' 125 result_entry = ResultEntry( 126 KofaUtils.EXAM_SUBJECTS_DICT.keys()[0], 127 KofaUtils.EXAM_GRADES[0][0] 128 ) 129 applicant.school_grades = [ 130 result_entry] 131 return applicant 132 108 133 def test_export(self): 109 134 # we can really export applicants 110 135 # set values we can expect in export file 111 self.applicant.reg_number = u'123456' 112 self.applicant.applicant_id = u'dp2011_654321' 113 intid = self.intids.getId(self.applicant) 114 # reindex modified applicant 115 self.cat.index_doc(intid, self.applicant) 136 applicant = self.setup_applicant(self.applicant) 116 137 exporter = ApplicantsExporter() 117 exporter.export([ self.applicant], self.outfile)138 exporter.export([applicant], self.outfile) 118 139 result = open(self.outfile, 'rb').read() 119 140 self.assertEqual( 120 141 result, 121 'reg_number,school_grades,firstname,phone,middlename,lastname,' 122 'lga,screening_score,notice,applicant_id,sex,course2,email,' 123 'date_of_birth,screening_venue,course_admitted,course1\r\n' 142 'applicant_id,course1,course2,course_admitted,date_of_birth,' 143 'email,firstname,lastname,lga,middlename,notice,phone,' 144 'reg_number,school_grades,screening_score,screening_venue,' 145 'sex\r\n' 124 146 125 '123456,[],Anna,,,Tester,foreigner,,,dp2011_654321,m,,,,,,\r\n' 147 'dp2011_654321,CERT1,CERT1,CERT1,1981-02-04,anna@sample.com,' 148 'Anna,Tester,foreigner,M.,"Some notice\nin lines.",' 149 '+234-123-12345,123456,' 150 '"[(\'computer_science\', \'A\')]",98,Exam Room,f\r\n' 126 151 ) 127 152 return
Note: See TracChangeset for help on using the changeset viewer.