Changeset 17766
- Timestamp:
- 12 May 2024, 08:39:58 (6 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_export.py
r17760 r17766 12 12 from waeup.kofa.applicants.export import ( 13 13 ApplicantsContainerExporter, ApplicantExporter, 14 ApplicantPaymentExporter )14 ApplicantPaymentExporter, ApplicantRefereeReportExporter) 15 15 from waeup.kofa.applicants.interfaces import ( 16 16 AppCatSource, ApplicationTypeSource) … … 331 331 '123456,Anna M. Tester\r\n' % cdate, result) 332 332 return 333 334 class ApplicantRefereeReportExporterTest(ApplicantImportExportSetup): 335 336 layer = FunctionalLayer 337 338 def setUp(self): 339 super(ApplicantRefereeReportExporterTest, self).setUp() 340 self.outfile = os.path.join(self.workdir, 'myoutput.csv') 341 self.cat = getUtility(ICatalog, name='applicants_catalog') 342 self.intids = getUtility(IIntIds) 343 return 344 345 def test_ifaces(self): 346 # make sure we fullfill interface contracts 347 obj = ApplicantRefereeReportExporter() 348 verifyObject(ICSVExporter, obj) 349 verifyClass(ICSVExporter, ApplicantRefereeReportExporter) 350 return 351 352 def test_get_as_utility(self): 353 # we can get an applicant exporter as utility 354 result = queryUtility(ICSVExporter, name="applicantrefereereports") 355 self.assertTrue(result is not None) 356 return 357 358 def setup_applicant(self, applicant): 359 # set predictable values for `applicant` 360 applicant.reg_number = u'123456' 361 applicant.applicant_id = u'dp2011_654321' 362 applicant.firstname = u'Anna' 363 applicant.lastname = u'Tester' 364 applicant.middlename = u'M.' 365 applicant.date_of_birth = datetime.date(1981, 2, 4) 366 applicant.sex = 'f' 367 applicant.email = 'anna@sample.com' 368 applicant.phone = u'+234-123-12345' 369 # Add payment 370 report = createObject(u'waeup.ApplicantRefereeReport') 371 report.r_id = 'r120' 372 report.name = u'John Doe' 373 report.email = 'xx@xx.xx' 374 applicant['r120'] = report 375 return applicant 376 377 def test_export(self): 378 applicant = self.setup_applicant(self.applicant) 379 exporter = ApplicantRefereeReportExporter() 380 exporter.export(applicant.refereereports, self.outfile) 381 result = open(self.outfile, 'rb').read() 382 cdate = str('%s#' % self.applicant['r120'].creation_date) 383 self.assertEqual( 384 'creation_date,email,email_pref,name,phone,r_id,report,' 385 'applicant_id,reg_number,display_fullname\r\n' 386 '%s,xx@xx.xx,aa@aa.aa,John Doe,,r120,,dp2011_654321,' 387 '123456,Anna M. Tester\r\n' % cdate, result) 388 return 389 390 def test_export_all(self): 391 self.applicant = self.setup_applicant(self.applicant) 392 exporter = ApplicantRefereeReportExporter() 393 exporter.export_all(self.app, self.outfile) 394 result = open(self.outfile, 'rb').read() 395 cdate = str('%s#' % self.applicant['r120'].creation_date) 396 self.assertEqual( 397 'creation_date,email,email_pref,name,phone,r_id,report,' 398 'applicant_id,reg_number,display_fullname\r\n' 399 '%s,xx@xx.xx,aa@aa.aa,John Doe,,r120,,dp2011_654321,' 400 '123456,Anna M. Tester\r\n' % cdate, result) 401 return 402 403 def test_export_filtered(self): 404 self.applicant = self.setup_applicant(self.applicant) 405 exporter = ApplicantRefereeReportExporter() 406 exporter.export_filtered( 407 self.app, self.outfile, container=self.container.code) 408 result = open(self.outfile, 'rb').read() 409 cdate = str('%s#' % self.applicant['r120'].creation_date) 410 self.assertEqual( 411 'creation_date,email,email_pref,name,phone,r_id,report,' 412 'applicant_id,reg_number,display_fullname\r\n' 413 '%s,xx@xx.xx,aa@aa.aa,John Doe,,r120,,dp2011_654321,' 414 '123456,Anna M. Tester\r\n' % cdate, result) 415 return 416
Note: See TracChangeset for help on using the changeset viewer.