Ignore:
Timestamp:
1 Aug 2017, 07:12:58 (7 years ago)
Author:
Henrik Bettermann
Message:

Add query_remita helper function with test.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/remita/tests.py

    r14735 r14737  
    2525from waeup.kofa.applicants.tests.test_browser import ApplicantsFullSetup
    2626from waeup.kofa.configuration import SessionConfiguration
    27 from waeup.kofa.students.payments import StudentOnlinePayment
     27from kofacustom.nigeria.students.payments import NigeriaStudentOnlinePayment
    2828from kofacustom.nigeria.testing import FunctionalLayer
    2929
    3030from kofacustom.nigeria.remita.helpers import (
    31     get_JSON_POST_response, get_payment_status_via_rrr)
     31    get_JSON_POST_response, get_payment_status_via_rrr, query_remita)
    3232
    3333# Also run tests that send requests to external servers?
     
    4040        myself = __file__
    4141        if myself.endswith('.pyc'):
    42             myself = myself[:-2]
     42            myself = myself[:-1]
    4343        print "WARNING: external tests are skipped!"
    4444        print "WARNING: edit %s to enable them." % myself
    4545        return
    4646    return func
     47
    4748
    4849class HelperTests(unittest.TestCase):
     
    8384            u'statuscode': u'055'}
    8485
     86
    8587    @external_test
    8688    def test_payment_status_via_rrr(self):
     
    105107            u'RRR': u'280007640804'}
    106108
     109
     110class RemitaTestsStudents(StudentsFullSetup):
     111    """Tests for the Remita payment gateway.
     112    """
     113
     114    layer = FunctionalLayer
     115
     116    merchantId = '2547916'
     117    serviceTypeId = '4430731'
     118    api_key = '1946'
     119    orderId = '3456346346'
     120    amount = '1000'
     121    responseurl = 'http://xxxx'
     122    host = 'www.remitademo.net'
     123
     124    def setUp(self):
     125        super(RemitaTestsStudents, self).setUp()
     126        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     127        self.browser.open(self.payments_path)
     128        IWorkflowState(self.student).setState('cleared')
     129        self.student.nationality = u'NG'
     130        self.browser.open(self.payments_path + '/addop')
     131        self.browser.getControl(name="form.p_category").value = ['schoolfee']
     132        self.browser.getControl("Create ticket").click()
     133        self.assertMatches('...ticket created...',
     134                           self.browser.contents)
     135        ctrl = self.browser.getControl(name='val_id')
     136        self.value = ctrl.options[0]
     137        self.browser.getLink(self.value).click()
     138        self.assertMatches('...Amount Authorized...',
     139                           self.browser.contents)
     140        self.assertTrue('<span>40000.0</span>', self.browser.contents)
     141        self.payment_url = self.browser.url
     142        self.payment = self.student['payments'][self.value]
     143
     144
     145    @external_test
     146    def test_query_remita(self):
     147        # We can only test the first part of query_interswitch since
     148        # we have no succesful payment.
     149        qr = query_remita(
     150            self.payment,
     151            merchantId=self.merchantId,
     152            api_key=self.api_key,
     153            RRR='280007640804',
     154            host=self.host,
     155            https=False,
     156            verify=False)
     157        assert qr == (
     158            False,
     159            u'Unsuccessful callback: ${a}',
     160            u'unsuccessful callback for schoolfee payment %s: Transaction Pending'
     161            % self.payment.p_id)
Note: See TracChangeset for help on using the changeset viewer.