[7894] | 1 | ## $Id: tests.py 10902 2014-01-13 11:06:33Z 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] | 18 | import os |
---|
[10836] | 19 | from datetime import datetime |
---|
[9713] | 20 | from zope.component import createObject, getUtility |
---|
| 21 | from zope.catalog.interfaces import ICatalog |
---|
[7894] | 22 | from hurry.workflow.interfaces import IWorkflowState |
---|
| 23 | from waeup.kofa.students.tests.test_browser import StudentsFullSetup |
---|
[8266] | 24 | from waeup.kofa.applicants.tests.test_browser import ApplicantsFullSetup |
---|
| 25 | from waeup.kofa.configuration import SessionConfiguration |
---|
[8020] | 26 | from 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] | 31 | EXTERNAL_TESTS = False |
---|
[7970] | 32 | |
---|
| 33 | def external_test(func): |
---|
| 34 | if not EXTERNAL_TESTS: |
---|
| 35 | myself = __file__ |
---|
| 36 | if myself.endswith('.pyc'): |
---|
| 37 | myself = myself[:-2] |
---|
| 38 | print "WARNING: external tests are skipped!" |
---|
| 39 | print "WARNING: edit %s to enable them." % myself |
---|
| 40 | return |
---|
| 41 | return func |
---|
| 42 | |
---|
| 43 | |
---|
[8266] | 44 | class InterswitchTestsStudents(StudentsFullSetup): |
---|
[7929] | 45 | """Tests for the Interswitch payment gateway. |
---|
[7894] | 46 | """ |
---|
| 47 | |
---|
| 48 | layer = FunctionalLayer |
---|
| 49 | |
---|
[7970] | 50 | def setUp(self): |
---|
[8266] | 51 | super(InterswitchTestsStudents, self).setUp() |
---|
[7970] | 52 | self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') |
---|
[7995] | 53 | self.browser.open(self.payments_path) |
---|
[7970] | 54 | IWorkflowState(self.student).setState('cleared') |
---|
[9006] | 55 | self.student.nationality = u'NG' |
---|
[7995] | 56 | self.browser.open(self.payments_path + '/addop') |
---|
[9384] | 57 | self.browser.getControl(name="form.p_category").value = ['schoolfee'] |
---|
[7970] | 58 | self.browser.getControl("Create ticket").click() |
---|
[9435] | 59 | self.assertMatches('...ticket created...', |
---|
| 60 | self.browser.contents) |
---|
| 61 | ctrl = self.browser.getControl(name='val_id') |
---|
[9775] | 62 | self.value = ctrl.options[0] |
---|
| 63 | self.browser.getLink(self.value).click() |
---|
[9435] | 64 | self.assertMatches('...Amount Authorized...', |
---|
| 65 | self.browser.contents) |
---|
| 66 | self.assertMatches( |
---|
| 67 | '...<span>40000.0</span>...', |
---|
| 68 | self.browser.contents) |
---|
| 69 | self.payment_url = self.browser.url |
---|
[7970] | 70 | |
---|
[8263] | 71 | # def callback_url(self, payment_url, resp, apprAmt): |
---|
| 72 | # return payment_url + ( |
---|
| 73 | # '/isw_callback?echo=' + |
---|
| 74 | # '&resp=%s' + |
---|
| 75 | # '&desc=Something went wrong' + |
---|
| 76 | # '&txnRef=p1331792385335' + |
---|
| 77 | # '&payRef=' + '&retRef=' + |
---|
| 78 | # '&cardNum=0' + |
---|
| 79 | # '&apprAmt=%s' + |
---|
| 80 | # '&url=http://xyz') % (resp, apprAmt) |
---|
[7894] | 81 | |
---|
[7970] | 82 | def test_interswitch_form(self): |
---|
[7894] | 83 | # Manager can access InterswitchForm |
---|
| 84 | self.browser.getLink("CollegePAY", index=0).click() |
---|
[8266] | 85 | # The total amount to be processed by Interswitch |
---|
| 86 | # has been reduced by the Interswitch fee of 150 Nairas |
---|
[9389] | 87 | self.assertMatches('...<input type="hidden" name="pay_item_id" value="5700" />...', |
---|
| 88 | self.browser.contents) |
---|
[9384] | 89 | self.assertMatches('...Total Amount Authorized:...', |
---|
| 90 | self.browser.contents) |
---|
[9460] | 91 | self.assertEqual(self.student.current_mode, 'ug_ft') |
---|
[7894] | 92 | self.assertMatches( |
---|
[8276] | 93 | '...<input type="hidden" name="amount" value="4000000.0" />...', |
---|
[7894] | 94 | self.browser.contents) |
---|
[9384] | 95 | self.assertMatches( |
---|
[9460] | 96 | '...item_name="School Fee" item_amt="3835000" bank_id="8" acct_num="2017506430"...', |
---|
[9384] | 97 | self.browser.contents) |
---|
| 98 | self.assertMatches( |
---|
| 99 | '...item_name="BT Education" item_amt="150000" bank_id="117" acct_num="1010764827"...', |
---|
| 100 | self.browser.contents) |
---|
[7894] | 101 | |
---|
[9520] | 102 | # Create school fee ticket for returning students. Payment is made |
---|
| 103 | # for next session. |
---|
| 104 | current_payment_key = self.student['payments'].keys()[0] |
---|
[9389] | 105 | self.certificate.study_mode = u'ug_pt' |
---|
| 106 | IWorkflowState(self.student).setState('returning') |
---|
| 107 | configuration = createObject('waeup.SessionConfiguration') |
---|
| 108 | configuration.academic_session = 2005 |
---|
| 109 | self.app['configuration'].addSessionConfiguration(configuration) |
---|
[9384] | 110 | self.browser.open(self.payments_path + '/addop') |
---|
[9389] | 111 | self.browser.getControl(name="form.p_category").value = ['schoolfee'] |
---|
[9384] | 112 | self.browser.getControl("Create ticket").click() |
---|
[9570] | 113 | |
---|
| 114 | ## Next session payment can't be made ... |
---|
| 115 | #self.assertMatches( |
---|
| 116 | # '...You have not yet paid your current/active session...', |
---|
| 117 | # self.browser.contents) |
---|
| 118 | ## current session payment must be approved first. |
---|
| 119 | #self.student['payments'][current_payment_key].approve() |
---|
| 120 | #self.browser.open(self.payments_path + '/addop') |
---|
| 121 | #self.browser.getControl(name="form.p_category").value = ['schoolfee'] |
---|
| 122 | #self.browser.getControl("Create ticket").click() |
---|
| 123 | |
---|
[9384] | 124 | ctrl = self.browser.getControl(name='val_id') |
---|
| 125 | value = ctrl.options[1] |
---|
[9775] | 126 | self.assertEqual(self.student['payments'][value].provider_amt, 0.0) |
---|
| 127 | self.assertEqual(self.student['payments'][value].gateway_amt, 0.0) |
---|
[9384] | 128 | self.browser.getLink(value).click() |
---|
[9389] | 129 | self.browser.getLink("CollegePAY", index=0).click() |
---|
[9775] | 130 | # Split amounts have been set. |
---|
| 131 | self.assertEqual(self.student['payments'][value].provider_amt, 1500.0) |
---|
| 132 | self.assertEqual(self.student['payments'][value].gateway_amt, 150.0) |
---|
[9389] | 133 | self.assertMatches('...<input type="hidden" name="pay_item_id" value="5701" />...', |
---|
[9384] | 134 | self.browser.contents) |
---|
| 135 | self.assertMatches( |
---|
[9389] | 136 | '...<input type="hidden" name="amount" value="2000000.0" />...', |
---|
| 137 | self.browser.contents) |
---|
| 138 | self.assertMatches( |
---|
[9460] | 139 | '...item_name="School Fee" item_amt="1835000" bank_id="16" acct_num="0122009929"...', |
---|
[9389] | 140 | self.browser.contents) |
---|
| 141 | self.assertMatches( |
---|
| 142 | '...item_name="BT Education" item_amt="150000" bank_id="117" acct_num="1010764827"...', |
---|
| 143 | self.browser.contents) |
---|
| 144 | |
---|
| 145 | # Create clearance fee ticket |
---|
[10902] | 146 | #self.browser.open(self.payments_path + '/addop') |
---|
| 147 | #self.browser.getControl(name="form.p_category").value = ['clearance'] |
---|
| 148 | #self.browser.getControl("Create ticket").click() |
---|
| 149 | #ctrl = self.browser.getControl(name='val_id') |
---|
| 150 | #value = ctrl.options[2] |
---|
| 151 | #self.browser.getLink(value).click() |
---|
| 152 | #self.assertMatches( |
---|
| 153 | # '...<span>45000.0</span>...', |
---|
| 154 | # self.browser.contents) |
---|
| 155 | ## Manager can access InterswitchForm |
---|
| 156 | #self.browser.getLink("CollegePAY", index=0).click() |
---|
| 157 | #self.assertEqual(self.student['payments'][value].provider_amt, 1500.0) |
---|
| 158 | #self.assertEqual(self.student['payments'][value].gateway_amt, 150.0) |
---|
| 159 | #self.assertMatches('...<input type="hidden" name="pay_item_id" value="5702" />...', |
---|
| 160 | # self.browser.contents) |
---|
| 161 | #self.assertMatches('...Total Amount Authorized:...', |
---|
| 162 | # self.browser.contents) |
---|
| 163 | #self.assertMatches( |
---|
| 164 | # '...<input type="hidden" name="amount" value="4500000.0" />...', |
---|
| 165 | # self.browser.contents) |
---|
| 166 | #self.assertMatches( |
---|
| 167 | # '...item_name="Acceptance Fee" item_amt="4335000" bank_id="7" acct_num="1003475516"...', |
---|
| 168 | # self.browser.contents) |
---|
| 169 | #self.assertMatches( |
---|
| 170 | # '...item_name="BT Education" item_amt="150000" bank_id="117" acct_num="1010764827"...', |
---|
| 171 | # self.browser.contents) |
---|
[9384] | 172 | |
---|
[9515] | 173 | # Create gown fee ticket |
---|
| 174 | configuration.maint_fee = 987.0 |
---|
| 175 | self.app['configuration']['2004'].gown_fee = 234.0 |
---|
| 176 | self.browser.open(self.payments_path + '/addop') |
---|
| 177 | self.browser.getControl(name="form.p_category").value = ['gown'] |
---|
| 178 | self.browser.getControl("Create ticket").click() |
---|
| 179 | ctrl = self.browser.getControl(name='val_id') |
---|
[10902] | 180 | value = ctrl.options[2] |
---|
[9515] | 181 | self.browser.getLink(value).click() |
---|
| 182 | self.assertMatches( |
---|
| 183 | '...<span>234.0</span>...', |
---|
| 184 | self.browser.contents) |
---|
| 185 | # Manager can access InterswitchForm |
---|
| 186 | self.browser.getLink("CollegePAY", index=0).click() |
---|
[9775] | 187 | self.assertEqual(self.student['payments'][value].provider_amt, 0.0) |
---|
| 188 | self.assertEqual(self.student['payments'][value].gateway_amt, 150.0) |
---|
[9515] | 189 | self.assertMatches('...<input type="hidden" name="pay_item_id" value="5704" />...', |
---|
| 190 | self.browser.contents) |
---|
| 191 | self.assertMatches('...Total Amount Authorized:...', |
---|
| 192 | self.browser.contents) |
---|
| 193 | self.assertMatches( |
---|
| 194 | '...<input type="hidden" name="amount" value="23400.0" />...', |
---|
| 195 | self.browser.contents) |
---|
| 196 | self.assertMatches( |
---|
| 197 | '...<item_detail item_id="1" item_name="Gown Hire Fee" item_amt="8400" bank_id="7" acct_num="1016232382" />...', |
---|
| 198 | self.browser.contents) |
---|
| 199 | self.assertFalse( |
---|
| 200 | 'item_name="BT Education"' in self.browser.contents) |
---|
[9384] | 201 | |
---|
[9727] | 202 | # Create temp maint fee ticket |
---|
| 203 | self.browser.open(self.payments_path + '/addop') |
---|
| 204 | self.browser.getControl(name="form.p_category").value = ['tempmaint_1'] |
---|
| 205 | self.browser.getControl("Create ticket").click() |
---|
| 206 | ctrl = self.browser.getControl(name='val_id') |
---|
[10902] | 207 | value = ctrl.options[3] |
---|
[9727] | 208 | self.browser.getLink(value).click() |
---|
| 209 | self.assertMatches( |
---|
[9728] | 210 | '...<span>8150.0</span>...', |
---|
[9727] | 211 | self.browser.contents) |
---|
| 212 | # Manager can access InterswitchForm |
---|
| 213 | self.browser.getLink("CollegePAY", index=0).click() |
---|
[9775] | 214 | self.assertEqual(self.student['payments'][value].provider_amt, 0.0) |
---|
| 215 | self.assertEqual(self.student['payments'][value].gateway_amt, 150.0) |
---|
[9727] | 216 | self.assertMatches('...<input type="hidden" name="pay_item_id" value="5705" />...', |
---|
| 217 | self.browser.contents) |
---|
| 218 | self.assertMatches('...Total Amount Authorized:...', |
---|
| 219 | self.browser.contents) |
---|
| 220 | self.assertMatches( |
---|
[9728] | 221 | '...<input type="hidden" name="amount" value="815000.0" />...', |
---|
[9727] | 222 | self.browser.contents) |
---|
| 223 | self.assertMatches( |
---|
[9731] | 224 | '...<item_detail item_id="1" item_name="Hostel Maintenance Fee" item_amt="800000" bank_id="129" acct_num="0014414547" />...', |
---|
[9727] | 225 | self.browser.contents) |
---|
[9728] | 226 | self.assertFalse( |
---|
| 227 | 'item_name="BT Education"' in self.browser.contents) |
---|
[9727] | 228 | |
---|
[9863] | 229 | # Create previous session fee ticket |
---|
| 230 | configuration = createObject('waeup.SessionConfiguration') |
---|
| 231 | configuration.academic_session = 2003 |
---|
| 232 | configuration.clearance_fee = 3456.0 |
---|
| 233 | self.app['configuration'].addSessionConfiguration(configuration) |
---|
| 234 | self.student['studycourse'].entry_session = 2002 |
---|
[10902] | 235 | #self.browser.open(self.payments_path + '/addpp') |
---|
| 236 | #self.browser.getControl(name="form.p_category").value = ['clearance'] |
---|
| 237 | #self.browser.getControl(name="form.p_session").value = ['2003'] |
---|
| 238 | #self.browser.getControl(name="form.p_level").value = ['300'] |
---|
| 239 | #self.browser.getControl("Create ticket").click() |
---|
| 240 | #ctrl = self.browser.getControl(name='val_id') |
---|
| 241 | #value = ctrl.options[5] |
---|
| 242 | #self.browser.getLink(value).click() |
---|
| 243 | #self.assertMatches( |
---|
| 244 | # '...<span>45000.0</span>...', |
---|
| 245 | # self.browser.contents) |
---|
| 246 | ## Manager can access InterswitchForm |
---|
| 247 | #self.browser.getLink("CollegePAY", index=0).click() |
---|
| 248 | #self.assertEqual(self.student['payments'][value].provider_amt, 1500.0) |
---|
| 249 | #self.assertEqual(self.student['payments'][value].gateway_amt, 150.0) |
---|
| 250 | #self.assertMatches('...<input type="hidden" name="pay_item_id" value="5702" />...', |
---|
| 251 | # self.browser.contents) |
---|
| 252 | #self.assertMatches('...Total Amount Authorized:...', |
---|
| 253 | # self.browser.contents) |
---|
| 254 | ##self.assertMatches( |
---|
| 255 | # '...<input type="hidden" name="amount" value="4500000.0" />...', |
---|
| 256 | # self.browser.contents) |
---|
| 257 | #self.assertMatches( |
---|
| 258 | # '...<item_detail item_id="1" item_name="Acceptance Fee" item_amt="4335000" bank_id="7" acct_num="1003475516" />...', |
---|
| 259 | # self.browser.contents) |
---|
[9863] | 260 | |
---|
[9869] | 261 | # Create balance payment ticket |
---|
| 262 | self.browser.open(self.payments_path + '/addbp') |
---|
| 263 | self.browser.getControl(name="form.p_category").value = ['schoolfee'] |
---|
| 264 | self.browser.getControl(name="form.balance_session").value = ['2003'] |
---|
| 265 | self.browser.getControl(name="form.balance_level").value = ['300'] |
---|
| 266 | self.browser.getControl(name="form.balance_amount").value = '200' |
---|
| 267 | self.browser.getControl("Create ticket").click() |
---|
| 268 | ctrl = self.browser.getControl(name='val_id') |
---|
[10902] | 269 | value = ctrl.options[4] |
---|
[9869] | 270 | self.browser.getLink(value).click() |
---|
| 271 | self.assertMatches( |
---|
| 272 | '...<span>200.0</span>...', |
---|
| 273 | self.browser.contents) |
---|
| 274 | # Manager can access InterswitchForm |
---|
| 275 | self.browser.getLink("CollegePAY", index=0).click() |
---|
| 276 | self.assertEqual(self.student['payments'][value].provider_amt, 0.0) |
---|
| 277 | self.assertEqual(self.student['payments'][value].gateway_amt, 150.0) |
---|
| 278 | self.assertMatches('...<input type="hidden" name="pay_item_id" value="5701" />...', |
---|
| 279 | self.browser.contents) |
---|
| 280 | self.assertMatches( |
---|
| 281 | '...<input type="hidden" name="amount" value="20000.0" />...', |
---|
| 282 | self.browser.contents) |
---|
| 283 | self.assertMatches( |
---|
| 284 | '...item_name="School Fee" item_amt="5000" bank_id="16" acct_num="0122009929"...', |
---|
| 285 | self.browser.contents) |
---|
| 286 | self.assertFalse( |
---|
| 287 | 'item_name="BT Education"' in self.browser.contents) |
---|
[9863] | 288 | |
---|
[8263] | 289 | # @external_test |
---|
| 290 | # def test_callback(self): |
---|
[7970] | 291 | |
---|
[7894] | 292 | # Manager can call callback manually |
---|
[8263] | 293 | # self.browser.open(self.callback_url(self.payment_url, 'XX', '300')) |
---|
| 294 | # self.assertMatches('...Unsuccessful callback: Something went wrong...', |
---|
| 295 | # self.browser.contents) |
---|
| 296 | # self.assertMatches('...Failed...', |
---|
| 297 | # self.browser.contents) |
---|
| 298 | # self.browser.open(self.payment_url + '/isw_callback') |
---|
| 299 | # self.assertMatches('...Unsuccessful callback: Incomplete query string...', |
---|
| 300 | # self.browser.contents) |
---|
| 301 | # self.assertMatches('...Failed...', |
---|
| 302 | # self.browser.contents) |
---|
| 303 | # self.browser.open(self.callback_url(self.payment_url, '00', '300000')) |
---|
| 304 | # self.assertMatches('...Wrong amount...', |
---|
| 305 | # self.browser.contents) |
---|
| 306 | # self.browser.open(self.callback_url(self.payment_url, '00', '4000000')) |
---|
| 307 | # self.assertMatches('...Valid callback received...', |
---|
| 308 | # self.browser.contents) |
---|
[7930] | 309 | |
---|
[7970] | 310 | @external_test |
---|
[7930] | 311 | def test_webservice(self): |
---|
[9775] | 312 | # First we have open InterswitchPageStudent to set provider_amt |
---|
| 313 | # and gateway_amt |
---|
| 314 | self.browser.open(self.payment_url + '/goto_interswitch') |
---|
| 315 | # Now we can call the webservice |
---|
[7970] | 316 | self.browser.open(self.payment_url + '/request_webservice') |
---|
[7930] | 317 | self.assertMatches('...Unsuccessful callback...', |
---|
| 318 | self.browser.contents) |
---|
[9713] | 319 | # The payment is now in state failed ... |
---|
[8266] | 320 | self.assertMatches('...<span>Failed</span>...', |
---|
| 321 | self.browser.contents) |
---|
[9713] | 322 | # ... and the catalog has been updated |
---|
| 323 | cat = getUtility(ICatalog, name='payments_catalog') |
---|
| 324 | results = list( |
---|
| 325 | cat.searchResults(p_state=('failed', 'failed'))) |
---|
| 326 | self.assertEqual(len(results), 1) |
---|
| 327 | self.assertEqual(results[0].p_state, 'failed') |
---|
[8266] | 328 | |
---|
[9775] | 329 | # Let's replace the p_id with a valid p_id of the Uniben |
---|
| 330 | # live system. This is definitely not an appropriate |
---|
| 331 | # solution for testing, but we have no choice since |
---|
| 332 | # Interswitch doesn't provide any interface |
---|
| 333 | # for testing. |
---|
| 334 | payment = self.student['payments'][self.value] |
---|
| 335 | payment.p_id = 'p3547789850240' |
---|
| 336 | self.browser.open(self.payment_url + '/request_webservice') |
---|
| 337 | self.assertMatches('...Callback amount does not match...', |
---|
| 338 | self.browser.contents) |
---|
| 339 | # The payment is now in state failed ... |
---|
| 340 | self.assertMatches('...<span>Failed</span>...', |
---|
| 341 | self.browser.contents) |
---|
| 342 | # Let's replace the amount autorized with the amount of the |
---|
| 343 | # live system payment |
---|
| 344 | payment.amount_auth = payment.r_amount_approved |
---|
| 345 | self.browser.open(self.payment_url + '/request_webservice') |
---|
| 346 | self.assertMatches('...Successful payment...', |
---|
| 347 | self.browser.contents) |
---|
| 348 | # The payment is now in state paid ... |
---|
| 349 | self.assertMatches('...<span>Paid</span>...', |
---|
| 350 | self.browser.contents) |
---|
| 351 | # ... and the catalog has been updated |
---|
| 352 | cat = getUtility(ICatalog, name='payments_catalog') |
---|
| 353 | results = list( |
---|
| 354 | cat.searchResults(p_state=('paid', 'paid'))) |
---|
| 355 | self.assertEqual(len(results), 1) |
---|
| 356 | self.assertEqual(results[0].p_state, 'paid') |
---|
| 357 | # Approval is logged in students.log ... |
---|
| 358 | logfile = os.path.join( |
---|
| 359 | self.app['datacenter'].storage, 'logs', 'students.log') |
---|
| 360 | logcontent = open(logfile).read() |
---|
| 361 | self.assertTrue( |
---|
| 362 | 'zope.mgr - ' |
---|
| 363 | 'waeup.uniben.interswitch.browser.InterswitchPaymentRequestWebservicePageStudent - ' |
---|
| 364 | 'B1000000 - successful schoolfee payment: p3547789850240\n' |
---|
| 365 | in logcontent) |
---|
| 366 | # ... and in payments.log |
---|
| 367 | logfile = os.path.join( |
---|
| 368 | self.app['datacenter'].storage, 'logs', 'payments.log') |
---|
| 369 | logcontent = open(logfile).read() |
---|
| 370 | self.assertTrue( |
---|
| 371 | '"zope.mgr",B1000000,p3547789850240,schoolfee,' |
---|
| 372 | '12000.0,00,1500.0,150.0,0.0,,,\n' |
---|
| 373 | in logcontent) |
---|
| 374 | |
---|
| 375 | |
---|
[8266] | 376 | class InterswitchTestsApplicants(ApplicantsFullSetup): |
---|
| 377 | """Tests for the Interswitch payment gateway. |
---|
| 378 | """ |
---|
| 379 | |
---|
| 380 | layer = FunctionalLayer |
---|
| 381 | |
---|
| 382 | def setUp(self): |
---|
| 383 | super(InterswitchTestsApplicants, self).setUp() |
---|
[10836] | 384 | configuration = SessionConfiguration() |
---|
| 385 | configuration.academic_session = datetime.now().year - 2 |
---|
| 386 | self.app['configuration'].addSessionConfiguration(configuration) |
---|
[8266] | 387 | self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') |
---|
| 388 | self.browser.open(self.manage_path) |
---|
| 389 | #IWorkflowState(self.student).setState('started') |
---|
| 390 | super(InterswitchTestsApplicants, self).fill_correct_values() |
---|
[8526] | 391 | self.applicantscontainer.application_fee = 1000.0 |
---|
[9453] | 392 | self.browser.getControl(name="form.nationality").value = ['NG'] |
---|
[8266] | 393 | self.browser.getControl(name="transition").value = ['start'] |
---|
| 394 | self.browser.getControl("Save").click() |
---|
| 395 | self.browser.getControl("Add online").click() |
---|
| 396 | self.assertMatches('...ticket created...', |
---|
| 397 | self.browser.contents) |
---|
[8281] | 398 | #ctrl = self.browser.getControl(name='val_id') |
---|
| 399 | #value = ctrl.options[0] |
---|
| 400 | #self.browser.getLink(value).click() |
---|
[10836] | 401 | self.payment_url = self.browser.url |
---|
| 402 | |
---|
| 403 | def test_interswitch_form(self): |
---|
[8266] | 404 | self.assertMatches('...Amount Authorized...', |
---|
| 405 | self.browser.contents) |
---|
| 406 | self.assertMatches( |
---|
| 407 | '...<span>1000.0</span>...', |
---|
| 408 | self.browser.contents) |
---|
| 409 | # Manager can access InterswitchForm |
---|
| 410 | self.browser.getLink("CollegePAY", index=0).click() |
---|
| 411 | self.assertMatches('...Total Amount Authorized:...', |
---|
| 412 | self.browser.contents) |
---|
| 413 | self.assertMatches( |
---|
[8276] | 414 | '...<input type="hidden" name="amount" value="100000.0" />...', |
---|
[8266] | 415 | self.browser.contents) |
---|
| 416 | |
---|
| 417 | @external_test |
---|
| 418 | def test_webservice(self): |
---|
| 419 | |
---|
| 420 | self.browser.open(self.payment_url + '/request_webservice') |
---|
| 421 | self.assertMatches('...Unsuccessful callback...', |
---|
| 422 | self.browser.contents) |
---|
| 423 | # The payment is now in state failed |
---|
| 424 | self.assertMatches('...<span>Failed</span>...', |
---|
| 425 | self.browser.contents) |
---|