Changeset 7252
- Timestamp:
- 2 Dec 2011, 21:11:44 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/applicants
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser.py
r7250 r7252 531 531 payment.surcharge_3 = academic_session.surcharge_3 532 532 self.context[payment.p_id] = payment 533 #import pdb; pdb.set_trace()534 533 self.flash('Payment ticket created.') 535 534 return … … 929 928 return 930 929 930 # We explicitely want the forms to be validated before payment tickets 931 # can be created. If no validation is requested, use 932 # 'validator=NullValidator' in the grok.action directive 931 933 @grok.action('Add online payment ticket') 932 934 def addPaymentTicket(self, **data): 933 935 self.redirect(self.url(self.context, '@@addafp')) 936 return 934 937 935 938 @grok.action('Remove selected tickets') … … 983 986 984 987 def dataNotComplete(self): 988 store = getUtility(IExtFileStore) 989 if not store.getFileByContext(self.context, attr=u'passport.jpg'): 990 return 'No passport picture uploaded.' 985 991 if not self.request.form.get('confirm_passport', False): 986 return 'Passport confirmation box not ticked.'992 return 'Passport picture confirmation box not ticked.' 987 993 return False 988 994 995 # We explicitely want the forms to be validated before payment tickets 996 # can be created. If no validation is requested, use 997 # 'validator=NullValidator' in the grok.action directive 989 998 @grok.action('Add online payment ticket') 990 999 def addPaymentTicket(self, **data): 991 1000 self.redirect(self.url(self.context, '@@addafp')) 1001 return 992 1002 993 1003 @grok.action('Remove selected tickets') … … 999 1009 @grok.action('Save') 1000 1010 def save(self, **data): 1011 #import pdb; pdb.set_trace() 1001 1012 if self.passport_changed is False: # False is not None! 1002 1013 return # error during image upload. Ignore other values … … 1009 1020 if self.passport_changed is False: # False is not None! 1010 1021 return # error during image upload. Ignore other values 1011 self.applyData(self.context, **data)1012 self.context._p_changed = True1013 1022 if self.dataNotComplete(): 1014 1023 self.flash(self.dataNotComplete()) 1015 1024 return 1025 self.applyData(self.context, **data) 1016 1026 state = IWorkflowState(self.context).getState() 1017 1027 # This shouldn't happen, but the application officer -
main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_browser.py
r7240 r7252 28 28 from zope.security.interfaces import Unauthorized 29 29 from zope.testbrowser.testing import Browser 30 from hurry.workflow.interfaces import IWorkflowInfo 30 from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState 31 31 from waeup.sirp.testing import FunctionalLayer, FunctionalTestCase 32 32 from waeup.sirp.app import University 33 from waeup.sirp.configuration import SessionConfiguration 33 34 from waeup.sirp.applicants.container import ApplicantsContainer 34 35 from waeup.sirp.applicants.applicant import Applicant … … 556 557 return 557 558 559 def test_pay_acceptance_fee(self): 560 self.login() 561 self.browser.open(self.edit_path) 562 # Payment tickets can't be created before the form has been validated 563 self.browser.getControl("Add online payment ticket").click() 564 self.assertTrue('Required input is missing' in self.browser.contents) 565 self.fill_correct_values() 566 # We have to savethe form otherwise the filled fields will be cleared 567 # after adding an online payment, because adding an online payment 568 # requires a filled form but does not save it 569 self.browser.getControl("Save").click() 570 self.browser.getControl("Add online payment ticket").click() 571 # Session object missing 572 self.assertTrue( 573 'Session configuration object is not available' 574 in self.browser.contents) 575 configuration = SessionConfiguration() 576 configuration.academic_session = 2009 577 configuration.acceptance_fee = 200 578 self.app['configuration'].addSessionConfiguration(configuration) 579 self.browser.open(self.edit_path) 580 self.fill_correct_values() 581 self.browser.getControl("Add online payment ticket").click() 582 self.assertMatches('...Payment ticket created...', self.browser.contents) 583 # Payment ticket can be removed if they haven't received a valid callback 584 ctrl = self.browser.getControl(name='val_id') 585 value = ctrl.options[0] 586 ctrl.getControl(value=value).selected = True 587 self.browser.getControl("Remove selected", index=0).click() 588 self.assertMatches('...Successfully removed...', self.browser.contents) 589 # We will try the callback request view 590 self.browser.getControl("Add online payment ticket").click() 591 ctrl = self.browser.getControl(name='val_id') 592 value = ctrl.options[0] 593 self.browser.getLink(value).click() 594 self.assertMatches('...Amount Authorized...', 595 self.browser.contents) 596 payment_url = self.browser.url 597 # The pdf payment receipt can't yet be opened 598 self.browser.open(payment_url + '/payment_receipt.pdf') 599 self.assertMatches('...Ticket not yet paid...', 600 self.browser.contents) 601 # Request callback 602 self.browser.open(payment_url) 603 self.browser.getLink("Request callback").click() 604 self.assertMatches('...Valid callback received...', 605 self.browser.contents) 606 # Callback can't be applied twice 607 self.browser.open(payment_url + '/callback') 608 self.assertMatches('...This ticket has already been paid...', 609 self.browser.contents) 610 # The payment receipt can be downloaded now 611 self.browser.open(payment_url) 612 self.browser.getLink("Download payment receipt").click() 613 self.assertEqual(self.browser.headers['Status'], '200 Ok') 614 self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf') 615 # Applicant is is in state 'paid' 616 self.browser.open(self.view_path) 617 self.assertMatches('...paid...', 618 self.browser.contents) 619 state = IWorkflowState(self.applicant).getState() 620 self.assertTrue(state == 'paid') 621 558 622 def test_final_submit(self): 559 623 # Make sure that a correctly filled form with passport picture 560 # can be submitted 624 # can be submitted (only) after payment 561 625 self.login() 562 626 self.browser.getLink("Edit application record").click() 627 self.assertFalse('Final Submit' in self.browser.contents) 628 IWorkflowInfo(self.applicant).fireTransition('pay') 629 self.browser.open(self.edit_path) 630 self.assertTrue('Final Submit' in self.browser.contents) 563 631 self.fill_correct_values() # fill other fields with correct values 632 self.browser.getControl("Final Submit").click() 633 # We forgot to upload a passport picture 634 self.assertTrue( 635 'No passport picture uploaded' in self.browser.contents) 564 636 # Create a pseudo image file and select it to be uploaded in form 565 637 pseudo_image = StringIO('I pretend to be a graphics file') … … 568 640 file_ctrl.add_file(pseudo_image, filename='myphoto.jpg') 569 641 self.browser.getControl("Final Submit").click() # (finally) submit form 570 self.assertEqual(self.browser.headers['Status'], '200 Ok') 571 self.assertTrue( 572 'Passport confirmation box not ticked' in self.browser.contents) 573 self.browser.getControl(name="confirm_passport").value = True 574 IWorkflowInfo(self.applicant).fireTransition('submit') 575 self.browser.getControl("Final Submit").click() # submit form again 576 self.assertTrue( 577 'Wrong state' in self.browser.contents) 578 IWorkflowInfo(self.applicant).fireTransition('reset1') 579 # Now do the whole thing again but with correct state 580 self.login() 581 self.browser.open(self.edit_path) 582 self.fill_correct_values() 583 pseudo_image = StringIO('I pretend to be a graphics file') 584 ctrl = self.browser.getControl(name='form.passport') 585 file_ctrl = ctrl.mech_control 586 file_ctrl.add_file(pseudo_image, filename='myphoto.jpg') 642 # The picture has been uploaded but the form cannot be submitted 643 # since the passport confirmation box was not ticked 644 self.assertTrue( 645 'Passport picture confirmation box not ticked' in self.browser.contents) 587 646 self.browser.getControl(name="confirm_passport").value = True 588 647 self.browser.getControl("Final Submit").click()
Note: See TracChangeset for help on using the changeset viewer.