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