[12730] | 1 | ## $Id: tests.py 15260 2018-12-04 08:18:51Z 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() |
---|
[13977] | 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( |
---|
[15260] | 80 | 'item_name="WAeAC" item_amt="200000"' |
---|
[13532] | 81 | in self.browser.contents) |
---|
| 82 | self.assertTrue( |
---|
[15260] | 83 | 'item_name="Application Fee" item_amt="775000" bank_id="117" acct_num="1010835352"' |
---|
[13532] | 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 | |
---|
[14121] | 96 | def test_interswitch_form_pg(self): |
---|
| 97 | self.applicant.applicant_id = u'pg_anything' |
---|
| 98 | self.browser.getControl("Add online").click() |
---|
| 99 | self.assertTrue('ticket created' in self.browser.contents) |
---|
| 100 | #self.browser.getLink(value).click() |
---|
| 101 | self.assertTrue('Amount Authorized' in self.browser.contents) |
---|
| 102 | self.assertTrue('<span>10000.0</span>' in self.browser.contents) |
---|
| 103 | self.payment_url = self.browser.url |
---|
| 104 | # Manager can access InterswitchForm |
---|
| 105 | self.browser.getLink("CollegePAY", index=0).click() |
---|
| 106 | self.assertTrue('Total Amount Authorized:' in self.browser.contents) |
---|
| 107 | self.assertTrue( |
---|
| 108 | '<input type="hidden" name="amount" value="1000000" />' |
---|
| 109 | in self.browser.contents) |
---|
| 110 | self.assertTrue( |
---|
[15260] | 111 | 'item_name="WAeAC" item_amt="200000"' |
---|
[14121] | 112 | in self.browser.contents) |
---|
| 113 | self.assertTrue( |
---|
[15260] | 114 | 'item_name="Application Fee" item_amt="575000" bank_id="117" acct_num="1010835352"' |
---|
[14121] | 115 | in self.browser.contents) |
---|
| 116 | self.assertTrue( |
---|
[14945] | 117 | 'item_name="PG Handbook" item_amt="200000" bank_id="117" acct_num="1010827641"' |
---|
[14121] | 118 | in self.browser.contents) |
---|
| 119 | self.assertTrue( |
---|
| 120 | '<input type="hidden" name="product_id" value="5845" />' |
---|
| 121 | in self.browser.contents) |
---|
| 122 | delta = timedelta(days=8) |
---|
| 123 | self.applicant.values()[0].creation_date -= delta |
---|
| 124 | self.browser.open(self.payment_url) |
---|
| 125 | self.browser.getLink("CollegePAY", index=0).click() |
---|
| 126 | self.assertTrue( |
---|
| 127 | 'This payment ticket is too old. Please create a new ticket' |
---|
| 128 | in self.browser.contents) |
---|
| 129 | |
---|
[14122] | 130 | def test_interswitch_form_utme(self): |
---|
| 131 | self.applicant.applicant_id = u'utme_anything' |
---|
| 132 | self.browser.getControl("Add online").click() |
---|
| 133 | self.assertTrue('ticket created' in self.browser.contents) |
---|
| 134 | #self.browser.getLink(value).click() |
---|
| 135 | self.assertTrue('Amount Authorized' in self.browser.contents) |
---|
| 136 | self.assertTrue('<span>10000.0</span>' in self.browser.contents) |
---|
| 137 | self.payment_url = self.browser.url |
---|
| 138 | # Manager can access InterswitchForm |
---|
| 139 | self.browser.getLink("CollegePAY", index=0).click() |
---|
| 140 | self.assertTrue('Total Amount Authorized:' in self.browser.contents) |
---|
| 141 | self.assertTrue( |
---|
| 142 | '<input type="hidden" name="amount" value="1000000" />' |
---|
| 143 | in self.browser.contents) |
---|
| 144 | self.assertTrue( |
---|
[15260] | 145 | 'item_name="WAeAC" item_amt="200000"' |
---|
[14122] | 146 | in self.browser.contents) |
---|
| 147 | self.assertTrue( |
---|
[15260] | 148 | 'item_name="Application Fee" item_amt="775000" bank_id="117" acct_num="1010835352"' |
---|
[14122] | 149 | in self.browser.contents) |
---|
| 150 | self.assertTrue( |
---|
| 151 | '<input type="hidden" name="product_id" value="5845" />' |
---|
| 152 | in self.browser.contents) |
---|
| 153 | delta = timedelta(days=8) |
---|
| 154 | self.applicant.values()[0].creation_date -= delta |
---|
| 155 | self.browser.open(self.payment_url) |
---|
| 156 | self.browser.getLink("CollegePAY", index=0).click() |
---|
| 157 | self.assertTrue( |
---|
| 158 | 'This payment ticket is too old. Please create a new ticket' |
---|
| 159 | in self.browser.contents) |
---|
| 160 | |
---|
[15224] | 161 | def test_interswitch_form_bridge(self): |
---|
| 162 | self.applicant.applicant_id = u'bridge_xyz' |
---|
| 163 | self.browser.getControl("Add online").click() |
---|
| 164 | self.assertTrue('ticket created' in self.browser.contents) |
---|
| 165 | #self.browser.getLink(value).click() |
---|
| 166 | self.assertTrue('Amount Authorized' in self.browser.contents) |
---|
| 167 | self.assertTrue('<span>10000.0</span>' in self.browser.contents) |
---|
| 168 | self.payment_url = self.browser.url |
---|
| 169 | # Manager can access InterswitchForm |
---|
| 170 | self.browser.getLink("CollegePAY", index=0).click() |
---|
| 171 | self.assertTrue('Total Amount Authorized:' in self.browser.contents) |
---|
| 172 | self.assertTrue( |
---|
| 173 | '<input type="hidden" name="amount" value="1000000" />' |
---|
| 174 | in self.browser.contents) |
---|
| 175 | self.assertTrue( |
---|
| 176 | 'item_name="WAeAC" item_amt="200000"' |
---|
| 177 | in self.browser.contents) |
---|
| 178 | self.assertTrue( |
---|
| 179 | 'item_name="Application Fee" item_amt="775000" bank_id="7" acct_num="1014847058"' |
---|
| 180 | in self.browser.contents) |
---|
| 181 | |
---|
[11846] | 182 | @external_test |
---|
| 183 | def test_webservice(self): |
---|
| 184 | |
---|
| 185 | self.browser.open(self.payment_url + '/request_webservice') |
---|
[13381] | 186 | self.assertTrue('Unsuccessful callback' in self.browser.contents) |
---|
[11846] | 187 | # The payment is now in state failed |
---|
[13381] | 188 | self.assertTrue('<span>Failed</span>' in self.browser.contents) |
---|
[11868] | 189 | |
---|
| 190 | class InterswitchTestsStudents(StudentsFullSetup): |
---|
| 191 | """Tests for the Interswitch payment gateway. |
---|
| 192 | """ |
---|
| 193 | |
---|
| 194 | layer = FunctionalLayer |
---|
| 195 | |
---|
| 196 | def setUp(self): |
---|
| 197 | super(InterswitchTestsStudents, self).setUp() |
---|
| 198 | |
---|
[13378] | 199 | def test_interswitch_form_pt_school_fees(self): |
---|
| 200 | self.certificate.study_mode = 'ug_pt' |
---|
[12975] | 201 | self.student['studycourse'].entry_session = 2013 |
---|
[13400] | 202 | self.student['studycourse'].certificate.school_fee_1 = 50250.0 |
---|
| 203 | self.app['configuration']['2004'].union_fee = 1000.0 |
---|
| 204 | self.app['configuration']['2004'].welfare_fee = 500.0 |
---|
[11868] | 205 | # Manager can access InterswitchForm |
---|
| 206 | self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') |
---|
| 207 | self.browser.open(self.payments_path) |
---|
| 208 | IWorkflowState(self.student).setState('cleared') |
---|
| 209 | self.student.nationality = u'NG' |
---|
| 210 | self.browser.open(self.payments_path + '/addop') |
---|
[13400] | 211 | self.browser.getControl(name="form.p_category").value = ['schoolfee_incl'] |
---|
[11868] | 212 | self.browser.getControl("Create ticket").click() |
---|
[13381] | 213 | self.assertTrue('ticket created' in self.browser.contents) |
---|
| 214 | ctrl = self.browser.getControl(name='val_id') |
---|
| 215 | self.value = ctrl.options[0] |
---|
| 216 | self.browser.getLink(self.value).click() |
---|
| 217 | self.assertTrue('Amount Authorized' in self.browser.contents) |
---|
[13438] | 218 | # 50250 + 1000 + 500 -500 |
---|
| 219 | self.assertTrue('<span>51250.0</span>' in self.browser.contents) |
---|
[13381] | 220 | self.payment_url = self.browser.url |
---|
| 221 | self.browser.getLink("CollegePAY", index=0).click() |
---|
| 222 | self.assertTrue( |
---|
| 223 | 'Please pay acceptance fee first' in self.browser.contents) |
---|
| 224 | acc_payment = createObject('waeup.StudentOnlinePayment') |
---|
| 225 | acc_payment.p_state = 'paid' |
---|
| 226 | acc_payment.p_category = 'clearance' |
---|
| 227 | self.student['payments']['xyz'] = acc_payment |
---|
| 228 | self.browser.getLink("CollegePAY", index=0).click() |
---|
| 229 | self.assertTrue('<input type="hidden" name="pay_item_id" value="105" />' |
---|
| 230 | in self.browser.contents) |
---|
| 231 | self.assertTrue('Total Amount Authorized:' in self.browser.contents) |
---|
| 232 | self.assertEqual(self.student.current_mode, 'ug_pt') |
---|
| 233 | self.assertTrue( |
---|
[13438] | 234 | '<input type="hidden" name="amount" value="5125000" />' |
---|
[13381] | 235 | in self.browser.contents) |
---|
| 236 | self.assertTrue( |
---|
[13410] | 237 | 'item_name="School Fee Plus" ' |
---|
[14920] | 238 | 'item_amt="4600000" bank_id="117" ' |
---|
| 239 | 'acct_num="1010827641"' in self.browser.contents) |
---|
[13381] | 240 | |
---|
| 241 | def test_interswitch_form_regular_school_fees(self): |
---|
| 242 | self.certificate.study_mode = 'ug_ft' |
---|
| 243 | self.student['studycourse'].entry_session = 2013 |
---|
| 244 | self.student['studycourse'].certificate.school_fee_1 = 51750.0 |
---|
| 245 | # Manager can access InterswitchForm |
---|
| 246 | self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') |
---|
| 247 | self.browser.open(self.payments_path) |
---|
| 248 | IWorkflowState(self.student).setState('cleared') |
---|
| 249 | self.student.nationality = u'NG' |
---|
| 250 | self.browser.open(self.payments_path + '/addop') |
---|
[13421] | 251 | self.browser.getControl(name="form.p_category").value = ['schoolfee_incl'] |
---|
[13381] | 252 | self.browser.getControl("Create ticket").click() |
---|
| 253 | self.assertTrue('ticket created' in |
---|
[11868] | 254 | self.browser.contents) |
---|
| 255 | ctrl = self.browser.getControl(name='val_id') |
---|
| 256 | self.value = ctrl.options[0] |
---|
| 257 | self.browser.getLink(self.value).click() |
---|
[13381] | 258 | self.assertTrue('Amount Authorized' in |
---|
[11868] | 259 | self.browser.contents) |
---|
[13381] | 260 | self.assertTrue('<span>51750.0</span>' in self.browser.contents) |
---|
[11868] | 261 | self.payment_url = self.browser.url |
---|
| 262 | self.browser.getLink("CollegePAY", index=0).click() |
---|
[12975] | 263 | self.assertTrue( |
---|
| 264 | 'Please pay acceptance fee first' in self.browser.contents) |
---|
| 265 | acc_payment = createObject('waeup.StudentOnlinePayment') |
---|
| 266 | acc_payment.p_state = 'paid' |
---|
| 267 | acc_payment.p_category = 'clearance' |
---|
| 268 | self.student['payments']['xyz'] = acc_payment |
---|
| 269 | self.browser.getLink("CollegePAY", index=0).click() |
---|
[13652] | 270 | self.assertTrue('<input type="hidden" name="pay_item_id" value="107" />' |
---|
[13381] | 271 | in self.browser.contents) |
---|
| 272 | self.assertTrue('Total Amount Authorized:' |
---|
| 273 | in self.browser.contents) |
---|
| 274 | self.assertEqual(self.student.current_mode, 'ug_ft') |
---|
| 275 | self.assertTrue( |
---|
| 276 | '<input type="hidden" name="amount" value="5175000" />' |
---|
| 277 | in self.browser.contents) |
---|
| 278 | self.assertTrue( |
---|
[13421] | 279 | 'item_name="School Fee Plus" item_amt="4750000" bank_id="117" ' |
---|
[13381] | 280 | 'acct_num="1010827641"' in self.browser.contents) |
---|
[11868] | 281 | |
---|
[12975] | 282 | |
---|
[13378] | 283 | def test_interswitch_form_pt_acceptance_fees(self): |
---|
| 284 | self.certificate.study_mode = 'ug_pt' |
---|
[13678] | 285 | self.app['configuration']['2004'].clearance_fee_ug_pt = 40250.0 |
---|
[13400] | 286 | self.app['configuration']['2004'].matric_gown_fee = 2000.0 |
---|
| 287 | self.app['configuration']['2004'].lapel_fee = 800.0 |
---|
[12729] | 288 | # Manager can access InterswitchForm |
---|
| 289 | self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') |
---|
| 290 | self.browser.open(self.payments_path) |
---|
| 291 | IWorkflowState(self.student).setState('admitted') |
---|
| 292 | self.student.nationality = u'NG' |
---|
| 293 | self.browser.open(self.payments_path + '/addop') |
---|
[13400] | 294 | self.browser.getControl(name="form.p_category").value = ['clearance_incl'] |
---|
[12729] | 295 | self.browser.getControl("Create ticket").click() |
---|
[13381] | 296 | self.assertTrue('ticket created' in self.browser.contents) |
---|
[12729] | 297 | ctrl = self.browser.getControl(name='val_id') |
---|
| 298 | self.value = ctrl.options[0] |
---|
| 299 | self.browser.getLink(self.value).click() |
---|
[13381] | 300 | self.assertTrue('Amount Authorized' in self.browser.contents) |
---|
[13438] | 301 | # 40250 + 2000 + 800 - 500 |
---|
| 302 | self.assertTrue('<span>42550.0</span>' in self.browser.contents) |
---|
[12729] | 303 | self.payment_url = self.browser.url |
---|
| 304 | self.browser.getLink("CollegePAY", index=0).click() |
---|
[13381] | 305 | self.assertTrue('<input type="hidden" name="pay_item_id" value="104" />' in |
---|
[12729] | 306 | self.browser.contents) |
---|
[13381] | 307 | self.assertTrue('Total Amount Authorized:' in self.browser.contents) |
---|
| 308 | self.assertTrue( |
---|
[13438] | 309 | '<input type="hidden" name="amount" value="4255000" />' |
---|
[13381] | 310 | in self.browser.contents) |
---|
| 311 | self.assertTrue( |
---|
[13410] | 312 | 'item_name="Acceptance Fee Plus" ' |
---|
[15191] | 313 | 'item_amt="3850000" bank_id="117" ' |
---|
[14920] | 314 | 'acct_num="1010827641"' in self.browser.contents) |
---|
[12729] | 315 | |
---|
[13381] | 316 | def test_interswitch_form_regular_acceptance_fees(self): |
---|
| 317 | self.certificate.study_mode = 'ug_ft' |
---|
| 318 | self.app['configuration']['2004'].clearance_fee = 43050.0 |
---|
| 319 | # Manager can access InterswitchForm |
---|
| 320 | self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') |
---|
| 321 | self.browser.open(self.payments_path) |
---|
| 322 | IWorkflowState(self.student).setState('admitted') |
---|
| 323 | self.student.nationality = u'NG' |
---|
| 324 | self.browser.open(self.payments_path + '/addop') |
---|
[13421] | 325 | self.browser.getControl(name="form.p_category").value = ['clearance_incl'] |
---|
[13381] | 326 | self.browser.getControl("Create ticket").click() |
---|
| 327 | self.assertTrue('ticket created' in self.browser.contents) |
---|
| 328 | ctrl = self.browser.getControl(name='val_id') |
---|
| 329 | self.value = ctrl.options[0] |
---|
| 330 | self.browser.getLink(self.value).click() |
---|
| 331 | self.assertTrue('Amount Authorized' in self.browser.contents) |
---|
| 332 | self.assertTrue('<span>43050.0</span>' in self.browser.contents) |
---|
| 333 | self.payment_url = self.browser.url |
---|
| 334 | self.browser.getLink("CollegePAY", index=0).click() |
---|
| 335 | self.assertTrue('<input type="hidden" name="pay_item_id" value="102" />' |
---|
| 336 | in self.browser.contents) |
---|
| 337 | self.assertTrue('Total Amount Authorized:' in self.browser.contents) |
---|
| 338 | self.assertTrue( |
---|
| 339 | '<input type="hidden" name="amount" value="4305000" />' |
---|
| 340 | in self.browser.contents) |
---|
| 341 | self.assertTrue( |
---|
[15191] | 342 | 'item_name="Acceptance Fee Plus" item_amt="4130000" bank_id="117" ' |
---|
[13381] | 343 | 'acct_num="1010827641"' in self.browser.contents) |
---|
| 344 | |
---|
[13464] | 345 | def test_interswitch_form_concessional_fees(self): |
---|
[13381] | 346 | self.certificate.study_mode = 'ug_pt' |
---|
[13464] | 347 | self.app['configuration']['2004'].concessional_fee = 1567.0 |
---|
[13381] | 348 | # Manager can access InterswitchForm |
---|
| 349 | self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') |
---|
| 350 | self.browser.open(self.payments_path) |
---|
| 351 | IWorkflowState(self.student).setState('admitted') |
---|
| 352 | self.student.nationality = u'NG' |
---|
| 353 | self.browser.open(self.payments_path + '/addop') |
---|
[13421] | 354 | self.browser.getControl(name="form.p_category").value = ['concessional'] |
---|
[13381] | 355 | self.browser.getControl("Create ticket").click() |
---|
| 356 | self.assertTrue('ticket created' in self.browser.contents) |
---|
| 357 | ctrl = self.browser.getControl(name='val_id') |
---|
| 358 | self.value = ctrl.options[0] |
---|
| 359 | self.browser.getLink(self.value).click() |
---|
| 360 | self.assertTrue('Amount Authorized' in self.browser.contents) |
---|
| 361 | self.assertTrue( |
---|
| 362 | '<span>1567.0</span>' in self.browser.contents) |
---|
| 363 | self.payment_url = self.browser.url |
---|
| 364 | self.certificate.study_mode = 'ug_ft' |
---|
| 365 | self.browser.getLink("CollegePAY", index=0).click() |
---|
[13421] | 366 | self.assertTrue('<input type="hidden" name="pay_item_id" value="107" />' |
---|
[13381] | 367 | in self.browser.contents) |
---|
| 368 | self.assertTrue('Total Amount Authorized:' in self.browser.contents) |
---|
| 369 | self.assertTrue( |
---|
| 370 | '<input type="hidden" name="amount" value="156700" />' |
---|
| 371 | in self.browser.contents) |
---|
| 372 | self.assertTrue( |
---|
[13438] | 373 | 'item_name="Concessional Fee" item_amt="131700" ' |
---|
[14920] | 374 | 'bank_id="117" acct_num="1010827641"' |
---|
[13381] | 375 | in self.browser.contents) |
---|
| 376 | |
---|
[12977] | 377 | def test_interswitch_form_ticket_expired(self): |
---|
[13379] | 378 | self.certificate.study_mode = 'ug_pt' |
---|
[12977] | 379 | self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') |
---|
| 380 | acc_payment = createObject('waeup.StudentOnlinePayment') |
---|
| 381 | acc_payment.p_state = 'unpaid' |
---|
[13408] | 382 | acc_payment.p_session = 2004 |
---|
[12977] | 383 | acc_payment.p_category = 'clearance' |
---|
| 384 | acc_payment.p_id = 'xyz' |
---|
| 385 | acc_payment.pay_item_id = '123' |
---|
| 386 | acc_payment.amount_auth = 876.0 |
---|
| 387 | self.student['payments']['xyz'] = acc_payment |
---|
| 388 | self.browser.open(self.payments_path + '/xyz') |
---|
| 389 | self.browser.getLink("CollegePAY", index=0).click() |
---|
[13381] | 390 | self.assertTrue('<input type="hidden" name="pay_item_id" value="104" />' |
---|
| 391 | in self.browser.contents) |
---|
| 392 | self.assertTrue('Total Amount Authorized:' in self.browser.contents) |
---|
[13379] | 393 | self.assertEqual(self.student.current_mode, 'ug_pt') |
---|
[13381] | 394 | self.assertTrue( |
---|
| 395 | '<input type="hidden" name="amount" value="87600" />' |
---|
| 396 | in self.browser.contents) |
---|
[13017] | 397 | delta = timedelta(days=8) |
---|
[12977] | 398 | acc_payment.creation_date -= delta |
---|
| 399 | self.browser.open(self.payments_path + '/xyz') |
---|
| 400 | self.browser.getLink("CollegePAY", index=0).click() |
---|
[13381] | 401 | self.assertTrue( |
---|
| 402 | 'This payment ticket is too old. Please create a new ticket' |
---|
| 403 | in self.browser.contents) |
---|
[13017] | 404 | delta = timedelta(days=2) |
---|
[12977] | 405 | acc_payment.creation_date += delta |
---|
| 406 | self.browser.open(self.payments_path + '/xyz') |
---|
| 407 | self.browser.getLink("CollegePAY", index=0).click() |
---|
[13381] | 408 | self.assertTrue('Total Amount Authorized:' in self.browser.contents) |
---|
[12977] | 409 | |
---|
[11868] | 410 | @external_test |
---|
| 411 | def test_webservice(self): |
---|
| 412 | self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') |
---|
| 413 | self.browser.open(self.payments_path) |
---|
| 414 | IWorkflowState(self.student).setState('cleared') |
---|
| 415 | self.student.nationality = u'NG' |
---|
| 416 | self.browser.open(self.payments_path + '/addop') |
---|
[13421] | 417 | self.browser.getControl(name="form.p_category").value = ['schoolfee_incl'] |
---|
[11868] | 418 | self.browser.getControl("Create ticket").click() |
---|
[13381] | 419 | self.assertTrue('ticket created' in self.browser.contents) |
---|
[11868] | 420 | ctrl = self.browser.getControl(name='val_id') |
---|
| 421 | self.value = ctrl.options[0] |
---|
| 422 | self.browser.getLink(self.value).click() |
---|
| 423 | self.payment_url = self.browser.url |
---|
[13388] | 424 | # First we have to open InterswitchPageStudent to set provider_amt |
---|
[11868] | 425 | # and gateway_amt |
---|
| 426 | self.browser.open(self.payment_url + '/goto_interswitch') |
---|
| 427 | # Now we can call the webservice |
---|
| 428 | self.browser.open(self.payment_url + '/request_webservice') |
---|
[13381] | 429 | self.assertTrue('Unsuccessful callback' in self.browser.contents) |
---|
[11868] | 430 | # The payment is now in state failed ... |
---|
[13381] | 431 | self.assertTrue('<span>Failed</span>' in self.browser.contents) |
---|
[11868] | 432 | # ... and the catalog has been updated |
---|
| 433 | cat = getUtility(ICatalog, name='payments_catalog') |
---|
| 434 | results = list( |
---|
| 435 | cat.searchResults(p_state=('failed', 'failed'))) |
---|
| 436 | self.assertEqual(len(results), 1) |
---|
| 437 | self.assertEqual(results[0].p_state, 'failed') |
---|
| 438 | |
---|
[13385] | 439 | # Let's replace the p_id with a valid p_id of the AAUE |
---|
[11868] | 440 | # live system. This is definitely not an appropriate |
---|
| 441 | # solution for testing, but we have no choice since |
---|
| 442 | # Interswitch doesn't provide any interface |
---|
| 443 | # for testing. |
---|
| 444 | payment = self.student['payments'][self.value] |
---|
[13385] | 445 | payment.p_id = 'p4465649308559' |
---|
[11868] | 446 | self.browser.open(self.payment_url + '/request_webservice') |
---|
[13388] | 447 | self.assertTrue('Unsuccessful callback: Amount Inconsistency' in |
---|
[11868] | 448 | self.browser.contents) |
---|
| 449 | # The payment is now in state failed ... |
---|
[13381] | 450 | self.assertTrue('<span>Failed</span>' in self.browser.contents) |
---|
[11868] | 451 | # Let's replace the amount autorized with the amount of the |
---|
| 452 | # live system payment |
---|
[13388] | 453 | payment.amount_auth = 60250.0 |
---|
[11868] | 454 | self.browser.open(self.payment_url + '/request_webservice') |
---|
[13381] | 455 | self.assertTrue('Successful payment' in |
---|
[11868] | 456 | self.browser.contents) |
---|
| 457 | # The payment is now in state paid ... |
---|
[13381] | 458 | self.assertTrue('<span>Paid</span>' in self.browser.contents) |
---|
[11868] | 459 | # ... and the catalog has been updated |
---|
| 460 | cat = getUtility(ICatalog, name='payments_catalog') |
---|
| 461 | results = list( |
---|
| 462 | cat.searchResults(p_state=('paid', 'paid'))) |
---|
| 463 | self.assertEqual(len(results), 1) |
---|
| 464 | self.assertEqual(results[0].p_state, 'paid') |
---|
| 465 | # Approval is logged in students.log ... |
---|
| 466 | logfile = os.path.join( |
---|
| 467 | self.app['datacenter'].storage, 'logs', 'students.log') |
---|
| 468 | logcontent = open(logfile).read() |
---|
| 469 | self.assertTrue( |
---|
| 470 | 'zope.mgr - ' |
---|
| 471 | 'waeup.aaue.interswitch.browser.CustomInterswitchPaymentRequestWebservicePageStudent - ' |
---|
[13530] | 472 | 'E1000000 - successful schoolfee_incl payment: p4465649308559\n' |
---|
[11868] | 473 | in logcontent) |
---|
| 474 | # ... and in payments.log |
---|
| 475 | logfile = os.path.join( |
---|
| 476 | self.app['datacenter'].storage, 'logs', 'payments.log') |
---|
| 477 | logcontent = open(logfile).read() |
---|
| 478 | self.assertTrue( |
---|
[13530] | 479 | '"zope.mgr",E1000000,p4465649308559,schoolfee_incl,' |
---|
[13385] | 480 | '60250.0,00,1500.0,250.0,0.0,,,\n' |
---|
[11868] | 481 | in logcontent) |
---|