source: main/waeup.aaue/trunk/src/waeup/aaue/etranzact/tests.py @ 8751

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

It seems that also the order is important.

  • Property svn:keywords set to Id
File size: 6.1 KB
Line 
1## $Id: tests.py 8733 2012-06-15 12:17:30Z 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.kofa.applicants.tests.test_browser import ApplicantsFullSetup
21from waeup.kofa.configuration import SessionConfiguration
22from waeup.aaue.testing import FunctionalLayer
23
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.
28EXTERNAL_TESTS = False
29
30def 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
40class EtranzactTestsStudent(StudentsFullSetup):
41    """Tests for the eTranzact payment gateway.
42    """
43
44    layer = FunctionalLayer
45
46    CONFIRMATION_NO = '500856521315472785095'
47
48    def setUp(self):
49        super(EtranzactTestsStudent, self).setUp()
50        # Managers can add online payment tickets
51        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
52        self.browser.open(self.payments_path)
53        IWorkflowState(self.student).setState('cleared')
54        self.browser.open(self.payments_path + '/addop')
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.p_id = value
61        self.browser.getLink(value).click()
62        self.assertMatches('...Amount Authorized...',
63                           self.browser.contents)
64        self.payment_url = self.browser.url
65
66    def test_enterpin(self):
67        self.browser.getLink("Query eTranzact History").click()
68        self.assertMatches(
69            '...Confirmation Number (PIN):...',
70            self.browser.contents)
71
72    def test_webservice(self):
73        self.browser.open('http://localhost/app/feerequest?PAYEE_ID=%s' % self.p_id)
74        self.assertEqual(self.browser.contents,
75            'FULL_NAME=Anna Tester&'
76            'FACULTY=fac1&'
77            'DEPARTMENT=dep1&'
78            'RETURN_TYPE=%s&'
79            'PROGRAMME_TYPE=CERT1&'
80            'PAYMENT_TYPE=School Fee&'
81            'ACADEMIC_SESSION=2004/2005&'
82            'MATRIC_NO=E1000000&'
83            'FEE_AMOUNT=40000.0&'
84            'TRANSACTION_STATUS=unpaid' % self.p_id)
85
86    @external_test
87    def test_etranzact_query_history(self):
88
89        self.browser.open(self.payment_url + '/query_history?confirmation_number=%s'
90            % self.CONFIRMATION_NO)
91        self.assertMatches('...Invalid or unsuccessful callback:...',
92                          self.browser.contents)
93        #self.assertMatches('...Wrong amount...',
94        #                  self.browser.contents)
95        #self.student['payments'][value].amount_auth = self.student[
96        #    'payments'][value].r_amount_approved
97        #self.browser.open(self.payment_url + '/query_history?confirmation_number=%s'
98        #    % self.CONFIRMATION_NO)
99        #self.assertMatches('...Wrong transaction id...',
100        #                  self.browser.contents)
101
102class EtranzactTestsApplicants(ApplicantsFullSetup):
103    """Tests for the Interswitch payment gateway.
104    """
105
106    layer = FunctionalLayer
107
108    CONFIRMATION_NO = '500856521315472785095'
109
110    def setUp(self):
111        super(EtranzactTestsApplicants, self).setUp()
112        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
113        self.browser.open(self.manage_path)
114        #IWorkflowState(self.student).setState('started')
115        super(EtranzactTestsApplicants, self).fill_correct_values()
116        self.browser.getControl(name="transition").value = ['start']
117        self.browser.getControl("Save").click()
118        self.browser.getControl("Add online").click()
119        self.assertTrue(
120            'Session configuration object is not available'
121            in self.browser.contents)
122        configuration = SessionConfiguration()
123        configuration.academic_session = 2009
124        configuration.application_fee = 1000.0
125        self.app['configuration'].addSessionConfiguration(configuration)
126        self.browser.open(self.manage_path)
127        self.browser.getControl("Add online").click()
128        self.assertMatches('...ticket created...',
129                           self.browser.contents)
130        self.assertMatches('...Amount Authorized...',
131                           self.browser.contents)
132        self.assertMatches(
133            '...<span>1000.0</span>...',
134            self.browser.contents)
135        self.payment_url = self.browser.url
136
137    @external_test
138    def test_etranzact_query_history(self):
139
140        self.browser.open(self.payment_url + '/query_history?confirmation_number=%s'
141            % self.CONFIRMATION_NO)
142        self.assertMatches('...Invalid or unsuccessful callback:...',
143                          self.browser.contents)
144        #self.assertMatches('...Wrong amount...',
145        #                  self.browser.contents)
146        #self.applicant[value].amount_auth = self.applicant[
147        #    value].r_amount_approved
148        #self.browser.open(self.payment_url + '/query_history?confirmation_number=%s'
149        #    % self.CONFIRMATION_NO)
150        #self.assertMatches('...Wrong transaction id...',
151        #                  self.browser.contents)
Note: See TracBrowser for help on using the repository browser.