[7929] | 1 | ## $Id: tests.py 8430 2012-05-12 08:43:51Z 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 | ## |
---|
| 18 | from hurry.workflow.interfaces import IWorkflowState |
---|
| 19 | from waeup.kofa.students.tests.test_browser import StudentsFullSetup |
---|
[8267] | 20 | from waeup.kofa.applicants.tests.test_browser import ApplicantsFullSetup |
---|
| 21 | from waeup.kofa.configuration import SessionConfiguration |
---|
[8020] | 22 | from waeup.uniben.testing import FunctionalLayer |
---|
[7929] | 23 | |
---|
[7970] | 24 | |
---|
| 25 | # Also run tests that send requests to external servers? |
---|
| 26 | # If you enable this, please make sure the external services |
---|
| 27 | # do exist really and are not bothered by being spammed by a test programme. |
---|
[8271] | 28 | EXTERNAL_TESTS = False |
---|
[7970] | 29 | |
---|
| 30 | def external_test(func): |
---|
| 31 | if not EXTERNAL_TESTS: |
---|
| 32 | myself = __file__ |
---|
| 33 | if myself.endswith('.pyc'): |
---|
| 34 | myself = myself[:-2] |
---|
| 35 | print "WARNING: external tests are skipped!" |
---|
| 36 | print "WARNING: edit %s to enable them." % myself |
---|
| 37 | return |
---|
| 38 | return func |
---|
| 39 | |
---|
[8267] | 40 | class EtranzactTestsStudent(StudentsFullSetup): |
---|
[7976] | 41 | """Tests for the eTranzact payment gateway. |
---|
[7929] | 42 | """ |
---|
| 43 | |
---|
| 44 | layer = FunctionalLayer |
---|
| 45 | |
---|
| 46 | CONFIRMATION_NO = '500856521315472785095' |
---|
| 47 | |
---|
[7976] | 48 | def setUp(self): |
---|
[8267] | 49 | super(EtranzactTestsStudent, self).setUp() |
---|
[7929] | 50 | # Managers can add online payment tickets |
---|
| 51 | self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') |
---|
[7995] | 52 | self.browser.open(self.payments_path) |
---|
[7929] | 53 | IWorkflowState(self.student).setState('cleared') |
---|
[7995] | 54 | self.browser.open(self.payments_path + '/addop') |
---|
[7929] | 55 | self.browser.getControl("Create ticket").click() |
---|
| 56 | self.assertMatches('...ticket created...', |
---|
| 57 | self.browser.contents) |
---|
| 58 | ctrl = self.browser.getControl(name='val_id') |
---|
| 59 | value = ctrl.options[0] |
---|
| 60 | self.browser.getLink(value).click() |
---|
| 61 | self.assertMatches('...Amount Authorized...', |
---|
| 62 | self.browser.contents) |
---|
[7976] | 63 | self.payment_url = self.browser.url |
---|
| 64 | |
---|
| 65 | def test_enterpin(self): |
---|
| 66 | self.browser.getLink("Query eTranzact History").click() |
---|
| 67 | self.assertMatches( |
---|
| 68 | '...Confirmation Number (PIN):...', |
---|
| 69 | self.browser.contents) |
---|
| 70 | |
---|
| 71 | @external_test |
---|
| 72 | def test_etranzact_query_history(self): |
---|
| 73 | |
---|
| 74 | self.browser.open(self.payment_url + '/query_history?confirmation_number=%s' |
---|
[7929] | 75 | % self.CONFIRMATION_NO) |
---|
[8267] | 76 | self.assertMatches('...Invalid or unsuccessful callback:...', |
---|
[7929] | 77 | self.browser.contents) |
---|
[8267] | 78 | #self.assertMatches('...Wrong amount...', |
---|
| 79 | # self.browser.contents) |
---|
| 80 | #self.student['payments'][value].amount_auth = self.student[ |
---|
| 81 | # 'payments'][value].r_amount_approved |
---|
| 82 | #self.browser.open(self.payment_url + '/query_history?confirmation_number=%s' |
---|
| 83 | # % self.CONFIRMATION_NO) |
---|
| 84 | #self.assertMatches('...Wrong transaction id...', |
---|
| 85 | # self.browser.contents) |
---|
[7929] | 86 | |
---|
[8267] | 87 | class EtranzactTestsApplicants(ApplicantsFullSetup): |
---|
| 88 | """Tests for the Interswitch payment gateway. |
---|
| 89 | """ |
---|
| 90 | |
---|
| 91 | layer = FunctionalLayer |
---|
| 92 | |
---|
| 93 | CONFIRMATION_NO = '500856521315472785095' |
---|
| 94 | |
---|
| 95 | def setUp(self): |
---|
| 96 | super(EtranzactTestsApplicants, self).setUp() |
---|
| 97 | self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') |
---|
| 98 | self.browser.open(self.manage_path) |
---|
| 99 | #IWorkflowState(self.student).setState('started') |
---|
| 100 | super(EtranzactTestsApplicants, self).fill_correct_values() |
---|
| 101 | self.browser.getControl(name="transition").value = ['start'] |
---|
| 102 | self.browser.getControl("Save").click() |
---|
| 103 | self.browser.getControl("Add online").click() |
---|
| 104 | self.assertTrue( |
---|
| 105 | 'Session configuration object is not available' |
---|
| 106 | in self.browser.contents) |
---|
| 107 | configuration = SessionConfiguration() |
---|
| 108 | configuration.academic_session = 2009 |
---|
| 109 | configuration.application_fee = 1000.0 |
---|
| 110 | self.app['configuration'].addSessionConfiguration(configuration) |
---|
[8430] | 111 | self.browser.open(self.manage_path) |
---|
[8267] | 112 | self.browser.getControl("Add online").click() |
---|
| 113 | self.assertMatches('...ticket created...', |
---|
| 114 | self.browser.contents) |
---|
| 115 | self.assertMatches('...Amount Authorized...', |
---|
| 116 | self.browser.contents) |
---|
| 117 | self.assertMatches( |
---|
| 118 | '...<span>1000.0</span>...', |
---|
| 119 | self.browser.contents) |
---|
| 120 | self.payment_url = self.browser.url |
---|
| 121 | |
---|
| 122 | @external_test |
---|
| 123 | def test_etranzact_query_history(self): |
---|
| 124 | |
---|
[7976] | 125 | self.browser.open(self.payment_url + '/query_history?confirmation_number=%s' |
---|
[7929] | 126 | % self.CONFIRMATION_NO) |
---|
[8267] | 127 | self.assertMatches('...Invalid or unsuccessful callback:...', |
---|
[7929] | 128 | self.browser.contents) |
---|
[8267] | 129 | #self.assertMatches('...Wrong amount...', |
---|
| 130 | # self.browser.contents) |
---|
| 131 | #self.applicant[value].amount_auth = self.applicant[ |
---|
| 132 | # value].r_amount_approved |
---|
| 133 | #self.browser.open(self.payment_url + '/query_history?confirmation_number=%s' |
---|
| 134 | # % self.CONFIRMATION_NO) |
---|
| 135 | #self.assertMatches('...Wrong transaction id...', |
---|
| 136 | # self.browser.contents) |
---|