source: main/waeup.futminna/trunk/src/waeup/futminna/interswitch/tests.py @ 9155

Last change on this file since 9155 was 9155, checked in by Henrik Bettermann, 12 years ago

Prepare for previous session payments but disable student payments completely. setPaymentDetails has to be written from the scratch.

  • Property svn:keywords set to Id
File size: 4.1 KB
RevLine 
[7894]1## $Id: tests.py 9155 2012-09-04 07:09:29Z 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
[8266]20from waeup.kofa.applicants.tests.test_browser import ApplicantsFullSetup
21from waeup.kofa.configuration import SessionConfiguration
[8619]22from waeup.futminna.testing import FunctionalLayer
[7894]23
[7970]24# Also run tests that send requests to external servers?
25#   If you enable this, please make sure the external services
26#   do exist really and are not bothered by being spammed by a test programme.
[8271]27EXTERNAL_TESTS = False
[7970]28
29def external_test(func):
30    if not EXTERNAL_TESTS:
31        myself = __file__
32        if myself.endswith('.pyc'):
33            myself = myself[:-2]
34        print "WARNING: external tests are skipped!"
35        print "WARNING: edit %s to enable them." % myself
36        return
37    return func
38
39
[8266]40class InterswitchTestsStudents(StudentsFullSetup):
[7929]41    """Tests for the Interswitch payment gateway.
[7894]42    """
43
44    layer = FunctionalLayer
45
[7970]46    def setUp(self):
[8266]47        super(InterswitchTestsStudents, self).setUp()
[7970]48        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
[7995]49        self.browser.open(self.payments_path)
[7970]50        IWorkflowState(self.student).setState('cleared')
[7995]51        self.browser.open(self.payments_path + '/addop')
[7970]52        self.browser.getControl("Create ticket").click()
[9155]53        self.assertMatches('...Payment components not yet configured...',
[7970]54                           self.browser.contents)
55
56
[8266]57class InterswitchTestsApplicants(ApplicantsFullSetup):
58    """Tests for the Interswitch payment gateway.
59    """
60
61    layer = FunctionalLayer
62
63    def setUp(self):
64        super(InterswitchTestsApplicants, self).setUp()
65        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
66        self.browser.open(self.manage_path)
67        #IWorkflowState(self.student).setState('started')
68        super(InterswitchTestsApplicants, self).fill_correct_values()
[8526]69        self.applicantscontainer.application_fee = 1000.0
[8266]70        self.browser.getControl(name="transition").value = ['start']
71        self.browser.getControl("Save").click()
72        self.browser.getControl("Add online").click()
73        self.assertMatches('...ticket created...',
74                           self.browser.contents)
[8281]75        #ctrl = self.browser.getControl(name='val_id')
76        #value = ctrl.options[0]
77        #self.browser.getLink(value).click()
[8266]78        self.assertMatches('...Amount Authorized...',
79                           self.browser.contents)
80        self.assertMatches(
81            '...<span>1000.0</span>...',
82            self.browser.contents)
83        self.payment_url = self.browser.url
84
85
86    def test_interswitch_form(self):
87
88        # Manager can access InterswitchForm
89        self.browser.getLink("CollegePAY", index=0).click()
90        self.assertMatches('...Total Amount Authorized:...',
91                           self.browser.contents)
92        self.assertMatches(
[8276]93            '...<input type="hidden" name="amount" value="100000.0" />...',
[8266]94            self.browser.contents)
95
96    @external_test
97    def test_webservice(self):
98
99        self.browser.open(self.payment_url + '/request_webservice')
100        self.assertMatches('...Unsuccessful callback...',
101                          self.browser.contents)
102        # The payment is now in state failed
103        self.assertMatches('...<span>Failed</span>...',
104                          self.browser.contents)
Note: See TracBrowser for help on using the repository browser.