1 | ## $Id: tests.py 8020 2012-04-02 11:05:40Z 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 |
---|
20 | from waeup.uniben.testing import FunctionalLayer |
---|
21 | |
---|
22 | |
---|
23 | # Also run tests that send requests to external servers? |
---|
24 | # If you enable this, please make sure the external services |
---|
25 | # do exist really and are not bothered by being spammed by a test programme. |
---|
26 | EXTERNAL_TESTS = False |
---|
27 | |
---|
28 | def external_test(func): |
---|
29 | if not EXTERNAL_TESTS: |
---|
30 | myself = __file__ |
---|
31 | if myself.endswith('.pyc'): |
---|
32 | myself = myself[:-2] |
---|
33 | print "WARNING: external tests are skipped!" |
---|
34 | print "WARNING: edit %s to enable them." % myself |
---|
35 | return |
---|
36 | return func |
---|
37 | |
---|
38 | class EtranzactTests(StudentsFullSetup): |
---|
39 | """Tests for the eTranzact payment gateway. |
---|
40 | """ |
---|
41 | |
---|
42 | layer = FunctionalLayer |
---|
43 | |
---|
44 | CONFIRMATION_NO = '500856521315472785095' |
---|
45 | |
---|
46 | def setUp(self): |
---|
47 | super(EtranzactTests, self).setUp() |
---|
48 | # Managers can add online payment tickets |
---|
49 | self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') |
---|
50 | self.browser.open(self.payments_path) |
---|
51 | IWorkflowState(self.student).setState('cleared') |
---|
52 | self.browser.open(self.payments_path + '/addop') |
---|
53 | self.browser.getControl("Create ticket").click() |
---|
54 | self.assertMatches('...ticket created...', |
---|
55 | self.browser.contents) |
---|
56 | ctrl = self.browser.getControl(name='val_id') |
---|
57 | value = ctrl.options[0] |
---|
58 | self.browser.getLink(value).click() |
---|
59 | self.assertMatches('...Amount Authorized...', |
---|
60 | self.browser.contents) |
---|
61 | self.payment_url = self.browser.url |
---|
62 | |
---|
63 | def test_enterpin(self): |
---|
64 | self.browser.getLink("Query eTranzact History").click() |
---|
65 | self.assertMatches( |
---|
66 | '...Confirmation Number (PIN):...', |
---|
67 | self.browser.contents) |
---|
68 | |
---|
69 | @external_test |
---|
70 | def test_etranzact_query_history(self): |
---|
71 | |
---|
72 | self.browser.open(self.payment_url + '/query_history?confirmation_number=%s' |
---|
73 | % self.CONFIRMATION_NO) |
---|
74 | self.assertMatches('...Wrong amount...', |
---|
75 | self.browser.contents) |
---|
76 | |
---|
77 | self.student['payments'][value].amount_auth = self.student[ |
---|
78 | 'payments'][value].r_amount_approved |
---|
79 | self.browser.open(self.payment_url + '/query_history?confirmation_number=%s' |
---|
80 | % self.CONFIRMATION_NO) |
---|
81 | self.assertMatches('...Wrong transaction id...', |
---|
82 | self.browser.contents) |
---|