- Timestamp:
- 23 Mar 2012, 06:48:01 (13 years ago)
- Location:
- main/waeup.custom/trunk/src/waeup/custom
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.custom/trunk/src/waeup/custom/etranzact/tests.py
r7929 r7970 20 20 from waeup.custom.testing import FunctionalLayer 21 21 22 23 # Also run tests that send requests to external servers? 24 # If you enable this, please make sure the external services 25 # do exist really and are not bothered by being spammed by a test programme. 26 EXTERNAL_TESTS = False 27 28 def external_test(func): 29 if not EXTERNAL_TESTS: 30 myself = __file__ 31 if myself.endswith('.pyc'): 32 myself = myself[:-2] 33 print "WARNING: external tests are skipped!" 34 print "WARNING: edit %s to enable them." % myself 35 return 36 return func 37 22 38 class EtranzactTests(StudentsFullSetup): 23 39 """Tests foreTranzact payment gateway. … … 28 44 CONFIRMATION_NO = '500856521315472785095' 29 45 46 def test_dummy(self): 47 return 48 49 @external_test 30 50 def test_etranzact_query_history(self): 31 51 -
main/waeup.custom/trunk/src/waeup/custom/interswitch/browser.py
r7934 r7970 191 191 student = self.context.getStudent() 192 192 query = self.request.form 193 # Should be logged instead of printed194 193 write_log_message(self,'callback received: %s' % query) 195 194 … … 214 213 if self.context.r_amount_approved != total_amount_auth: 215 214 self.flash(_('Wrong amount')) 216 write_log_message( self,'successful but wrong amount: %s' % self.context.p_id)217 self.context.p_state = 'failed'218 return219 220 # Add webservice validation 215 write_log_message( 216 self,'successful but wrong amount: %s' % self.context.p_id) 217 self.context.p_state = 'failed' 218 return 219 221 220 try: 222 221 validation_list = get_SOAP_response( 223 222 PRODUCT_ID, self.context.p_id).split(':') 224 223 # Validation does not make sense yet since the query string 225 # formats are conflicting. We are only printing the validation string, 226 # nothing else. 227 print validation_list 224 # formats are conflicting. We are only printing the validation 225 # string, nothing else. 226 print 'WARNING: Webservice validation is not yet implemented' 227 print 'validation list: %s' % validation_list 228 228 except: 229 229 print 'Connection to webservice failed.' 230 231 # Add webservice validation here 230 232 231 233 write_log_message(self,'valid callback: %s' % self.context.p_id) 232 234 self.context.p_state = 'paid' 233 235 self.context.payment_date = datetime.now() 234 235 236 actions_after_payment(student, self.context, self) 236 237 237 return 238 238 … … 271 271 self.flash(_('Unsuccessful callback: ${a}', 272 272 mapping = {'a': wlist[1]})) 273 write_log_message(self,'unsuccessful callback: %s' % self.context.p_id) 273 write_log_message( 274 self,'unsuccessful callback: %s' % self.context.p_id) 274 275 self.context.p_state = 'failed' 275 276 return … … 282 283 if self.context.r_amount_approved != total_amount_auth: 283 284 self.flash(_('Wrong amount')) 284 write_log_message(self,'successful callback but wrong amount: %s' % self.context.p_id) 285 write_log_message( 286 self,'successful callback but wrong amount: %s' 287 % self.context.p_id) 285 288 self.context.p_state = 'failed' 286 289 return … … 288 291 if wlist[4] != self.context.p_id: 289 292 self.flash(_('Wrong transaction id')) 290 write_log_message(self,'successful callback but wrong transaction id: %s' % self.context.p_id) 293 write_log_message( 294 self,'successful callback but wrong transaction id: %s' 295 % self.context.p_id) 291 296 self.context.p_state = 'failed' 292 297 return -
main/waeup.custom/trunk/src/waeup/custom/interswitch/tests.py
r7930 r7970 20 20 from waeup.custom.testing import FunctionalLayer 21 21 22 # Also run tests that send requests to external servers? 23 # If you enable this, please make sure the external services 24 # do exist really and are not bothered by being spammed by a test programme. 25 EXTERNAL_TESTS = False 26 27 def external_test(func): 28 if not EXTERNAL_TESTS: 29 myself = __file__ 30 if myself.endswith('.pyc'): 31 myself = myself[:-2] 32 print "WARNING: external tests are skipped!" 33 print "WARNING: edit %s to enable them." % myself 34 return 35 return func 36 37 22 38 class InterswitchTests(StudentsFullSetup): 23 39 """Tests for the Interswitch payment gateway. … … 25 41 26 42 layer = FunctionalLayer 43 44 def setUp(self): 45 super(InterswitchTests, self).setUp() 46 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 47 self.browser.open(self.payments_student_path) 48 IWorkflowState(self.student).setState('cleared') 49 self.browser.open(self.payments_student_path + '/addop') 50 self.browser.getControl("Create ticket").click() 51 self.assertMatches('...ticket created...', 52 self.browser.contents) 53 ctrl = self.browser.getControl(name='val_id') 54 value = ctrl.options[0] 55 self.browser.getLink(value).click() 56 self.assertMatches('...Amount Authorized...', 57 self.browser.contents) 58 self.payment_url = self.browser.url 59 27 60 28 61 def callback_url(self, payment_url, resp, apprAmt): … … 37 70 '&url=http://xyz') % (resp, apprAmt) 38 71 39 def test_ callback(self):72 def test_interswitch_form(self): 40 73 41 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')42 self.browser.open(self.payments_student_path)43 IWorkflowState(self.student).setState('cleared')44 self.browser.open(self.payments_student_path + '/addop')45 self.browser.getControl("Create ticket").click()46 self.assertMatches('...ticket created...',47 self.browser.contents)48 ctrl = self.browser.getControl(name='val_id')49 value = ctrl.options[0]50 self.browser.getLink(value).click()51 self.assertMatches('...Amount Authorized...',52 self.browser.contents)53 payment_url = self.browser.url54 55 74 # Manager can access InterswitchForm 56 75 self.browser.getLink("CollegePAY", index=0).click() … … 61 80 self.browser.contents) 62 81 82 @external_test 83 def test_callback(self): 84 63 85 # Manager can call callback manually 64 self.browser.open(self.callback_url( payment_url, 'XX', '300'))86 self.browser.open(self.callback_url(self.payment_url, 'XX', '300')) 65 87 self.assertMatches('...Unsuccessful callback: Something went wrong...', 66 88 self.browser.contents) 67 89 self.assertMatches('...Failed...', 68 90 self.browser.contents) 69 self.browser.open( payment_url + '/callback')91 self.browser.open(self.payment_url + '/callback') 70 92 self.assertMatches('...Unsuccessful callback: Incomplete query string...', 71 93 self.browser.contents) 72 94 self.assertMatches('...Failed...', 73 95 self.browser.contents) 74 self.browser.open(self.callback_url( payment_url, '00', '300000'))96 self.browser.open(self.callback_url(self.payment_url, '00', '300000')) 75 97 self.assertMatches('...Wrong amount...', 76 98 self.browser.contents) 77 self.browser.open(self.callback_url( payment_url, '00', '4000000'))99 self.browser.open(self.callback_url(self.payment_url, '00', '4000000')) 78 100 self.assertMatches('...Valid callback received...', 79 101 self.browser.contents) 80 102 103 @external_test 81 104 def test_webservice(self): 82 105 83 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 84 self.browser.open(self.payments_student_path) 85 IWorkflowState(self.student).setState('cleared') 86 self.browser.open(self.payments_student_path + '/addop') 87 self.browser.getControl("Create ticket").click() 88 self.assertMatches('...ticket created...', 89 self.browser.contents) 90 ctrl = self.browser.getControl(name='val_id') 91 value = ctrl.options[0] 92 self.browser.getLink(value).click() 93 self.assertMatches('...Amount Authorized...', 94 self.browser.contents) 95 payment_url = self.browser.url 96 97 self.browser.open(payment_url + '/request_webservice') 106 self.browser.open(self.payment_url + '/request_webservice') 98 107 self.assertMatches('...Unsuccessful callback...', 99 108 self.browser.contents)
Note: See TracChangeset for help on using the changeset viewer.