[16639] | 1 | ## $Id: test_browser.py 16655 2021-09-30 05:31:28Z henrik $ |
---|
[15614] | 2 | ## |
---|
| 3 | ## Copyright (C) 2013 Uli Fouquet & Henrik Bettermann |
---|
| 4 | ## This program is free software; you can redistribute it and/or modify |
---|
| 5 | ## it under the terms of the GNU General Public License as published by |
---|
| 6 | ## the Free Software Foundation; either version 2 of the License, or |
---|
| 7 | ## (at your option) any later version. |
---|
| 8 | ## |
---|
| 9 | ## This program is distributed in the hope that it will be useful, |
---|
| 10 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 11 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 12 | ## GNU General Public License for more details. |
---|
| 13 | ## |
---|
| 14 | ## You should have received a copy of the GNU General Public License |
---|
| 15 | ## along with this program; if not, write to the Free Software |
---|
| 16 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
| 17 | ## |
---|
| 18 | """ |
---|
| 19 | Test the applicant-related UI components. |
---|
| 20 | """ |
---|
| 21 | import os |
---|
| 22 | import datetime |
---|
| 23 | from zope.component import createObject, getUtility |
---|
| 24 | from zope.catalog.interfaces import ICatalog |
---|
| 25 | from zope.intid.interfaces import IIntIds |
---|
| 26 | from hurry.workflow.interfaces import IWorkflowState |
---|
[16615] | 27 | from kofacustom.edocons.testing import FunctionalLayer |
---|
[15614] | 28 | from waeup.kofa.browser.tests.test_pdf import samples_dir |
---|
| 29 | from waeup.kofa.applicants.tests.test_browser import ApplicantsFullSetup |
---|
| 30 | from waeup.kofa.applicants.tests.test_batching import ApplicantImportExportSetup |
---|
[16615] | 31 | from kofacustom.edocons.applicants.export import CustomApplicantExporter |
---|
| 32 | from kofacustom.edocons.applicants.batching import CustomApplicantProcessor |
---|
[15614] | 33 | |
---|
| 34 | class CustomApplicantUITests(ApplicantsFullSetup): |
---|
| 35 | # Tests for uploading/browsing the passport image of appplicants |
---|
| 36 | |
---|
| 37 | layer = FunctionalLayer |
---|
| 38 | |
---|
| 39 | class ApplicantExporterTest(ApplicantImportExportSetup): |
---|
| 40 | |
---|
| 41 | layer = FunctionalLayer |
---|
| 42 | |
---|
| 43 | def setUp(self): |
---|
| 44 | super(ApplicantExporterTest, self).setUp() |
---|
| 45 | self.outfile = os.path.join(self.workdir, 'myoutput.csv') |
---|
| 46 | self.cat = getUtility(ICatalog, name='applicants_catalog') |
---|
| 47 | self.intids = getUtility(IIntIds) |
---|
| 48 | return |
---|
| 49 | |
---|
| 50 | def setup_applicant(self, applicant): |
---|
| 51 | # set predictable values for `applicant` |
---|
| 52 | applicant.reg_number = u'123456' |
---|
| 53 | applicant.applicant_id = u'dp2011_654321' |
---|
| 54 | applicant.firstname = u'Anna' |
---|
| 55 | applicant.lastname = u'Tester' |
---|
| 56 | applicant.middlename = u'M.' |
---|
| 57 | applicant.nationality = u'NG' |
---|
| 58 | applicant.date_of_birth = datetime.date(1981, 2, 4) |
---|
| 59 | applicant.sex = 'f' |
---|
| 60 | applicant.email = 'anna@sample.com' |
---|
| 61 | applicant.phone = u'+234-123-12345' |
---|
| 62 | applicant.course1 = self.certificate |
---|
| 63 | applicant.course2 = self.certificate |
---|
| 64 | applicant.course_admitted = self.certificate |
---|
| 65 | applicant.notice = u'Some notice\nin lines.' |
---|
| 66 | applicant.screening_score = 98 |
---|
| 67 | applicant.screening_venue = u'Exam Room' |
---|
| 68 | applicant.screening_date = u'Saturday, 16th June 2012 2:00:00 PM' |
---|
| 69 | applicant.password = 'any password' |
---|
| 70 | return applicant |
---|
| 71 | |
---|
| 72 | class ApplicantsContainerUITests(ApplicantsFullSetup): |
---|
| 73 | # Tests for ApplicantsContainer class views and pages |
---|
| 74 | |
---|
| 75 | layer = FunctionalLayer |
---|
| 76 | |
---|
| 77 | def test_application_slip(self): |
---|
| 78 | self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') |
---|
| 79 | self.slip_path = self.view_path + '/application_slip.pdf' |
---|
| 80 | self.browser.open(self.manage_path) |
---|
| 81 | self.assertEqual(self.browser.headers['Status'], '200 Ok') |
---|
[16655] | 82 | self.browser.getControl(name="form.firstname").value = 'John' |
---|
| 83 | self.browser.getControl(name="form.middlename").value = 'Anthony' |
---|
| 84 | self.browser.getControl(name="form.lastname").value = 'Tester' |
---|
| 85 | #self.browser.getControl(name="form.course1").value = ['CERT1'] |
---|
| 86 | self.browser.getControl(name="form.date_of_birth").value = '09/09/1988' |
---|
| 87 | self.browser.getControl(name="form.sex").value = ['m'] |
---|
| 88 | self.browser.getControl(name="form.email").value = 'xx@yy.zz' |
---|
[15614] | 89 | self.browser.getControl("Save").click() |
---|
| 90 | IWorkflowState(self.applicant).setState('submitted') |
---|
[16591] | 91 | self.browser.open(self.view_path) |
---|
[15614] | 92 | self.browser.getLink("Download application slip").click() |
---|
| 93 | self.assertEqual(self.browser.headers['Status'], '200 Ok') |
---|
| 94 | self.assertEqual(self.browser.headers['Content-Type'], |
---|
| 95 | 'application/pdf') |
---|
| 96 | path = os.path.join(samples_dir(), 'application_slip.pdf') |
---|
| 97 | open(path, 'wb').write(self.browser.contents) |
---|
| 98 | print "Sample application_slip.pdf written to %s" % path |
---|