[13814] | 1 | # -*- coding: utf-8 -*- |
---|
[10589] | 2 | ## $Id: test_browser.py 17659 2023-12-22 16:47:45Z henrik $ |
---|
| 3 | ## |
---|
| 4 | ## Copyright (C) 2013 Uli Fouquet & Henrik Bettermann |
---|
| 5 | ## This program is free software; you can redistribute it and/or modify |
---|
| 6 | ## it under the terms of the GNU General Public License as published by |
---|
| 7 | ## the Free Software Foundation; either version 2 of the License, or |
---|
| 8 | ## (at your option) any later version. |
---|
| 9 | ## |
---|
| 10 | ## This program is distributed in the hope that it will be useful, |
---|
| 11 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 12 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 13 | ## GNU General Public License for more details. |
---|
| 14 | ## |
---|
| 15 | ## You should have received a copy of the GNU General Public License |
---|
| 16 | ## along with this program; if not, write to the Free Software |
---|
| 17 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
| 18 | ## |
---|
| 19 | """ |
---|
| 20 | Test the applicant-related UI components. |
---|
| 21 | """ |
---|
[13552] | 22 | import os |
---|
[16078] | 23 | import datetime |
---|
| 24 | import pytz |
---|
[11736] | 25 | from StringIO import StringIO |
---|
[11788] | 26 | from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState |
---|
[11736] | 27 | from zope.securitypolicy.interfaces import IPrincipalRoleManager |
---|
[16078] | 28 | from zope.component import createObject, getUtility |
---|
| 29 | from waeup.kofa.interfaces import IUserAccount |
---|
[13552] | 30 | from waeup.kofa.browser.tests.test_pdf import samples_dir |
---|
| 31 | from waeup.kofa.applicants.container import ApplicantsContainer |
---|
[10589] | 32 | from waeup.uniben.testing import FunctionalLayer |
---|
[11788] | 33 | from waeup.uniben.configuration import CustomSessionConfiguration |
---|
[11736] | 34 | from waeup.kofa.applicants.tests.test_browser import ApplicantsFullSetup, PH_LEN |
---|
[10589] | 35 | |
---|
[16078] | 36 | session_1 = datetime.datetime.now().year - 2 |
---|
[13816] | 37 | SAMPLE_IMAGE = os.path.join(os.path.dirname(__file__), 'test_image.jpg') |
---|
| 38 | |
---|
[10589] | 39 | class CustomApplicantUITests(ApplicantsFullSetup): |
---|
| 40 | # Tests for uploading/browsing the passport image of appplicants |
---|
| 41 | |
---|
| 42 | layer = FunctionalLayer |
---|
| 43 | |
---|
[11788] | 44 | #def setUp(self): |
---|
| 45 | # super(CustomApplicantUITests, self).setUp() |
---|
| 46 | # return |
---|
| 47 | |
---|
[10589] | 48 | def test_applicant_access(self): |
---|
| 49 | # Anonymous users can't see the application fee. |
---|
| 50 | self.browser.open(self.container_path) |
---|
| 51 | self.assertFalse('Application Fee' in self.browser.contents) |
---|
| 52 | # Applicants can edit their record |
---|
| 53 | self.browser.open(self.login_path) |
---|
| 54 | self.login() |
---|
| 55 | self.assertTrue( |
---|
[17298] | 56 | 'You logged in as an applicant.' in self.browser.contents) |
---|
[10589] | 57 | self.browser.open(self.edit_path) |
---|
| 58 | self.assertTrue(self.browser.url != self.login_path) |
---|
| 59 | self.assertEqual(self.browser.headers['Status'], '200 Ok') |
---|
| 60 | self.fill_correct_values() |
---|
| 61 | self.browser.getControl("Save").click() |
---|
| 62 | self.assertMatches('...Form has been saved...', self.browser.contents) |
---|
| 63 | # Applicants can't see the application fee. |
---|
| 64 | self.browser.open(self.container_path) |
---|
| 65 | self.assertFalse('Application Fee' in self.browser.contents) |
---|
| 66 | return |
---|
[11736] | 67 | |
---|
| 68 | def image_url(self, filename): |
---|
| 69 | return self.edit_path.replace('edit', filename) |
---|
| 70 | |
---|
| 71 | def test_upload_passport_wo_permission(self): |
---|
| 72 | # Create CRPU officer |
---|
[15313] | 73 | self.app['users'].addUser('mrcrpu', 'mrCrpusecret1') |
---|
[11736] | 74 | self.app['users']['mrcrpu'].email = 'mrcrpu@foo.ng' |
---|
| 75 | self.app['users']['mrcrpu'].title = 'Carlo Pitter' |
---|
| 76 | prmglobal = IPrincipalRoleManager(self.app) |
---|
| 77 | prmglobal.assignRoleToPrincipal('waeup.CCOfficer', 'mrcrpu') |
---|
| 78 | # Login as CRPU officer |
---|
| 79 | self.browser.open(self.login_path) |
---|
| 80 | self.browser.getControl(name="form.login").value = 'mrcrpu' |
---|
[15313] | 81 | self.browser.getControl(name="form.password").value = 'mrCrpusecret1' |
---|
[11736] | 82 | self.browser.getControl("Login").click() |
---|
| 83 | self.assertMatches('...You logged in...', self.browser.contents) |
---|
| 84 | # Let's try to change the passport image |
---|
| 85 | self.browser.open(self.manage_path) |
---|
| 86 | self.fill_correct_values() |
---|
| 87 | # Create a pseudo image file and select it to be uploaded in form |
---|
| 88 | pseudo_image = StringIO('I pretend to be a graphics file') |
---|
| 89 | ctrl = self.browser.getControl(name='form.passport') |
---|
| 90 | file_ctrl = ctrl.mech_control |
---|
| 91 | file_ctrl.add_file(pseudo_image, filename='myphoto.jpg') |
---|
| 92 | self.browser.getControl("Save").click() |
---|
| 93 | self.assertMatches('...You are not entitled to upload passport pictures...', |
---|
| 94 | self.browser.contents) |
---|
| 95 | # The officer still sees the placeholder passport image |
---|
| 96 | self.browser.open(self.image_url('passport.jpg')) |
---|
| 97 | self.assertEqual( |
---|
| 98 | self.browser.headers['content-type'], 'image/jpeg') |
---|
| 99 | self.assertEqual(len(self.browser.contents), PH_LEN) |
---|
| 100 | # After adding the additional role ... |
---|
| 101 | prmglobal.assignRoleToPrincipal('waeup.PassportPictureManager', 'mrcrpu') |
---|
| 102 | # ... passport pictures can be uploaded |
---|
| 103 | self.browser.open(self.manage_path) |
---|
| 104 | self.fill_correct_values() |
---|
| 105 | pseudo_image = StringIO('I pretend to be a graphics file') |
---|
| 106 | ctrl = self.browser.getControl(name='form.passport') |
---|
| 107 | file_ctrl = ctrl.mech_control |
---|
| 108 | file_ctrl.add_file(pseudo_image, filename='myphoto.jpg') |
---|
| 109 | self.browser.getControl("Save").click() |
---|
| 110 | self.assertMatches('...Form has been saved...', self.browser.contents) |
---|
| 111 | # There is a correct <img> link included |
---|
| 112 | self.assertTrue( |
---|
| 113 | '<img src="passport.jpg" height="180px" />' in self.browser.contents) |
---|
| 114 | # Browsing the link shows a real image |
---|
| 115 | self.browser.open(self.image_url('passport.jpg')) |
---|
| 116 | self.assertEqual( |
---|
| 117 | self.browser.headers['content-type'], 'image/jpeg') |
---|
| 118 | self.assertEqual(len(self.browser.contents), 31) |
---|
[11788] | 119 | |
---|
| 120 | def test_pay_admission_checking_fee(self): |
---|
| 121 | IWorkflowState(self.applicant).setState('admitted') |
---|
[16744] | 122 | self.applicant.screening_score = 55.0 |
---|
[11788] | 123 | self.applicant.course_admitted = self.certificate |
---|
| 124 | self.login() |
---|
| 125 | # SessionConfiguration is not set, thus admission checking payment |
---|
| 126 | # is not necessary. Screening results and course admitted are visible. |
---|
| 127 | self.assertFalse( |
---|
| 128 | 'Add admission checking payment ticket' in self.browser.contents) |
---|
| 129 | self.assertTrue('<a href="http://localhost/app/faculties/fac1/dep1/certificates/CERT1">CERT1 - Unnamed Certificate</a>' in self.browser.contents) |
---|
[16744] | 130 | self.assertTrue('<span>55.0</span>' in self.browser.contents) |
---|
[11788] | 131 | configuration = CustomSessionConfiguration() |
---|
[16078] | 132 | configuration.academic_session = datetime.datetime.now().year - 2 |
---|
[11788] | 133 | self.app['configuration'].addSessionConfiguration(configuration) |
---|
| 134 | # Admission checking fee is 0, thus admission checking payment |
---|
| 135 | # is not necessary. Screening results and course admitted are visible. |
---|
| 136 | self.browser.open(self.view_path) |
---|
| 137 | self.assertFalse( |
---|
| 138 | 'Add admission checking payment ticket' in self.browser.contents) |
---|
| 139 | self.assertTrue('<a href="http://localhost/app/faculties/fac1/dep1/certificates/CERT1">CERT1 - Unnamed Certificate</a>' in self.browser.contents) |
---|
[16744] | 140 | self.assertTrue('<span>55.0</span>' in self.browser.contents) |
---|
[11788] | 141 | configuration.admchecking_fee = 22.0 |
---|
| 142 | # Admission checking payment button is now visible, but screening results |
---|
| 143 | # and course admitted are not. |
---|
| 144 | self.browser.open(self.view_path) |
---|
| 145 | self.assertTrue( |
---|
| 146 | 'Add admission checking payment ticket' in self.browser.contents) |
---|
| 147 | self.assertFalse('<a href="http://localhost/app/faculties/fac1/dep1/certificates/CERT1">CERT1 - Unnamed Certificate</a>' in self.browser.contents) |
---|
[16744] | 148 | self.assertFalse('<span>55.0</span>' in self.browser.contents) |
---|
[11788] | 149 | # Application slip can't be downloaded |
---|
| 150 | self.assertFalse('Download application slip' in self.browser.contents) |
---|
| 151 | slip_path = self.view_path + '/application_slip.pdf' |
---|
| 152 | self.browser.open(slip_path) |
---|
| 153 | self.assertTrue( |
---|
| 154 | 'Please pay admission checking fee before trying to download' |
---|
| 155 | in self.browser.contents) |
---|
| 156 | # Pay admission checking fee. |
---|
| 157 | self.browser.getControl("Add admission checking").click() |
---|
| 158 | p_id = self.applicant.keys()[0] |
---|
| 159 | self.applicant[p_id].p_state = 'paid' |
---|
| 160 | # Screening results and course admitted are visible after payment. |
---|
| 161 | self.browser.open(self.view_path) |
---|
| 162 | self.assertFalse( |
---|
| 163 | 'Add admission checking payment ticket' in self.browser.contents) |
---|
| 164 | self.assertTrue('<a href="http://localhost/app/faculties/fac1/dep1/certificates/CERT1">CERT1 - Unnamed Certificate</a>' in self.browser.contents) |
---|
[16744] | 165 | self.assertTrue('<span>55.0</span>' in self.browser.contents) |
---|
[11788] | 166 | # Application slip can be downloaded again. |
---|
| 167 | self.browser.getLink("Download application slip").click() |
---|
| 168 | self.assertEqual(self.browser.headers['Status'], '200 Ok') |
---|
| 169 | self.assertEqual(self.browser.headers['Content-Type'], |
---|
| 170 | 'application/pdf') |
---|
| 171 | return |
---|
[13552] | 172 | |
---|
[14147] | 173 | def test_application_slips(self): |
---|
[13552] | 174 | |
---|
[13558] | 175 | self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') |
---|
| 176 | self.browser.open(self.manage_path) |
---|
| 177 | self.assertEqual(self.browser.headers['Status'], '200 Ok') |
---|
| 178 | self.fill_correct_values() |
---|
| 179 | self.browser.getControl("Save").click() |
---|
| 180 | IWorkflowState(self.applicant).setState('submitted') |
---|
[16330] | 181 | self.browser.open(self.view_path) |
---|
[13558] | 182 | self.browser.getLink("Download application slip").click() |
---|
| 183 | self.assertEqual(self.browser.headers['Status'], '200 Ok') |
---|
| 184 | self.assertEqual(self.browser.headers['Content-Type'], |
---|
| 185 | 'application/pdf') |
---|
| 186 | path = os.path.join(samples_dir(), 'application_slip.pdf') |
---|
| 187 | open(path, 'wb').write(self.browser.contents) |
---|
| 188 | print "Sample application_slip.pdf written to %s" % path |
---|
[14147] | 189 | # Screening invitation letter is not yet available |
---|
| 190 | self.browser.open(self.view_path) |
---|
| 191 | self.assertFalse('invitation slip' in self.browser.contents) |
---|
| 192 | self.browser.open(self.view_path + '/screening_invitation_slip.pdf') |
---|
| 193 | self.assertTrue('Forbidden' in self.browser.contents) |
---|
| 194 | self.applicant.screening_date = u'any date' |
---|
[14167] | 195 | self.applicant.screening_venue = u'MAIN AUDITORIUM' |
---|
[14168] | 196 | self.applicantscontainer.application_slip_notice = u'This is an additional notice.' |
---|
[14147] | 197 | # The invitation letter can be printed |
---|
| 198 | self.browser.open(self.view_path) |
---|
| 199 | self.browser.getLink("invitation").click() |
---|
| 200 | self.assertEqual(self.browser.headers['Status'], '200 Ok') |
---|
| 201 | self.assertEqual(self.browser.headers['Content-Type'], |
---|
| 202 | 'application/pdf') |
---|
| 203 | path = os.path.join(samples_dir(), 'screening_invitation_slip.pdf') |
---|
| 204 | open(path, 'wb').write(self.browser.contents) |
---|
| 205 | print "Sample screening_invitation_slip.pdf written to %s" % path |
---|
[13558] | 206 | |
---|
| 207 | def test_akoka_application_slip(self): |
---|
| 208 | |
---|
[13552] | 209 | # Remove required FieldProperty attribute first ... |
---|
| 210 | delattr(ApplicantsContainer, 'prefix') |
---|
[13558] | 211 | # ... and replace by akoka |
---|
[14061] | 212 | self.applicantscontainer.prefix = 'akj' |
---|
[14064] | 213 | self.applicantscontainer.title = u'FCET Akoka JUPEB Pre-Degree (Foundation) Studies 2016/2017' |
---|
[13552] | 214 | self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') |
---|
| 215 | self.slip_path = self.view_path + '/application_slip.pdf' |
---|
| 216 | self.browser.open(self.manage_path) |
---|
| 217 | self.assertEqual(self.browser.headers['Status'], '200 Ok') |
---|
| 218 | self.fill_correct_values() |
---|
| 219 | self.browser.getControl("Save").click() |
---|
| 220 | IWorkflowState(self.applicant).setState('submitted') |
---|
[16330] | 221 | self.browser.open(self.view_path) |
---|
[13552] | 222 | self.browser.getLink("Download application slip").click() |
---|
| 223 | self.assertEqual(self.browser.headers['Status'], '200 Ok') |
---|
| 224 | self.assertEqual(self.browser.headers['Content-Type'], |
---|
| 225 | 'application/pdf') |
---|
[13558] | 226 | path = os.path.join(samples_dir(), 'akoka_application_slip.pdf') |
---|
[13552] | 227 | open(path, 'wb').write(self.browser.contents) |
---|
[13558] | 228 | print "Sample akoka_application_slip.pdf written to %s" % path |
---|
[13615] | 229 | |
---|
| 230 | def test_nils_application_slip(self): |
---|
| 231 | |
---|
| 232 | # Remove required FieldProperty attribute first ... |
---|
| 233 | #delattr(ApplicantsContainer, 'prefix') |
---|
| 234 | # ... and replace by akoka |
---|
| 235 | self.applicantscontainer.prefix = 'pgn' |
---|
| 236 | self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') |
---|
| 237 | self.slip_path = self.view_path + '/application_slip.pdf' |
---|
| 238 | self.browser.open(self.manage_path) |
---|
| 239 | self.assertEqual(self.browser.headers['Status'], '200 Ok') |
---|
| 240 | self.fill_correct_values() |
---|
| 241 | self.browser.getControl("Save").click() |
---|
| 242 | IWorkflowState(self.applicant).setState('submitted') |
---|
[16330] | 243 | self.browser.open(self.view_path) |
---|
[13615] | 244 | self.browser.getLink("Download application slip").click() |
---|
| 245 | self.assertEqual(self.browser.headers['Status'], '200 Ok') |
---|
| 246 | self.assertEqual(self.browser.headers['Content-Type'], |
---|
| 247 | 'application/pdf') |
---|
| 248 | path = os.path.join(samples_dir(), 'nils_application_slip.pdf') |
---|
| 249 | open(path, 'wb').write(self.browser.contents) |
---|
| 250 | print "Sample nils_application_slip.pdf written to %s" % path |
---|
[13814] | 251 | |
---|
[13816] | 252 | def test_ictwk_application(self): |
---|
[13814] | 253 | |
---|
| 254 | # Remove required FieldProperty attribute first ... |
---|
| 255 | #delattr(ApplicantsContainer, 'prefix') |
---|
| 256 | # ... and replace by ictw |
---|
| 257 | self.applicantscontainer.prefix = 'ictwk' |
---|
| 258 | self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') |
---|
| 259 | self.slip_path = self.view_path + '/application_slip.pdf' |
---|
| 260 | self.browser.open(self.manage_path) |
---|
| 261 | self.assertEqual(self.browser.headers['Status'], '200 Ok') |
---|
| 262 | self.browser.getControl(name="form.firstname").value = 'John' |
---|
| 263 | self.browser.getControl(name="form.middlename").value = 'Anthony' |
---|
| 264 | self.browser.getControl(name="form.lastname").value = 'Tester' |
---|
[13819] | 265 | #self.browser.getControl(name="form.date_of_birth").value = '09/09/1988' |
---|
| 266 | self.browser.getControl(name="form.sex").value = ['m'] |
---|
[13814] | 267 | self.browser.getControl(name="form.email").value = 'xx@yy.zz' |
---|
[13816] | 268 | image = open(SAMPLE_IMAGE, 'rb') |
---|
| 269 | ctrl = self.browser.getControl(name='form.passport') |
---|
| 270 | file_ctrl = ctrl.mech_control |
---|
| 271 | file_ctrl.add_file(image, filename='myphoto.jpg') |
---|
[13814] | 272 | self.browser.getControl("Save").click() |
---|
| 273 | self.applicant.registration_cats = ['group', 'corporate'] |
---|
[13816] | 274 | IWorkflowState(self.applicant).setState('started') |
---|
| 275 | configuration = CustomSessionConfiguration() |
---|
| 276 | configuration.academic_session = session_1 |
---|
| 277 | configuration.application_fee = 0.0 |
---|
| 278 | self.app['configuration'].addSessionConfiguration(configuration) |
---|
[16330] | 279 | self.browser.getControl("Create and make online").click() |
---|
[13816] | 280 | self.assertMatches('...Payment ticket created...', |
---|
| 281 | self.browser.contents) |
---|
| 282 | self.assertEqual(self.applicant.values()[0].amount_auth, 450000) |
---|
[13814] | 283 | IWorkflowState(self.applicant).setState('submitted') |
---|
| 284 | self.browser.open(self.view_path) |
---|
| 285 | self.assertTrue('Group Registration @ ₦ 200000' in self.browser.contents) |
---|
[16330] | 286 | self.browser.open(self.view_path) |
---|
[13814] | 287 | self.browser.getLink("Download application slip").click() |
---|
| 288 | self.assertEqual(self.browser.headers['Status'], '200 Ok') |
---|
| 289 | self.assertEqual(self.browser.headers['Content-Type'], |
---|
| 290 | 'application/pdf') |
---|
| 291 | path = os.path.join(samples_dir(), 'ictwk_application_slip.pdf') |
---|
| 292 | open(path, 'wb').write(self.browser.contents) |
---|
| 293 | print "Sample ictwk_application_slip.pdf written to %s" % path |
---|
[16078] | 294 | |
---|
[16184] | 295 | def test_transcript_application(self): |
---|
[16151] | 296 | configuration = CustomSessionConfiguration() |
---|
[16078] | 297 | configuration.academic_session = session_1 |
---|
| 298 | self.app['configuration'].addSessionConfiguration(configuration) |
---|
| 299 | # Add special application container |
---|
| 300 | applicantscontainer = ApplicantsContainer() |
---|
| 301 | applicantscontainer.year = session_1 |
---|
[16151] | 302 | applicantscontainer.application_fee = 1.0 # Must be set but is not used. |
---|
[16183] | 303 | applicantscontainer.code = u'tsc1234' |
---|
[16164] | 304 | applicantscontainer.prefix = 'tscf' |
---|
[16183] | 305 | applicantscontainer.title = u'This is a tsc container' |
---|
[16078] | 306 | applicantscontainer.application_category = 'no' |
---|
| 307 | applicantscontainer.mode = 'create' |
---|
| 308 | applicantscontainer.strict_deadline = True |
---|
[16184] | 309 | applicantscontainer.with_picture = True |
---|
[16078] | 310 | delta = datetime.timedelta(days=10) |
---|
| 311 | applicantscontainer.startdate = datetime.datetime.now(pytz.utc) - delta |
---|
| 312 | applicantscontainer.enddate = datetime.datetime.now(pytz.utc) + delta |
---|
[16183] | 313 | self.app['applicants']['tsc1234'] = applicantscontainer |
---|
[16078] | 314 | # Add an applicant |
---|
| 315 | applicant = createObject('waeup.Applicant') |
---|
| 316 | # reg_number is the only field which has to be preset here |
---|
| 317 | # because managers are allowed to edit this required field |
---|
| 318 | applicant.reg_number = u'12345' |
---|
[17593] | 319 | applicant.collected = True |
---|
[16183] | 320 | self.app['applicants']['tsc1234'].addApplicant(applicant) |
---|
[16078] | 321 | IUserAccount( |
---|
[16183] | 322 | self.app['applicants']['tsc1234'][ |
---|
[16078] | 323 | applicant.application_number]).setPassword('apwd') |
---|
| 324 | # Login |
---|
| 325 | self.browser.open(self.login_path) |
---|
| 326 | self.browser.getControl( |
---|
| 327 | name="form.login").value = applicant.applicant_id |
---|
| 328 | self.browser.getControl(name="form.password").value = 'apwd' |
---|
| 329 | self.browser.getControl("Login").click() |
---|
| 330 | self.browser.getLink("Application record").click() |
---|
| 331 | self.browser.getControl(name="form.date_of_birth").value = '09/09/1988' |
---|
| 332 | self.browser.getControl(name="form.email").value = 'xx@yy.zz' |
---|
| 333 | self.browser.getControl(name="form.firstname").value = 'Angela' |
---|
| 334 | self.browser.getControl(name="form.lastname").value = 'Merkel' |
---|
| 335 | self.browser.getControl(name="form.sex").value = ['f'] |
---|
[16151] | 336 | self.browser.getControl(name="form.no_copies").value = ['2'] |
---|
[16078] | 337 | self.browser.getControl(name="form.course_studied").value = ['CERT1'] |
---|
[17659] | 338 | self.browser.getControl(name="form.matric_number").value = 'a234' |
---|
[16184] | 339 | self.browser.getControl(name="form.dispatch_address").value = 'Kuensche\nMarsch 5' |
---|
[16078] | 340 | self.browser.getControl(name="form.entry_mode").value = ['ug_ft'] |
---|
| 341 | self.browser.getControl(name="form.entry_session").value = ['2014'] |
---|
| 342 | self.browser.getControl(name="form.end_session").value = ['2015'] |
---|
| 343 | self.browser.getControl(name="form.phone.country").value = ['+234'] |
---|
| 344 | self.browser.getControl(name="form.phone.ext").value = '5678' |
---|
[16151] | 345 | self.browser.getControl(name="form.charge").value = ['nigeria'] |
---|
[16773] | 346 | self.browser.getControl(name="form.order").value = ['o'] |
---|
[16184] | 347 | image = open(SAMPLE_IMAGE, 'rb') |
---|
| 348 | ctrl = self.browser.getControl(name='form.passport') |
---|
| 349 | file_ctrl = ctrl.mech_control |
---|
| 350 | file_ctrl.add_file(image, filename='myphoto.jpg') |
---|
[16078] | 351 | self.browser.getControl("Save").click() |
---|
[16504] | 352 | applicant_url = self.browser.url |
---|
[16330] | 353 | self.browser.getControl("Create and make online").click() |
---|
[16078] | 354 | self.assertTrue('Payment ticket created' in self.browser.contents) |
---|
[16151] | 355 | self.assertTrue('<span>40000.0</span>' in self.browser.contents) |
---|
| 356 | self.assertEqual(applicant.values()[0].amount_auth, 40000.0) |
---|
[16504] | 357 | applicant.values()[0].p_state = 'paid' |
---|
| 358 | payment_url = self.browser.url |
---|
[16184] | 359 | IWorkflowState(applicant).setState('submitted') |
---|
[16504] | 360 | self.browser.open(payment_url) |
---|
| 361 | self.browser.getLink("Download payment slip").click() |
---|
| 362 | self.assertEqual(self.browser.headers['Status'], '200 Ok') |
---|
| 363 | self.assertEqual(self.browser.headers['Content-Type'], |
---|
| 364 | 'application/pdf') |
---|
| 365 | path = os.path.join(samples_dir(), 'tscf_payment_slip.pdf') |
---|
| 366 | open(path, 'wb').write(self.browser.contents) |
---|
| 367 | print "Sample tscf_payment_slip.pdf written to %s" % path |
---|
| 368 | self.browser.open(applicant_url) |
---|
[16184] | 369 | self.browser.getLink("My Data").click() |
---|
| 370 | self.browser.getLink("Download application slip").click() |
---|
| 371 | self.assertEqual(self.browser.headers['Status'], '200 Ok') |
---|
| 372 | self.assertEqual(self.browser.headers['Content-Type'], |
---|
| 373 | 'application/pdf') |
---|
| 374 | path = os.path.join(samples_dir(), 'tscf_application_slip.pdf') |
---|
| 375 | open(path, 'wb').write(self.browser.contents) |
---|
| 376 | print "Sample tscf_application_slip.pdf written to %s" % path |
---|
[16078] | 377 | return |
---|