source: main/waeup.futminna/trunk/src/waeup/futminna/etranzact/tests.py @ 8619

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

Replace uniben by futminna.

  • Property svn:keywords set to Id
File size: 5.6 KB
Line 
1## $Id: tests.py 8619 2012-06-03 17:56:05Z 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.futminna.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.browser.getLink(value).click()
61        self.assertMatches('...Amount Authorized...',
62                           self.browser.contents)
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'
75            % self.CONFIRMATION_NO)
76        self.assertMatches('...Invalid or unsuccessful callback:...',
77                          self.browser.contents)
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)
86
87class 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)
111        self.browser.open(self.manage_path)
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
125        self.browser.open(self.payment_url + '/query_history?confirmation_number=%s'
126            % self.CONFIRMATION_NO)
127        self.assertMatches('...Invalid or unsuccessful callback:...',
128                          self.browser.contents)
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)
Note: See TracBrowser for help on using the repository browser.