Changeset 8266


Ignore:
Timestamp:
24 Apr 2012, 20:03:01 (13 years ago)
Author:
Henrik Bettermann
Message:

Add and improve tests for interswitch views.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.uniben/trunk/src/waeup/uniben/interswitch/tests.py

    r8263 r8266  
    1818from hurry.workflow.interfaces import IWorkflowState
    1919from waeup.kofa.students.tests.test_browser import StudentsFullSetup
     20from waeup.kofa.applicants.tests.test_browser import ApplicantsFullSetup
     21from waeup.kofa.configuration import SessionConfiguration
    2022from waeup.uniben.testing import FunctionalLayer
    2123
     
    3638
    3739
    38 class InterswitchTests(StudentsFullSetup):
     40class InterswitchTestsStudents(StudentsFullSetup):
    3941    """Tests for the Interswitch payment gateway.
    4042    """
     
    4345
    4446    def setUp(self):
    45         super(InterswitchTests, self).setUp()
     47        super(InterswitchTestsStudents, self).setUp()
    4648        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
    4749        self.browser.open(self.payments_path)
     
    5658        self.assertMatches('...Amount Authorized...',
    5759                           self.browser.contents)
     60        self.assertMatches(
     61            '...<span>40000.0</span>...',
     62            self.browser.contents)
    5863        self.payment_url = self.browser.url
    5964
     
    7681        self.assertMatches('...Total Amount Authorized:...',
    7782                           self.browser.contents)
     83        # The total amount to be processed by Interswitch
     84        # has been reduced by the Interswitch fee of 150 Nairas
    7885        self.assertMatches(
    7986            '...<input type="hidden" name="amount" value="3985000.0" />...',
     
    107114        self.assertMatches('...Unsuccessful callback...',
    108115                          self.browser.contents)
     116        # The payment is now in state failed
     117        self.assertMatches('...<span>Failed</span>...',
     118                          self.browser.contents)
     119
     120class InterswitchTestsApplicants(ApplicantsFullSetup):
     121    """Tests for the Interswitch payment gateway.
     122    """
     123
     124    layer = FunctionalLayer
     125
     126    def setUp(self):
     127        super(InterswitchTestsApplicants, self).setUp()
     128        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     129        self.browser.open(self.manage_path)
     130        #IWorkflowState(self.student).setState('started')
     131        super(InterswitchTestsApplicants, self).fill_correct_values()
     132        self.browser.getControl(name="transition").value = ['start']
     133        self.browser.getControl("Save").click()
     134        self.browser.getControl("Add online").click()
     135        self.assertTrue(
     136            'Session configuration object is not available'
     137            in self.browser.contents)
     138        configuration = SessionConfiguration()
     139        configuration.academic_session = 2009
     140        configuration.application_fee = 1000.0
     141        self.app['configuration'].addSessionConfiguration(configuration)
     142        self.browser.getControl("Add online").click()
     143        self.assertMatches('...ticket created...',
     144                           self.browser.contents)
     145        ctrl = self.browser.getControl(name='val_id')
     146        value = ctrl.options[0]
     147        self.browser.getLink(value).click()
     148        self.assertMatches('...Amount Authorized...',
     149                           self.browser.contents)
     150        self.assertMatches(
     151            '...<span>1000.0</span>...',
     152            self.browser.contents)
     153        self.payment_url = self.browser.url
     154
     155
     156    def test_interswitch_form(self):
     157
     158        # Manager can access InterswitchForm
     159        self.browser.getLink("CollegePAY", index=0).click()
     160        self.assertMatches('...Total Amount Authorized:...',
     161                           self.browser.contents)
     162        # The total amount to be processed by Interswitch
     163        # has been reduced by the Interswitch fee of 150 Nairas
     164        self.assertMatches(
     165            '...<input type="hidden" name="amount" value="85000.0" />...',
     166            self.browser.contents)
     167
     168    @external_test
     169    def test_webservice(self):
     170
     171        self.browser.open(self.payment_url + '/request_webservice')
     172        self.assertMatches('...Unsuccessful callback...',
     173                          self.browser.contents)
     174        # The payment is now in state failed
     175        self.assertMatches('...<span>Failed</span>...',
     176                          self.browser.contents)
Note: See TracChangeset for help on using the changeset viewer.