source: main/waeup.custom/trunk/src/waeup/custom/interswitch/tests.py @ 7898

Last change on this file since 7898 was 7897, checked in by Henrik Bettermann, 13 years ago

Move all Interswitch components into separate package. This package can be simply removed when these payments are no longer required.

  • Property svn:keywords set to Id
File size: 3.5 KB
Line 
1## $Id: tests.py 7897 2012-03-16 09:51:50Z 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##
18from hurry.workflow.interfaces import IWorkflowState
19from waeup.kofa.students.tests.test_browser import StudentsFullSetup
20from waeup.custom.testing import FunctionalLayer
21
22class StudentUITests(StudentsFullSetup):
23    """Tests for customized student class views and pages
24    """
25
26    layer = FunctionalLayer
27
28    def callback_url(self, payment_url, resp, apprAmt):
29        return payment_url + (
30            '/callback?echo=' +
31            '&resp=%s' +
32            '&desc=Something went wrong' +
33            '&txnRef=p1331792385335' +
34            '&payRef=' + '&retRef=' +
35            '&cardNum=0' +
36            '&apprAmt=%s' +
37            '&url=http://xyz') % (resp, apprAmt)
38
39    def test_manage_payments(self):
40
41        # Managers can add online payment tickets
42        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
43        self.browser.open(self.payments_student_path)
44        IWorkflowState(self.student).setState('cleared')
45        self.browser.open(self.payments_student_path + '/addop')
46        self.browser.getControl("Create ticket").click()
47        self.assertMatches('...ticket created...',
48                           self.browser.contents)
49        ctrl = self.browser.getControl(name='val_id')
50        value = ctrl.options[0]
51        self.browser.getLink(value).click()
52        self.assertMatches('...Amount Authorized...',
53                           self.browser.contents)
54        payment_url = self.browser.url
55       
56        # Manager can access InterswitchForm
57        self.browser.getLink("CollegePAY", index=0).click()
58        self.assertMatches('...Total Amount Authorized:...',
59                           self.browser.contents)
60        self.assertMatches(
61            '...<input type="hidden" name="amount" value="4000000" />...',
62            self.browser.contents)
63
64        # Manager can call callback manually
65        self.browser.open(self.callback_url(payment_url, 'XX', '300'))
66        self.assertMatches('...Unsuccessful callback: Something went wrong...',
67                          self.browser.contents)
68        self.assertMatches('...Failed...',
69                           self.browser.contents)
70        self.browser.open(payment_url + '/callback')
71        self.assertMatches('...Unsuccessful callback: Incomplete query string...',
72                          self.browser.contents)
73        self.assertMatches('...Failed...',
74                           self.browser.contents)
75        self.browser.open(self.callback_url(payment_url, '00', '300'))
76        self.assertMatches('...Wrong amount...',
77                          self.browser.contents)
78        self.browser.open(self.callback_url(payment_url, '00', '40000'))
79        self.assertMatches('...Valid callback received...',
80                          self.browser.contents)
Note: See TracBrowser for help on using the repository browser.