source: main/waeup.uniben/trunk/src/waeup/uniben/etranzact/tests.py @ 8259

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

Rename custom to uniben.

  • Property svn:keywords set to Id
File size: 3.2 KB
RevLine 
[7929]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##
18from hurry.workflow.interfaces import IWorkflowState
19from waeup.kofa.students.tests.test_browser import StudentsFullSetup
[8020]20from waeup.uniben.testing import FunctionalLayer
[7929]21
[7970]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.
26EXTERNAL_TESTS = False
27
28def 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
[7929]38class EtranzactTests(StudentsFullSetup):
[7976]39    """Tests for the eTranzact payment gateway.
[7929]40    """
41
42    layer = FunctionalLayer
43
44    CONFIRMATION_NO = '500856521315472785095'
45
[7976]46    def setUp(self):
47        super(EtranzactTests, self).setUp()
[7929]48        # Managers can add online payment tickets
49        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
[7995]50        self.browser.open(self.payments_path)
[7929]51        IWorkflowState(self.student).setState('cleared')
[7995]52        self.browser.open(self.payments_path + '/addop')
[7929]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)
[7976]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'
[7929]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
[7976]79        self.browser.open(self.payment_url + '/query_history?confirmation_number=%s'
[7929]80            % self.CONFIRMATION_NO)
81        self.assertMatches('...Wrong transaction id...',
82                          self.browser.contents)
Note: See TracBrowser for help on using the repository browser.