Ignore:
Timestamp:
1 Nov 2019, 11:39:34 (5 years ago)
Author:
Henrik Bettermann
Message:

Add test.

Location:
main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/etranzact
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/etranzact/helpers.py

    r15730 r15734  
    3030from waeup.kofa.utils.helpers import extract_formvars
    3131from kofacustom.nigeria.interfaces import MessageFactory as _
     32
     33ERROR_PART1 = (
     34        'PayeeName=N/A~'
     35        + 'Faculty=N/A~'
     36        + 'Department=N/A~'
     37        + 'Level=N/A~'
     38        + 'ProgrammeType=N/A~'
     39        + 'StudyType=N/A~'
     40        + 'Session=N/A~'
     41        + 'PayeeID=N/A~'
     42        + 'Amount=N/A~'
     43        + 'FeeStatus=')
     44ERROR_PART2 = (
     45        '~Semester=N/A~'
     46        + 'PaymentType=N/A~'
     47        + 'MatricNumber=N/A~'
     48        + 'Email=N/A~'
     49        + 'PhoneNumber=N/A')
    3250
    3351def write_payments_log(id, payment):
  • main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/etranzact/payoutletwebservice.py

    r15702 r15734  
    2323from waeup.kofa.payments.interfaces import IPayer
    2424from waeup.kofa.webservices import PaymentDataWebservice
    25 
    26 ERROR_PART1 = (
    27         'PayeeName=N/A~'
    28         + 'Faculty=N/A~'
    29         + 'Department=N/A~'
    30         + 'Level=N/A~'
    31         + 'ProgrammeType=N/A~'
    32         + 'StudyType=N/A~'
    33         + 'Session=N/A~'
    34         + 'PayeeID=N/A~'
    35         + 'Amount=N/A~'
    36         + 'FeeStatus=')
    37 ERROR_PART2 = (
    38         '~Semester=N/A~'
    39         + 'PaymentType=N/A~'
    40         + 'MatricNumber=N/A~'
    41         + 'Email=N/A~'
    42         + 'PhoneNumber=N/A')
     25from kofacustom.nigeria.etranzact.helpers import ERROR_PART1, ERROR_PART2
    4326
    4427class NigeriaPaymentDataWebservice(PaymentDataWebservice):
     
    7457                return
    7558        payment_cats_dict = getUtility(IKofaUtils).PAYMENT_CATEGORIES
    76         if PAYMENT_TYPE not in self.CATEGORY_MAPPING.keys() \
    77             and PAYMENT_TYPE.lower() not in payment_cats_dict.keys():
     59        if not PAYMENT_TYPE or (PAYMENT_TYPE not in self.CATEGORY_MAPPING.keys() \
     60            and PAYMENT_TYPE.lower() not in payment_cats_dict.keys()):
    7861            self.output = ERROR_PART1 + 'Invalid PAYMENT_TYPE' + ERROR_PART2
    7962            return
  • main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/etranzact/tests.py

    r15730 r15734  
    3232from kofacustom.nigeria.students.payments import NigeriaStudentOnlinePayment
    3333from kofacustom.nigeria.testing import FunctionalLayer
    34 from kofacustom.nigeria.etranzact.helpers import query_history, query_payoutlet
     34from kofacustom.nigeria.etranzact.helpers import (
     35    query_history, query_payoutlet, ERROR_PART1, ERROR_PART2)
    3536
    3637#from kofacustom.nigeria.etranzact.helpers import (query_etranzact)
     
    269270        self.assertEqual(self.payment.r_desc, 'Test Test Test-CLEARANCE -001-p5723474039401')
    270271        return
     272
     273    def test_webservice(self):
     274        self.browser.open(
     275            'http://localhost/app/feerequest?PAYEE_ID=%s&PAYMENT_TYPE=SCHOOLFEE'
     276            % self.payment.p_id)
     277        self.assertEqual(self.browser.contents,
     278            'PayeeName=Anna Tester~'
     279            'Faculty=fac1~Department=dep1~'
     280            'Level=100~ProgrammeType=CERT1~'
     281            'StudyType=ug_ft~Session=2004/2005~'
     282            'PayeeID=%s~'
     283            'Amount=40000.0~FeeStatus=unpaid~'
     284            'Semester=N/A~PaymentType=School Fee~'
     285            'MatricNumber=234~Email=aa@aa.ng~'
     286            'PhoneNumber=1234' % self.payment.p_id)
     287        self.browser.open('http://localhost/app/feerequest')
     288        self.assertEqual(self.browser.contents, ERROR_PART1 + 'Missing PAYEE_ID' + ERROR_PART2)
     289
     290        self.browser.open('http://localhost/app/feerequest?NONSENSE=nonsense')
     291        self.assertEqual(self.browser.contents, ERROR_PART1 + 'Missing PAYEE_ID' + ERROR_PART2)
     292
     293        self.browser.open(
     294            'http://localhost/app/feerequest?PAYEE_ID=nonsense&PAYMENT_TYPE=SCHOOLFEE')
     295        self.assertEqual(self.browser.contents, ERROR_PART1 + 'Invalid PAYEE_ID' + ERROR_PART2)
     296
     297        self.browser.open(
     298            'http://localhost/app/feerequest?PAYEE_ID=%s&PAYMENT_TYPE=NONSENSE'
     299            % self.payment.p_id)
     300        self.assertEqual(self.browser.contents, ERROR_PART1 + 'Invalid PAYMENT_TYPE' + ERROR_PART2)
     301
     302        self.browser.open(
     303            'http://localhost/app/feerequest?PAYEE_ID=%s' % self.payment.p_id)
     304        self.assertEqual(self.browser.contents, ERROR_PART1 + 'Invalid PAYMENT_TYPE' + ERROR_PART2)
     305
     306        self.browser.open(
     307            'http://localhost/app/feerequest?PAYEE_ID=%s&PAYMENT_TYPE=CLEARANCE'
     308            % self.payment.p_id)
     309        self.assertEqual(self.browser.contents, ERROR_PART1 + 'Wrong PAYMENT_TYPE' + ERROR_PART2)
     310
     311        # Change payment state
     312        self.student['payments'][self.payment.p_id].p_state = 'paid'
     313
     314        self.browser.open(
     315            'http://localhost/app/feerequest?PAYEE_ID=%s&PAYMENT_TYPE=SCHOOLFEE'
     316            % self.payment.p_id)
     317        self.assertEqual(self.browser.contents, ERROR_PART1 + 'PAYEE_ID already used' + ERROR_PART2)
Note: See TracChangeset for help on using the changeset viewer.