Changeset 8056
- Timestamp:
- 6 Apr 2012, 20:43:18 (13 years ago)
- Location:
- main/waeup.uniben/trunk/src/waeup/uniben/applicants
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.uniben/trunk/src/waeup/uniben/applicants/tests.py
r8053 r8056 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.uniben.testing import FunctionalLayer 31 from waeup.kofa.interfaces import IBatchProcessor 36 from waeup.uniben.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,emp2_end,' 198 'emp2_position,emp2_reason,emp2_start,emp_end,emp_position,emp_reason,' 199 'emp_start,employer,employer2,firstname,history,hq_degree,hq_disc,' 200 'hq_matric_no,hq_school,hq_session,hq_type,lastname,lga,locked,' 201 'middlename,notice,password,perm_address,phone,pp_school,reg_number,' 202 'screening_score,screening_venue,sex,state,student_id' 203 in result) 204 self.assertTrue( 205 'Application initialized by system\'],,,,,,,Tester,foreigner,0,M.,' 206 '"Some notice\nin lines.",any password,,+234-123-12345,,123456,98,' 207 'Exam Room,f,initialized,' in result) 208 return
Note: See TracChangeset for help on using the changeset viewer.