Changeset 8055
- Timestamp:
- 6 Apr 2012, 20:42:44 (13 years ago)
- Location:
- main/waeup.custom/trunk/src/waeup/custom/applicants
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.custom/trunk/src/waeup/custom/applicants/tests.py
r8054 r8055 19 19 import shutil 20 20 import tempfile 21 import datetime 22 from zope.intid.interfaces import IIntIds 21 23 from zope.interface.verify import verifyClass, verifyObject 22 24 from zope.component.hooks import setSite, clearSite 23 from zope.component import createObject 25 from zope.component import createObject, getUtility 26 from zope.catalog.interfaces import ICatalog 24 27 from zope.testbrowser.testing import Browser 25 28 from waeup.kofa.app import University … … 28 31 from waeup.kofa.testing import FunctionalTestCase 29 32 from waeup.kofa.applicants.container import ApplicantsContainer 33 from waeup.kofa.applicants.tests.test_batching import ApplicantImportExportSetup 34 from waeup.kofa.interfaces import IBatchProcessor 30 35 from waeup.custom.testing import FunctionalLayer 31 from waeup.kofa.interfaces import IBatchProcessor 36 from waeup.custom.applicants.export import ApplicantsExporter 37 32 38 33 39 class ApplicantUITest(FunctionalTestCase): … … 145 151 self.assertEqual(self.browser.headers['Status'], '200 Ok') 146 152 return 153 154 class ApplicantsExporterTest(ApplicantImportExportSetup): 155 156 layer = FunctionalLayer 157 158 def setUp(self): 159 super(ApplicantsExporterTest, self).setUp() 160 self.outfile = os.path.join(self.workdir, 'myoutput.csv') 161 self.cat = getUtility(ICatalog, name='applicants_catalog') 162 self.intids = getUtility(IIntIds) 163 return 164 165 def setup_applicant(self, applicant): 166 # set predictable values for `applicant` 167 applicant.reg_number = u'123456' 168 applicant.applicant_id = u'dp2011_654321' 169 applicant.firstname = u'Anna' 170 applicant.lastname = u'Tester' 171 applicant.middlename = u'M.' 172 applicant.date_of_birth = datetime.date(1981, 2, 4) 173 applicant.sex = 'f' 174 applicant.email = 'anna@sample.com' 175 applicant.phone = u'+234-123-12345' 176 applicant.course1 = self.certificate 177 applicant.course2 = self.certificate 178 applicant.course_admitted = self.certificate 179 applicant.notice = u'Some notice\nin lines.' 180 applicant.screening_score = 98 181 applicant.screening_venue = u'Exam Room' 182 applicant.password = 'any password' 183 return applicant 184 185 def test_export_all(self): 186 # we can export all applicants in a portal 187 # set values we can expect in export file 188 self.applicant = self.setup_applicant(self.applicant) 189 exporter = ApplicantsExporter() 190 exporter.export_all(self.app, self.outfile) 191 result = open(self.outfile, 'rb').read() 192 # The exported records do contain a real date in their 193 # history dict. We skip the date and split the comparison 194 # into two parts. 195 self.assertTrue( 196 'applicant_id,application_date,application_number,course1,course2,' 197 'course_admitted,date_of_birth,display_fullname,email,employer,' 198 'firstname,history,lastname,lga,locked,middlename,notice,password,' 199 'phone,reg_number,screening_score,screening_venue,sex,state,' 200 'student_id' 201 in result) 202 self.assertTrue( 203 'Application initialized by system\'],Tester,foreigner,0,M.,' 204 '"Some notice\nin lines.",any password,+234-123-12345,123456,98,' 205 'Exam Room,f,initialized,' in result) 206 return
Note: See TracChangeset for help on using the changeset viewer.