source: main/waeup.uniben/trunk/src/waeup/uniben/interswitch/tests.py @ 16281

Last change on this file since 16281 was 15716, checked in by Henrik Bettermann, 5 years ago

Update test.

  • Property svn:keywords set to Id
File size: 25.2 KB
RevLine 
[7894]1## $Id: tests.py 15716 2019-10-29 10:32:34Z henrik $
2##
3## Copyright (C) 2011 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##
[9775]18import os
[12980]19from datetime import datetime, date, timedelta
[9713]20from zope.component import createObject, getUtility
21from zope.catalog.interfaces import ICatalog
[7894]22from hurry.workflow.interfaces import IWorkflowState
23from waeup.kofa.students.tests.test_browser import StudentsFullSetup
[8266]24from waeup.kofa.applicants.tests.test_browser import ApplicantsFullSetup
[11787]25from waeup.uniben.configuration import CustomSessionConfiguration
[8020]26from waeup.uniben.testing import FunctionalLayer
[7894]27
[7970]28# Also run tests that send requests to external servers?
29#   If you enable this, please make sure the external services
30#   do exist really and are not bothered by being spammed by a test programme.
[9831]31EXTERNAL_TESTS = False
[7970]32
[11728]33SAMPLE_IMAGE = os.path.join(os.path.dirname(__file__), 'test_image.jpg')
34
[7970]35def external_test(func):
36    if not EXTERNAL_TESTS:
37        myself = __file__
38        if myself.endswith('.pyc'):
39            myself = myself[:-2]
40        print "WARNING: external tests are skipped!"
41        print "WARNING: edit %s to enable them." % myself
42        return
43    return func
44
45
[8266]46class InterswitchTestsStudents(StudentsFullSetup):
[7929]47    """Tests for the Interswitch payment gateway.
[7894]48    """
49
50    layer = FunctionalLayer
51
[7970]52    def setUp(self):
[8266]53        super(InterswitchTestsStudents, self).setUp()
[14758]54        self.app['configuration']['2004'].interswitch_enabled = True
[7970]55        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
[7995]56        self.browser.open(self.payments_path)
[7970]57        IWorkflowState(self.student).setState('cleared')
[9006]58        self.student.nationality = u'NG'
[7995]59        self.browser.open(self.payments_path + '/addop')
[9384]60        self.browser.getControl(name="form.p_category").value = ['schoolfee']
[7970]61        self.browser.getControl("Create ticket").click()
[9435]62        self.assertMatches('...ticket created...',
63                           self.browser.contents)
64        ctrl = self.browser.getControl(name='val_id')
[9775]65        self.value = ctrl.options[0]
66        self.browser.getLink(self.value).click()
[9435]67        self.assertMatches('...Amount Authorized...',
68                           self.browser.contents)
[13111]69        self.assertTrue(
70            '<span>40000.0</span>' in self.browser.contents)
[9435]71        self.payment_url = self.browser.url
[7970]72
[8263]73#    def callback_url(self, payment_url, resp, apprAmt):
74#        return payment_url + (
75#            '/isw_callback?echo=' +
76#            '&resp=%s' +
77#            '&desc=Something went wrong' +
78#            '&txnRef=p1331792385335' +
79#            '&payRef=' + '&retRef=' +
80#            '&cardNum=0' +
81#            '&apprAmt=%s' +
82#            '&url=http://xyz') % (resp, apprAmt)
[7894]83
[7970]84    def test_interswitch_form(self):
[7894]85        # Manager can access InterswitchForm
[15716]86        self.browser.getLink("Pay via Interswitch", index=0).click()
[8266]87        # The total amount to be processed by Interswitch
88        # has been reduced by the Interswitch fee of 150 Nairas
[13111]89        self.assertTrue('<input type="hidden" name="pay_item_id" value="5700" />'
90                           in self.browser.contents)
91        self.assertTrue('Total Amount Authorized:'
92                           in self.browser.contents)
[9460]93        self.assertEqual(self.student.current_mode, 'ug_ft')
[13111]94        self.assertTrue(
95            '<input type="hidden" name="amount" value="4000000" />'
96            in self.browser.contents)
97        self.assertTrue(
[14237]98            'item_name="School Fee" item_amt="3835000" bank_id="8" acct_num="2017506430"'
[13111]99            in self.browser.contents)
100        self.assertTrue(
[14237]101            'item_name="BT Education" item_amt="150000" bank_id="117" acct_num="1014261520"'
[13111]102            in self.browser.contents)
[7894]103
[9520]104        # Create school fee ticket for returning students. Payment is made
105        # for next session.
106        current_payment_key = self.student['payments'].keys()[0]
[9389]107        self.certificate.study_mode = u'ug_pt'
108        IWorkflowState(self.student).setState('returning')
109        configuration = createObject('waeup.SessionConfiguration')
110        configuration.academic_session = 2005
111        self.app['configuration'].addSessionConfiguration(configuration)
[9384]112        self.browser.open(self.payments_path + '/addop')
[9389]113        self.browser.getControl(name="form.p_category").value = ['schoolfee']
[9384]114        self.browser.getControl("Create ticket").click()
[9570]115
116        ## Next session payment can't be made ...
117        #self.assertMatches(
118        #    '...You have not yet paid your current/active session...',
119        #    self.browser.contents)
120        ## current session payment must be approved first.
121        #self.student['payments'][current_payment_key].approve()
122        #self.browser.open(self.payments_path + '/addop')
123        #self.browser.getControl(name="form.p_category").value = ['schoolfee']
124        #self.browser.getControl("Create ticket").click()
125
[9384]126        ctrl = self.browser.getControl(name='val_id')
127        value = ctrl.options[1]
[9775]128        self.assertEqual(self.student['payments'][value].provider_amt, 0.0)
129        self.assertEqual(self.student['payments'][value].gateway_amt, 0.0)
[9384]130        self.browser.getLink(value).click()
[15716]131        self.browser.getLink("Pay via Interswitch", index=0).click()
[9775]132        # Split amounts have been set.
[14237]133        self.assertEqual(self.student['payments'][value].provider_amt, 1500.0)
[9775]134        self.assertEqual(self.student['payments'][value].gateway_amt, 150.0)
[13111]135        self.assertTrue('<input type="hidden" name="pay_item_id" value="5701" />'
136                           in self.browser.contents)
137        self.assertTrue(
138            '<input type="hidden" name="amount" value="2000000" />'
139            in self.browser.contents)
140        self.assertTrue(
[14237]141            'item_name="School Fee" item_amt="1835000" bank_id="8" acct_num="2017506430"'
[13111]142            in self.browser.contents)
143        self.assertTrue(
[14237]144            'item_name="BT Education" item_amt="150000" bank_id="117" acct_num="1014261520"'
[13111]145            in self.browser.contents)
[9389]146
147        # Create clearance fee ticket
[10902]148        #self.browser.open(self.payments_path + '/addop')
149        #self.browser.getControl(name="form.p_category").value = ['clearance']
150        #self.browser.getControl("Create ticket").click()
151        #ctrl = self.browser.getControl(name='val_id')
152        #value = ctrl.options[2]
153        #self.browser.getLink(value).click()
154        #self.assertMatches(
155        #    '...<span>45000.0</span>...',
156        #    self.browser.contents)
157        ## Manager can access InterswitchForm
[15716]158        #self.browser.getLink("Pay via Interswitch", index=0).click()
[10902]159        #self.assertEqual(self.student['payments'][value].provider_amt, 1500.0)
160        #self.assertEqual(self.student['payments'][value].gateway_amt, 150.0)
161        #self.assertMatches('...<input type="hidden" name="pay_item_id" value="5702" />...',
162        #                   self.browser.contents)
163        #self.assertMatches('...Total Amount Authorized:...',
164        #                   self.browser.contents)
165        #self.assertMatches(
166        #    '...<input type="hidden" name="amount" value="4500000.0" />...',
167        #    self.browser.contents)
168        #self.assertMatches(
169        #    '...item_name="Acceptance Fee" item_amt="4335000" bank_id="7" acct_num="1003475516"...',
170        #    self.browser.contents)
171        #self.assertMatches(
172        #    '...item_name="BT Education" item_amt="150000" bank_id="117" acct_num="1010764827"...',
173        #    self.browser.contents)
[9384]174
[9515]175        # Create gown fee ticket
176        configuration.maint_fee = 987.0
177        self.app['configuration']['2004'].gown_fee = 234.0
178        self.browser.open(self.payments_path + '/addop')
179        self.browser.getControl(name="form.p_category").value = ['gown']
180        self.browser.getControl("Create ticket").click()
181        ctrl = self.browser.getControl(name='val_id')
[10902]182        value = ctrl.options[2]
[9515]183        self.browser.getLink(value).click()
[13111]184        self.assertTrue(
185            '<span>234.0</span>',
[9515]186            self.browser.contents)
187        # Manager can access InterswitchForm
[15716]188        self.browser.getLink("Pay via Interswitch", index=0).click()
[9775]189        self.assertEqual(self.student['payments'][value].provider_amt, 0.0)
190        self.assertEqual(self.student['payments'][value].gateway_amt, 150.0)
[13111]191        self.assertTrue('<input type="hidden" name="pay_item_id" value="5704" />'
192                           in self.browser.contents)
193        self.assertTrue('Total Amount Authorized:'
194                           in self.browser.contents)
195        self.assertTrue(
196            '<input type="hidden" name="amount" value="23400" />'
197            in self.browser.contents)
198        self.assertTrue(
[13771]199            '<item_detail item_id="1" item_name="Gown Hire Fee" item_amt="8400" bank_id="8" acct_num="2017506430" />'
[13111]200            in self.browser.contents)
[9515]201        self.assertFalse(
202            'item_name="BT Education"' in self.browser.contents)
[9384]203
[12566]204        # Create hostel application ticket
[13251]205        #self.browser.open(self.payments_path + '/addop')
206        #self.browser.getControl(name="form.p_category").value = ['hostel_application']
207        #self.browser.getControl("Create ticket").click()
208        #ctrl = self.browser.getControl(name='val_id')
209        #value = ctrl.options[3]
210        #self.browser.getLink(value).click()
211        #self.assertTrue(
212        #    '<span>1000.0</span>' in self.browser.contents)
213        #self.student['payments'][value].approve()
[12566]214
[9727]215        # Create temp maint fee ticket
[13251]216        #self.browser.open(self.payments_path + '/addop')
217        #self.browser.getControl(name="form.p_category").value = ['tempmaint_1']
218        #self.browser.getControl("Create ticket").click()
219        #ctrl = self.browser.getControl(name='val_id')
220        #value = ctrl.options[4]
221        #self.browser.getLink(value).click()
222        #self.assertTrue(
223        #    '<span>8150.0</span>' in self.browser.contents)
[9727]224        # Manager can access InterswitchForm
[15716]225        #self.browser.getLink("Pay via Interswitch", index=0).click()
[13251]226        #self.assertEqual(self.student['payments'][value].provider_amt, 0.0)
227        #self.assertEqual(self.student['payments'][value].gateway_amt, 150.0)
228        #self.assertTrue('<input type="hidden" name="pay_item_id" value="5705" />'
229        #                 in self.browser.contents)
230        #self.assertMatches('...Total Amount Authorized:...',
231        #                   self.browser.contents)
232        #self.assertTrue(
233        #    '<input type="hidden" name="amount" value="815000" />'
234        #    in self.browser.contents)
235        #self.assertTrue(
236        #    '<item_detail item_id="1" item_name="Hostel Maintenance Fee" item_amt="800000" bank_id="129" acct_num="0014419432" />'
237        #    in self.browser.contents)
238        #self.assertFalse(
239        #    'item_name="BT Education"' in self.browser.contents)
[9727]240
[9863]241        # Create previous session fee ticket
242        configuration = createObject('waeup.SessionConfiguration')
243        configuration.academic_session = 2003
244        configuration.clearance_fee = 3456.0
245        self.app['configuration'].addSessionConfiguration(configuration)
246        self.student['studycourse'].entry_session = 2002
[10902]247        #self.browser.open(self.payments_path + '/addpp')
248        #self.browser.getControl(name="form.p_category").value = ['clearance']
249        #self.browser.getControl(name="form.p_session").value = ['2003']
250        #self.browser.getControl(name="form.p_level").value = ['300']
251        #self.browser.getControl("Create ticket").click()
252        #ctrl = self.browser.getControl(name='val_id')
253        #value = ctrl.options[5]
254        #self.browser.getLink(value).click()
255        #self.assertMatches(
256        #    '...<span>45000.0</span>...',
257        #    self.browser.contents)
258        ## Manager can access InterswitchForm
[15716]259        #self.browser.getLink("Pay via Interswitch", index=0).click()
[10902]260        #self.assertEqual(self.student['payments'][value].provider_amt, 1500.0)
261        #self.assertEqual(self.student['payments'][value].gateway_amt, 150.0)
262        #self.assertMatches('...<input type="hidden" name="pay_item_id" value="5702" />...',
263        #                   self.browser.contents)
264        #self.assertMatches('...Total Amount Authorized:...',
265        #                   self.browser.contents)
266        ##self.assertMatches(
267        #    '...<input type="hidden" name="amount" value="4500000.0" />...',
268        #    self.browser.contents)
269        #self.assertMatches(
270        #    '...<item_detail item_id="1" item_name="Acceptance Fee" item_amt="4335000" bank_id="7" acct_num="1003475516" />...',
271        #    self.browser.contents)
[9863]272
[9869]273        # Create balance payment ticket
274        self.browser.open(self.payments_path + '/addbp')
275        self.browser.getControl(name="form.p_category").value = ['schoolfee']
276        self.browser.getControl(name="form.balance_session").value = ['2003']
277        self.browser.getControl(name="form.balance_level").value = ['300']
278        self.browser.getControl(name="form.balance_amount").value = '200'
279        self.browser.getControl("Create ticket").click()
280        ctrl = self.browser.getControl(name='val_id')
[13251]281        value = ctrl.options[3]
[9869]282        self.browser.getLink(value).click()
[13111]283        self.assertTrue(
284            '<span>200.0</span>' in self.browser.contents)
[9869]285        # Manager can access InterswitchForm
[15716]286        self.browser.getLink("Pay via Interswitch", index=0).click()
[9869]287        self.assertEqual(self.student['payments'][value].provider_amt, 0.0)
288        self.assertEqual(self.student['payments'][value].gateway_amt, 150.0)
[13111]289        self.assertTrue('<input type="hidden" name="pay_item_id" value="5701" />'
290                           in self.browser.contents)
291        self.assertTrue(
292            '<input type="hidden" name="amount" value="20000" />'
293            in self.browser.contents)
294        self.assertTrue(
[13771]295            'item_name="School Fee" item_amt="5000" bank_id="8" acct_num="2017506430"'
[13111]296            in self.browser.contents)
[9869]297        self.assertFalse(
298            'item_name="BT Education"' in self.browser.contents)
[9863]299
[13785]300        # Create JUPEB fee ticket
301        self.app['configuration']['2004'].jupeb_fee = 345.0
302        self.browser.open(self.payments_path + '/addop')
303        self.browser.getControl(name="form.p_category").value = ['jupeb']
304        self.browser.getControl("Create ticket").click()
305        ctrl = self.browser.getControl(name='val_id')
306        value = ctrl.options[4]
307        self.browser.getLink(value).click()
308        self.assertTrue(
309            '<span>345.0</span>',
310            self.browser.contents)
311        # Manager can access InterswitchForm
[15716]312        self.browser.getLink("Pay via Interswitch", index=0).click()
[13785]313        self.assertEqual(self.student['payments'][value].provider_amt, 0.0)
314        self.assertEqual(self.student['payments'][value].gateway_amt, 150.0)
315        self.assertTrue('<input type="hidden" name="pay_item_id" value="5717" />'
316                           in self.browser.contents)
317        self.assertTrue('Total Amount Authorized:'
318                           in self.browser.contents)
319        self.assertTrue(
320            '<input type="hidden" name="amount" value="34500" />'
321            in self.browser.contents)
322        self.assertTrue(
323            '<item_detail item_id="1" item_name="JUPEB Examination Fee" item_amt="19500" bank_id="8" acct_num="2017506430" />'
324            in self.browser.contents)
325        self.assertFalse(
326            'item_name="BT Education"' in self.browser.contents)
327
[8263]328#    @external_test
329#    def test_callback(self):
[7970]330
[7894]331        # Manager can call callback manually
[8263]332#        self.browser.open(self.callback_url(self.payment_url, 'XX', '300'))
333#        self.assertMatches('...Unsuccessful callback: Something went wrong...',
334#                          self.browser.contents)
335#        self.assertMatches('...Failed...',
336#                           self.browser.contents)
337#        self.browser.open(self.payment_url + '/isw_callback')
338#        self.assertMatches('...Unsuccessful callback: Incomplete query string...',
339#                          self.browser.contents)
340#        self.assertMatches('...Failed...',
341#                           self.browser.contents)
342#        self.browser.open(self.callback_url(self.payment_url, '00', '300000'))
343#        self.assertMatches('...Wrong amount...',
344#                          self.browser.contents)
345#        self.browser.open(self.callback_url(self.payment_url, '00', '4000000'))
346#        self.assertMatches('...Valid callback received...',
347#                          self.browser.contents)
[7930]348
[12980]349    def test_interswitch_form_ticket_expired(self):
350        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
351        acc_payment = createObject('waeup.StudentOnlinePayment')
352        acc_payment.p_state = 'unpaid'
353        acc_payment.p_category = 'clearance'
354        acc_payment.p_id = 'xyz'
355        acc_payment.pay_item_id = '123'
356        acc_payment.amount_auth = 876.0
357        self.student['payments']['xyz'] = acc_payment
358        self.browser.open(self.payments_path + '/xyz')
[15716]359        self.browser.getLink("Pay via Interswitch", index=0).click()
[13111]360        self.assertTrue('<input type="hidden" name="pay_item_id" value="5702" />'
361                           in self.browser.contents)
362        self.assertTrue('Total Amount Authorized:'
363                           in self.browser.contents)
[12980]364        self.assertEqual(self.student.current_mode, 'ug_ft')
[13111]365        self.assertTrue(
366            '<input type="hidden" name="amount" value="87600" />'
367            in self.browser.contents)
[13016]368        delta = timedelta(days=8)
[12980]369        acc_payment.creation_date -= delta
370        self.browser.open(self.payments_path + '/xyz')
[15716]371        self.browser.getLink("Pay via Interswitch", index=0).click()
[12980]372        self.assertMatches(
373            '...This payment ticket is too old. Please create a new ticket...',
374            self.browser.contents)
[13016]375        delta = timedelta(days=2)
[12980]376        acc_payment.creation_date += delta
377        self.browser.open(self.payments_path + '/xyz')
[15716]378        self.browser.getLink("Pay via Interswitch", index=0).click()
[12980]379        self.assertMatches('...Total Amount Authorized:...',
380                           self.browser.contents)
381
[11645]382    def test_pay_twice(self):
383        # Create second ticket
384        self.browser.open(self.payments_path + '/addop')
385        self.browser.getControl(name="form.p_category").value = ['schoolfee']
386        self.browser.getControl("Create ticket").click()
387        # Pay first ticket
388        self.student['payments'][self.value].approve()
389        # Try to pay second ticket
390        self.browser.open(self.payments_path)
391        ctrl = self.browser.getControl(name='val_id')
392        value = ctrl.options[1]
393        self.browser.getLink(value).click()
[15716]394        self.browser.getLink("Pay via Interswitch", index=0).click()
[11645]395        self.assertMatches(
396            '...alert alert-danger">This type of payment has already been made...',
397            self.browser.contents)
398
[7970]399    @external_test
[7930]400    def test_webservice(self):
[9775]401        # First we have open InterswitchPageStudent to set provider_amt
402        # and gateway_amt
403        self.browser.open(self.payment_url + '/goto_interswitch')
404        # Now we can call the webservice
[7970]405        self.browser.open(self.payment_url + '/request_webservice')
[7930]406        self.assertMatches('...Unsuccessful callback...',
407                          self.browser.contents)
[9713]408        # The payment is now in state failed ...
[8266]409        self.assertMatches('...<span>Failed</span>...',
410                          self.browser.contents)
[9713]411        # ... and the catalog has been updated
412        cat = getUtility(ICatalog, name='payments_catalog')
413        results = list(
414            cat.searchResults(p_state=('failed', 'failed')))
415        self.assertEqual(len(results), 1)
416        self.assertEqual(results[0].p_state, 'failed')
[8266]417
[9775]418        # Let's replace the p_id with a valid p_id of the Uniben
419        # live system. This is definitely not an appropriate
420        # solution for testing, but we have no choice since
421        # Interswitch doesn't provide any interface
422        # for testing.
423        payment = self.student['payments'][self.value]
424        payment.p_id = 'p3547789850240'
425        self.browser.open(self.payment_url + '/request_webservice')
426        self.assertMatches('...Callback amount does not match...',
427                          self.browser.contents)
428        # The payment is now in state failed ...
429        self.assertMatches('...<span>Failed</span>...',
430                          self.browser.contents)
431        # Let's replace the amount autorized with the amount of the
432        # live system payment
433        payment.amount_auth = payment.r_amount_approved
434        self.browser.open(self.payment_url + '/request_webservice')
435        self.assertMatches('...Successful payment...',
436                          self.browser.contents)
437        # The payment is now in state paid ...
438        self.assertMatches('...<span>Paid</span>...',
439                          self.browser.contents)
440        # ... and the catalog has been updated
441        cat = getUtility(ICatalog, name='payments_catalog')
442        results = list(
443            cat.searchResults(p_state=('paid', 'paid')))
444        self.assertEqual(len(results), 1)
445        self.assertEqual(results[0].p_state, 'paid')
446        # Approval is logged in students.log ...
447        logfile = os.path.join(
448            self.app['datacenter'].storage, 'logs', 'students.log')
449        logcontent = open(logfile).read()
450        self.assertTrue(
451            'zope.mgr - '
[11633]452            'waeup.uniben.interswitch.browser.CustomInterswitchPaymentRequestWebservicePageStudent - '
[9775]453            'B1000000 - successful schoolfee payment: p3547789850240\n'
454            in logcontent)
455        # ... and in payments.log
456        logfile = os.path.join(
457            self.app['datacenter'].storage, 'logs', 'payments.log')
458        logcontent = open(logfile).read()
459        self.assertTrue(
460            '"zope.mgr",B1000000,p3547789850240,schoolfee,'
461            '12000.0,00,1500.0,150.0,0.0,,,\n'
462            in logcontent)
463
464
[8266]465class InterswitchTestsApplicants(ApplicantsFullSetup):
466    """Tests for the Interswitch payment gateway.
467    """
468
469    layer = FunctionalLayer
470
471    def setUp(self):
472        super(InterswitchTestsApplicants, self).setUp()
[11787]473        configuration = CustomSessionConfiguration()
[10836]474        configuration.academic_session = datetime.now().year - 2
[14758]475        configuration.interswitch_enabled = True
[13887]476        self.applicantscontainer.application_fee = 1000.0
[10836]477        self.app['configuration'].addSessionConfiguration(configuration)
[8266]478        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
479        self.browser.open(self.manage_path)
480        #IWorkflowState(self.student).setState('started')
481        super(InterswitchTestsApplicants, self).fill_correct_values()
[11728]482        self.browser.getControl("Add online").click()
[11752]483        self.assertMatches('...passport photo before making payment...',
[11728]484                           self.browser.contents)
485        self.browser.open(self.manage_path)
486        super(InterswitchTestsApplicants, self).fill_correct_values()
487        #self.browser.getControl(name="form.nationality").value = ['NG']
488        #self.browser.getControl(name="transition").value = ['start']
489        image = open(SAMPLE_IMAGE, 'rb')
490        ctrl = self.browser.getControl(name='form.passport')
491        file_ctrl = ctrl.mech_control
492        file_ctrl.add_file(image, filename='myphoto.jpg')
[8266]493        self.browser.getControl("Save").click()
494        self.browser.getControl("Add online").click()
495        self.assertMatches('...ticket created...',
496                           self.browser.contents)
[8281]497        #ctrl = self.browser.getControl(name='val_id')
498        #value = ctrl.options[0]
499        #self.browser.getLink(value).click()
[10836]500        self.payment_url = self.browser.url
501
502    def test_interswitch_form(self):
[8266]503        self.assertMatches('...Amount Authorized...',
504                           self.browser.contents)
[13111]505        self.assertTrue(
506            '<span>1000.0</span>' in self.browser.contents)
[8266]507        # Manager can access InterswitchForm
[15716]508        self.browser.getLink("Pay via Interswitch", index=0).click()
[8266]509        self.assertMatches('...Total Amount Authorized:...',
510                           self.browser.contents)
[13111]511        self.assertTrue(
512            '<input type="hidden" name="amount" value="100000" />'
513            in self.browser.contents)
[13016]514        delta = timedelta(days=8)
[12980]515        self.applicant.values()[0].creation_date -= delta
516        self.browser.open(self.payment_url)
[15716]517        self.browser.getLink("Pay via Interswitch", index=0).click()
[12980]518        self.assertMatches(
519            '...This payment ticket is too old. Please create a new ticket...',
520            self.browser.contents)
[8266]521
522    @external_test
523    def test_webservice(self):
524
525        self.browser.open(self.payment_url + '/request_webservice')
526        self.assertMatches('...Unsuccessful callback...',
527                          self.browser.contents)
528        # The payment is now in state failed
529        self.assertMatches('...<span>Failed</span>...',
530                          self.browser.contents)
Note: See TracBrowser for help on using the repository browser.