Ignore:
Timestamp:
4 Nov 2015, 05:10:46 (9 years ago)
Author:
Henrik Bettermann
Message:

Add test for query_interswitch.

File:
1 edited

Legend:

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

    r13015 r13386  
    2424from waeup.kofa.applicants.tests.test_browser import ApplicantsFullSetup
    2525from waeup.kofa.configuration import SessionConfiguration
     26from waeup.kofa.students.payments import StudentOnlinePayment
     27from kofacustom.nigeria.interswitch.helpers import query_interswitch
    2628from kofacustom.nigeria.testing import FunctionalLayer
     29
     30# Also run tests that send requests to external servers?
     31#   If you enable this, please make sure the external services
     32#   do exist really and are not bothered by being spammed by a test programme.
     33EXTERNAL_TESTS = True
     34
     35def external_test(func):
     36    if not EXTERNAL_TESTS:
     37        myself = __file__
     38        if myself.endswith('.pyc'):
     39            myself = myself[:-2]
     40        print "WARNING: external tests are skipped!"
     41        print "WARNING: edit %s to enable them." % myself
     42        return
     43    return func
    2744
    2845class InterswitchTestsStudents(StudentsFullSetup):
     
    4865        self.assertMatches('...Amount Authorized...',
    4966                           self.browser.contents)
    50         self.assertMatches(
    51             '...<span>40000.0</span>...',
    52             self.browser.contents)
     67        self.assertTrue('<span>40000.0</span>', self.browser.contents)
    5368        self.payment_url = self.browser.url
    5469        self.payment = self.student['payments'][self.value]
     
    119134        self.assertMatches('...Total Amount Authorized:...',
    120135                           self.browser.contents)
     136
     137    @external_test
     138    def test_query_interswitch(self):
     139        host = 'webpay.interswitchng.com'
     140        url = '/paydirect/services/TransactionQueryWs.asmx'
     141        https = True
     142        product_id = '5845' # AAUE regular
     143        payment = StudentOnlinePayment()
     144        payment.p_id ='p4465649308559'
     145        payment.amount_auth = 60250.0
     146        success, msg, log = query_interswitch(
     147            payment, product_id, host, url, https)
     148        self.assertEqual('Successful callback received', msg)
     149        self.assertTrue(success)
     150        self.assertTrue(
     151            '00:Approved Successful:6025000:3154:p4465649308559:'
     152            'ZIB|WEB|ABAL|3-11-2015|021336:000457580882' in log)
    121153
    122154class InterswitchTestsApplicants(ApplicantsFullSetup):
Note: See TracChangeset for help on using the changeset viewer.