[12730] | 1 | ## $Id: tests.py 13678 2016-02-11 10:45:59Z henrik $ |
---|
[11846] | 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 | ## |
---|
| 18 | import os |
---|
| 19 | from datetime import datetime, date, timedelta |
---|
| 20 | from zope.component import createObject, getUtility |
---|
| 21 | from zope.catalog.interfaces import ICatalog |
---|
| 22 | from hurry.workflow.interfaces import IWorkflowState |
---|
| 23 | from waeup.kofa.students.tests.test_browser import StudentsFullSetup |
---|
| 24 | from waeup.kofa.applicants.tests.test_browser import ApplicantsFullSetup |
---|
| 25 | from waeup.kofa.configuration import SessionConfiguration |
---|
| 26 | from waeup.aaue.testing import FunctionalLayer |
---|
| 27 | |
---|
| 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. |
---|
[13388] | 31 | EXTERNAL_TESTS = False |
---|
[11846] | 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 | |
---|
| 44 | class InterswitchTestsApplicants(ApplicantsFullSetup): |
---|
| 45 | """Tests for the Interswitch payment gateway. |
---|
| 46 | """ |
---|
| 47 | |
---|
| 48 | layer = FunctionalLayer |
---|
| 49 | |
---|
| 50 | def setUp(self): |
---|
| 51 | super(InterswitchTestsApplicants, self).setUp() |
---|
| 52 | configuration = SessionConfiguration() |
---|
| 53 | configuration.academic_session = datetime.now().year - 2 |
---|
| 54 | self.app['configuration'].addSessionConfiguration(configuration) |
---|
| 55 | self.configuration = configuration |
---|
| 56 | self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') |
---|
| 57 | self.browser.open(self.manage_path) |
---|
| 58 | #IWorkflowState(self.student).setState('started') |
---|
| 59 | super(InterswitchTestsApplicants, self).fill_correct_values() |
---|
| 60 | self.browser.getControl(name="form.programme_type").value = ['regular'] |
---|
[13532] | 61 | self.applicantscontainer.application_fee = 10000.0 |
---|
[11846] | 62 | self.browser.getControl(name="form.nationality").value = ['NG'] |
---|
| 63 | self.browser.getControl(name="transition").value = ['start'] |
---|
| 64 | self.browser.getControl("Save").click() |
---|
[13532] | 65 | |
---|
| 66 | def test_interswitch_form_regular(self): |
---|
[11846] | 67 | self.browser.getControl("Add online").click() |
---|
[13381] | 68 | self.assertTrue('ticket created' in self.browser.contents) |
---|
[11846] | 69 | #self.browser.getLink(value).click() |
---|
[13381] | 70 | self.assertTrue('Amount Authorized' in self.browser.contents) |
---|
[13532] | 71 | self.assertTrue('<span>10000.0</span>' in self.browser.contents) |
---|
[11846] | 72 | self.payment_url = self.browser.url |
---|
| 73 | # Manager can access InterswitchForm |
---|
| 74 | self.browser.getLink("CollegePAY", index=0).click() |
---|
[13381] | 75 | self.assertTrue('Total Amount Authorized:' in self.browser.contents) |
---|
| 76 | self.assertTrue( |
---|
[13532] | 77 | '<input type="hidden" name="amount" value="1000000" />' |
---|
[13381] | 78 | in self.browser.contents) |
---|
[13532] | 79 | self.assertTrue( |
---|
| 80 | 'item_name="BT Education" item_amt="100000"' |
---|
| 81 | in self.browser.contents) |
---|
| 82 | self.assertTrue( |
---|
| 83 | 'item_name="Application Fee" item_amt="875000" bank_id="117" acct_num="1010835352"' |
---|
| 84 | in self.browser.contents) |
---|
| 85 | self.assertTrue( |
---|
| 86 | '<input type="hidden" name="product_id" value="5845" />' |
---|
| 87 | in self.browser.contents) |
---|
[13017] | 88 | delta = timedelta(days=8) |
---|
[12977] | 89 | self.applicant.values()[0].creation_date -= delta |
---|
| 90 | self.browser.open(self.payment_url) |
---|
| 91 | self.browser.getLink("CollegePAY", index=0).click() |
---|
[13381] | 92 | self.assertTrue( |
---|
| 93 | 'This payment ticket is too old. Please create a new ticket' |
---|
| 94 | in self.browser.contents) |
---|
[11846] | 95 | |
---|
| 96 | @external_test |
---|
| 97 | def test_webservice(self): |
---|
| 98 | |
---|
| 99 | self.browser.open(self.payment_url + '/request_webservice') |
---|
[13381] | 100 | self.assertTrue('Unsuccessful callback' in self.browser.contents) |
---|
[11846] | 101 | # The payment is now in state failed |
---|
[13381] | 102 | self.assertTrue('<span>Failed</span>' in self.browser.contents) |
---|
[11868] | 103 | |
---|
| 104 | class InterswitchTestsStudents(StudentsFullSetup): |
---|
| 105 | """Tests for the Interswitch payment gateway. |
---|
| 106 | """ |
---|
| 107 | |
---|
| 108 | layer = FunctionalLayer |
---|
| 109 | |
---|
| 110 | def setUp(self): |
---|
| 111 | super(InterswitchTestsStudents, self).setUp() |
---|
| 112 | |
---|
[13378] | 113 | def test_interswitch_form_pt_school_fees(self): |
---|
| 114 | self.certificate.study_mode = 'ug_pt' |
---|
[12975] | 115 | self.student['studycourse'].entry_session = 2013 |
---|
[13400] | 116 | self.student['studycourse'].certificate.school_fee_1 = 50250.0 |
---|
| 117 | self.app['configuration']['2004'].union_fee = 1000.0 |
---|
| 118 | self.app['configuration']['2004'].welfare_fee = 500.0 |
---|
[11868] | 119 | # Manager can access InterswitchForm |
---|
| 120 | self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') |
---|
| 121 | self.browser.open(self.payments_path) |
---|
| 122 | IWorkflowState(self.student).setState('cleared') |
---|
| 123 | self.student.nationality = u'NG' |
---|
| 124 | self.browser.open(self.payments_path + '/addop') |
---|
[13400] | 125 | self.browser.getControl(name="form.p_category").value = ['schoolfee_incl'] |
---|
[11868] | 126 | self.browser.getControl("Create ticket").click() |
---|
[13381] | 127 | self.assertTrue('ticket created' in self.browser.contents) |
---|
| 128 | ctrl = self.browser.getControl(name='val_id') |
---|
| 129 | self.value = ctrl.options[0] |
---|
| 130 | self.browser.getLink(self.value).click() |
---|
| 131 | self.assertTrue('Amount Authorized' in self.browser.contents) |
---|
[13438] | 132 | # 50250 + 1000 + 500 -500 |
---|
| 133 | self.assertTrue('<span>51250.0</span>' in self.browser.contents) |
---|
[13381] | 134 | self.payment_url = self.browser.url |
---|
| 135 | self.browser.getLink("CollegePAY", index=0).click() |
---|
| 136 | self.assertTrue( |
---|
| 137 | 'Please pay acceptance fee first' in self.browser.contents) |
---|
| 138 | acc_payment = createObject('waeup.StudentOnlinePayment') |
---|
| 139 | acc_payment.p_state = 'paid' |
---|
| 140 | acc_payment.p_category = 'clearance' |
---|
| 141 | self.student['payments']['xyz'] = acc_payment |
---|
| 142 | self.browser.getLink("CollegePAY", index=0).click() |
---|
| 143 | self.assertTrue('<input type="hidden" name="pay_item_id" value="105" />' |
---|
| 144 | in self.browser.contents) |
---|
| 145 | self.assertTrue('Total Amount Authorized:' in self.browser.contents) |
---|
| 146 | self.assertEqual(self.student.current_mode, 'ug_pt') |
---|
| 147 | self.assertTrue( |
---|
[13438] | 148 | '<input type="hidden" name="amount" value="5125000" />' |
---|
[13381] | 149 | in self.browser.contents) |
---|
| 150 | self.assertTrue( |
---|
[13410] | 151 | 'item_name="School Fee Plus" ' |
---|
[13400] | 152 | 'item_amt="4600000" bank_id="7" ' |
---|
[13381] | 153 | 'acct_num="1014847058"' in self.browser.contents) |
---|
| 154 | |
---|
| 155 | def test_interswitch_form_regular_school_fees(self): |
---|
| 156 | self.certificate.study_mode = 'ug_ft' |
---|
| 157 | self.student['studycourse'].entry_session = 2013 |
---|
| 158 | self.student['studycourse'].certificate.school_fee_1 = 51750.0 |
---|
| 159 | # Manager can access InterswitchForm |
---|
| 160 | self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') |
---|
| 161 | self.browser.open(self.payments_path) |
---|
| 162 | IWorkflowState(self.student).setState('cleared') |
---|
| 163 | self.student.nationality = u'NG' |
---|
| 164 | self.browser.open(self.payments_path + '/addop') |
---|
[13421] | 165 | self.browser.getControl(name="form.p_category").value = ['schoolfee_incl'] |
---|
[13381] | 166 | self.browser.getControl("Create ticket").click() |
---|
| 167 | self.assertTrue('ticket created' in |
---|
[11868] | 168 | self.browser.contents) |
---|
| 169 | ctrl = self.browser.getControl(name='val_id') |
---|
| 170 | self.value = ctrl.options[0] |
---|
| 171 | self.browser.getLink(self.value).click() |
---|
[13381] | 172 | self.assertTrue('Amount Authorized' in |
---|
[11868] | 173 | self.browser.contents) |
---|
[13381] | 174 | self.assertTrue('<span>51750.0</span>' in self.browser.contents) |
---|
[11868] | 175 | self.payment_url = self.browser.url |
---|
| 176 | self.browser.getLink("CollegePAY", index=0).click() |
---|
[12975] | 177 | self.assertTrue( |
---|
| 178 | 'Please pay acceptance fee first' in self.browser.contents) |
---|
| 179 | acc_payment = createObject('waeup.StudentOnlinePayment') |
---|
| 180 | acc_payment.p_state = 'paid' |
---|
| 181 | acc_payment.p_category = 'clearance' |
---|
| 182 | self.student['payments']['xyz'] = acc_payment |
---|
| 183 | self.browser.getLink("CollegePAY", index=0).click() |
---|
[13652] | 184 | self.assertTrue('<input type="hidden" name="pay_item_id" value="107" />' |
---|
[13381] | 185 | in self.browser.contents) |
---|
| 186 | self.assertTrue('Total Amount Authorized:' |
---|
| 187 | in self.browser.contents) |
---|
| 188 | self.assertEqual(self.student.current_mode, 'ug_ft') |
---|
| 189 | self.assertTrue( |
---|
| 190 | '<input type="hidden" name="amount" value="5175000" />' |
---|
| 191 | in self.browser.contents) |
---|
| 192 | self.assertTrue( |
---|
[13421] | 193 | 'item_name="School Fee Plus" item_amt="4750000" bank_id="117" ' |
---|
[13381] | 194 | 'acct_num="1010827641"' in self.browser.contents) |
---|
[11868] | 195 | |
---|
[12975] | 196 | |
---|
[13378] | 197 | def test_interswitch_form_pt_acceptance_fees(self): |
---|
| 198 | self.certificate.study_mode = 'ug_pt' |
---|
[13678] | 199 | self.app['configuration']['2004'].clearance_fee_ug_pt = 40250.0 |
---|
[13400] | 200 | self.app['configuration']['2004'].matric_gown_fee = 2000.0 |
---|
| 201 | self.app['configuration']['2004'].lapel_fee = 800.0 |
---|
[12729] | 202 | # Manager can access InterswitchForm |
---|
| 203 | self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') |
---|
| 204 | self.browser.open(self.payments_path) |
---|
| 205 | IWorkflowState(self.student).setState('admitted') |
---|
| 206 | self.student.nationality = u'NG' |
---|
| 207 | self.browser.open(self.payments_path + '/addop') |
---|
[13400] | 208 | self.browser.getControl(name="form.p_category").value = ['clearance_incl'] |
---|
[12729] | 209 | self.browser.getControl("Create ticket").click() |
---|
[13381] | 210 | self.assertTrue('ticket created' in self.browser.contents) |
---|
[12729] | 211 | ctrl = self.browser.getControl(name='val_id') |
---|
| 212 | self.value = ctrl.options[0] |
---|
| 213 | self.browser.getLink(self.value).click() |
---|
[13381] | 214 | self.assertTrue('Amount Authorized' in self.browser.contents) |
---|
[13438] | 215 | # 40250 + 2000 + 800 - 500 |
---|
| 216 | self.assertTrue('<span>42550.0</span>' in self.browser.contents) |
---|
[12729] | 217 | self.payment_url = self.browser.url |
---|
| 218 | self.browser.getLink("CollegePAY", index=0).click() |
---|
[13381] | 219 | self.assertTrue('<input type="hidden" name="pay_item_id" value="104" />' in |
---|
[12729] | 220 | self.browser.contents) |
---|
[13381] | 221 | self.assertTrue('Total Amount Authorized:' in self.browser.contents) |
---|
| 222 | self.assertTrue( |
---|
[13438] | 223 | '<input type="hidden" name="amount" value="4255000" />' |
---|
[13381] | 224 | in self.browser.contents) |
---|
| 225 | self.assertTrue( |
---|
[13410] | 226 | 'item_name="Acceptance Fee Plus" ' |
---|
[13400] | 227 | 'item_amt="4000000" bank_id="117" ' |
---|
[13381] | 228 | 'acct_num="1014066976"' in self.browser.contents) |
---|
[12729] | 229 | |
---|
[13381] | 230 | def test_interswitch_form_regular_acceptance_fees(self): |
---|
| 231 | self.certificate.study_mode = 'ug_ft' |
---|
| 232 | self.app['configuration']['2004'].clearance_fee = 43050.0 |
---|
| 233 | # Manager can access InterswitchForm |
---|
| 234 | self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') |
---|
| 235 | self.browser.open(self.payments_path) |
---|
| 236 | IWorkflowState(self.student).setState('admitted') |
---|
| 237 | self.student.nationality = u'NG' |
---|
| 238 | self.browser.open(self.payments_path + '/addop') |
---|
[13421] | 239 | self.browser.getControl(name="form.p_category").value = ['clearance_incl'] |
---|
[13381] | 240 | self.browser.getControl("Create ticket").click() |
---|
| 241 | self.assertTrue('ticket created' in self.browser.contents) |
---|
| 242 | ctrl = self.browser.getControl(name='val_id') |
---|
| 243 | self.value = ctrl.options[0] |
---|
| 244 | self.browser.getLink(self.value).click() |
---|
| 245 | self.assertTrue('Amount Authorized' in self.browser.contents) |
---|
| 246 | self.assertTrue('<span>43050.0</span>' in self.browser.contents) |
---|
| 247 | self.payment_url = self.browser.url |
---|
| 248 | self.browser.getLink("CollegePAY", index=0).click() |
---|
| 249 | self.assertTrue('<input type="hidden" name="pay_item_id" value="102" />' |
---|
| 250 | in self.browser.contents) |
---|
| 251 | self.assertTrue('Total Amount Authorized:' in self.browser.contents) |
---|
| 252 | self.assertTrue( |
---|
| 253 | '<input type="hidden" name="amount" value="4305000" />' |
---|
| 254 | in self.browser.contents) |
---|
| 255 | self.assertTrue( |
---|
[13421] | 256 | 'item_name="Acceptance Fee Plus" item_amt="4280000" bank_id="117" ' |
---|
[13381] | 257 | 'acct_num="1010827641"' in self.browser.contents) |
---|
| 258 | |
---|
[13464] | 259 | def test_interswitch_form_concessional_fees(self): |
---|
[13381] | 260 | self.certificate.study_mode = 'ug_pt' |
---|
[13464] | 261 | self.app['configuration']['2004'].concessional_fee = 1567.0 |
---|
[13381] | 262 | # Manager can access InterswitchForm |
---|
| 263 | self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') |
---|
| 264 | self.browser.open(self.payments_path) |
---|
| 265 | IWorkflowState(self.student).setState('admitted') |
---|
| 266 | self.student.nationality = u'NG' |
---|
| 267 | self.browser.open(self.payments_path + '/addop') |
---|
[13421] | 268 | self.browser.getControl(name="form.p_category").value = ['concessional'] |
---|
[13381] | 269 | self.browser.getControl("Create ticket").click() |
---|
| 270 | self.assertTrue('ticket created' in self.browser.contents) |
---|
| 271 | ctrl = self.browser.getControl(name='val_id') |
---|
| 272 | self.value = ctrl.options[0] |
---|
| 273 | self.browser.getLink(self.value).click() |
---|
| 274 | self.assertTrue('Amount Authorized' in self.browser.contents) |
---|
| 275 | self.assertTrue( |
---|
| 276 | '<span>1567.0</span>' in self.browser.contents) |
---|
| 277 | self.payment_url = self.browser.url |
---|
| 278 | self.certificate.study_mode = 'ug_ft' |
---|
| 279 | self.browser.getLink("CollegePAY", index=0).click() |
---|
[13421] | 280 | self.assertTrue('<input type="hidden" name="pay_item_id" value="107" />' |
---|
[13381] | 281 | in self.browser.contents) |
---|
| 282 | self.assertTrue('Total Amount Authorized:' in self.browser.contents) |
---|
| 283 | self.assertTrue( |
---|
| 284 | '<input type="hidden" name="amount" value="156700" />' |
---|
| 285 | in self.browser.contents) |
---|
| 286 | self.assertTrue( |
---|
[13438] | 287 | 'item_name="Concessional Fee" item_amt="131700" ' |
---|
[13421] | 288 | 'bank_id="117" acct_num="1010835352"' |
---|
[13381] | 289 | in self.browser.contents) |
---|
| 290 | |
---|
[12977] | 291 | def test_interswitch_form_ticket_expired(self): |
---|
[13379] | 292 | self.certificate.study_mode = 'ug_pt' |
---|
[12977] | 293 | self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') |
---|
| 294 | acc_payment = createObject('waeup.StudentOnlinePayment') |
---|
| 295 | acc_payment.p_state = 'unpaid' |
---|
[13408] | 296 | acc_payment.p_session = 2004 |
---|
[12977] | 297 | acc_payment.p_category = 'clearance' |
---|
| 298 | acc_payment.p_id = 'xyz' |
---|
| 299 | acc_payment.pay_item_id = '123' |
---|
| 300 | acc_payment.amount_auth = 876.0 |
---|
| 301 | self.student['payments']['xyz'] = acc_payment |
---|
| 302 | self.browser.open(self.payments_path + '/xyz') |
---|
| 303 | self.browser.getLink("CollegePAY", index=0).click() |
---|
[13381] | 304 | self.assertTrue('<input type="hidden" name="pay_item_id" value="104" />' |
---|
| 305 | in self.browser.contents) |
---|
| 306 | self.assertTrue('Total Amount Authorized:' in self.browser.contents) |
---|
[13379] | 307 | self.assertEqual(self.student.current_mode, 'ug_pt') |
---|
[13381] | 308 | self.assertTrue( |
---|
| 309 | '<input type="hidden" name="amount" value="87600" />' |
---|
| 310 | in self.browser.contents) |
---|
[13017] | 311 | delta = timedelta(days=8) |
---|
[12977] | 312 | acc_payment.creation_date -= delta |
---|
| 313 | self.browser.open(self.payments_path + '/xyz') |
---|
| 314 | self.browser.getLink("CollegePAY", index=0).click() |
---|
[13381] | 315 | self.assertTrue( |
---|
| 316 | 'This payment ticket is too old. Please create a new ticket' |
---|
| 317 | in self.browser.contents) |
---|
[13017] | 318 | delta = timedelta(days=2) |
---|
[12977] | 319 | acc_payment.creation_date += delta |
---|
| 320 | self.browser.open(self.payments_path + '/xyz') |
---|
| 321 | self.browser.getLink("CollegePAY", index=0).click() |
---|
[13381] | 322 | self.assertTrue('Total Amount Authorized:' in self.browser.contents) |
---|
[12977] | 323 | |
---|
[11868] | 324 | @external_test |
---|
| 325 | def test_webservice(self): |
---|
| 326 | self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') |
---|
| 327 | self.browser.open(self.payments_path) |
---|
| 328 | IWorkflowState(self.student).setState('cleared') |
---|
| 329 | self.student.nationality = u'NG' |
---|
| 330 | self.browser.open(self.payments_path + '/addop') |
---|
[13421] | 331 | self.browser.getControl(name="form.p_category").value = ['schoolfee_incl'] |
---|
[11868] | 332 | self.browser.getControl("Create ticket").click() |
---|
[13381] | 333 | self.assertTrue('ticket created' in self.browser.contents) |
---|
[11868] | 334 | ctrl = self.browser.getControl(name='val_id') |
---|
| 335 | self.value = ctrl.options[0] |
---|
| 336 | self.browser.getLink(self.value).click() |
---|
| 337 | self.payment_url = self.browser.url |
---|
[13388] | 338 | # First we have to open InterswitchPageStudent to set provider_amt |
---|
[11868] | 339 | # and gateway_amt |
---|
| 340 | self.browser.open(self.payment_url + '/goto_interswitch') |
---|
| 341 | # Now we can call the webservice |
---|
| 342 | self.browser.open(self.payment_url + '/request_webservice') |
---|
[13381] | 343 | self.assertTrue('Unsuccessful callback' in self.browser.contents) |
---|
[11868] | 344 | # The payment is now in state failed ... |
---|
[13381] | 345 | self.assertTrue('<span>Failed</span>' in self.browser.contents) |
---|
[11868] | 346 | # ... and the catalog has been updated |
---|
| 347 | cat = getUtility(ICatalog, name='payments_catalog') |
---|
| 348 | results = list( |
---|
| 349 | cat.searchResults(p_state=('failed', 'failed'))) |
---|
| 350 | self.assertEqual(len(results), 1) |
---|
| 351 | self.assertEqual(results[0].p_state, 'failed') |
---|
| 352 | |
---|
[13385] | 353 | # Let's replace the p_id with a valid p_id of the AAUE |
---|
[11868] | 354 | # live system. This is definitely not an appropriate |
---|
| 355 | # solution for testing, but we have no choice since |
---|
| 356 | # Interswitch doesn't provide any interface |
---|
| 357 | # for testing. |
---|
| 358 | payment = self.student['payments'][self.value] |
---|
[13385] | 359 | payment.p_id = 'p4465649308559' |
---|
[11868] | 360 | self.browser.open(self.payment_url + '/request_webservice') |
---|
[13388] | 361 | self.assertTrue('Unsuccessful callback: Amount Inconsistency' in |
---|
[11868] | 362 | self.browser.contents) |
---|
| 363 | # The payment is now in state failed ... |
---|
[13381] | 364 | self.assertTrue('<span>Failed</span>' in self.browser.contents) |
---|
[11868] | 365 | # Let's replace the amount autorized with the amount of the |
---|
| 366 | # live system payment |
---|
[13388] | 367 | payment.amount_auth = 60250.0 |
---|
[11868] | 368 | self.browser.open(self.payment_url + '/request_webservice') |
---|
[13381] | 369 | self.assertTrue('Successful payment' in |
---|
[11868] | 370 | self.browser.contents) |
---|
| 371 | # The payment is now in state paid ... |
---|
[13381] | 372 | self.assertTrue('<span>Paid</span>' in self.browser.contents) |
---|
[11868] | 373 | # ... and the catalog has been updated |
---|
| 374 | cat = getUtility(ICatalog, name='payments_catalog') |
---|
| 375 | results = list( |
---|
| 376 | cat.searchResults(p_state=('paid', 'paid'))) |
---|
| 377 | self.assertEqual(len(results), 1) |
---|
| 378 | self.assertEqual(results[0].p_state, 'paid') |
---|
| 379 | # Approval is logged in students.log ... |
---|
| 380 | logfile = os.path.join( |
---|
| 381 | self.app['datacenter'].storage, 'logs', 'students.log') |
---|
| 382 | logcontent = open(logfile).read() |
---|
| 383 | self.assertTrue( |
---|
| 384 | 'zope.mgr - ' |
---|
| 385 | 'waeup.aaue.interswitch.browser.CustomInterswitchPaymentRequestWebservicePageStudent - ' |
---|
[13530] | 386 | 'E1000000 - successful schoolfee_incl payment: p4465649308559\n' |
---|
[11868] | 387 | in logcontent) |
---|
| 388 | # ... and in payments.log |
---|
| 389 | logfile = os.path.join( |
---|
| 390 | self.app['datacenter'].storage, 'logs', 'payments.log') |
---|
| 391 | logcontent = open(logfile).read() |
---|
| 392 | self.assertTrue( |
---|
[13530] | 393 | '"zope.mgr",E1000000,p4465649308559,schoolfee_incl,' |
---|
[13385] | 394 | '60250.0,00,1500.0,250.0,0.0,,,\n' |
---|
[11868] | 395 | in logcontent) |
---|