Changeset 14754 for main/kofacustom.nigeria/trunk/src
- Timestamp:
- 3 Aug 2017, 05:41:45 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/remita/tests.py
r14743 r14754 18 18 import os 19 19 import unittest 20 import random 20 21 from datetime import datetime, timedelta, date 21 22 from zope.component import createObject, getUtility … … 51 52 serviceTypeId = '4430731' 52 53 api_key = '1946' 53 orderId = '987698769876'54 amount = '1000'55 54 responseurl = 'http://xxxx' 56 55 host = 'www.remitademo.net' 56 url = '/remita/ecomm/split/init.reg' # /remita/ecomm/v2/init.reg 57 57 lineitems = ( 58 58 {"lineItemsId":"itemid1","beneficiaryName":"Oshadami Mike", … … 63 63 "beneficiaryAmount":"500","deductFeeFrom":"0"} 64 64 ) 65 66 @external_test 67 def test_get_JSON_POST_response(self): 68 69 url = '/remita/ecomm/split/init.reg' # /remita/ecomm/v2/init.reg 70 65 amount = 1000.0 66 67 def _get_transaction_data(self): 68 self.orderId = str(random.randint(100000000, 999999999)) 71 69 resp = get_JSON_POST_response( 72 70 merchantId=self.merchantId, serviceTypeId=self.serviceTypeId, 73 71 api_key=self.api_key, orderId=self.orderId, 74 72 amount=self.amount, responseurl=self.responseurl, 75 host=self.host, url=url, https=False, 73 host=self.host, url=self.url, https=False, 74 fullname='Anton Meier', email='am@xxx.de', 75 lineitems=self.lineitems) 76 self.rrr = resp['RRR'].rstrip() 77 78 @external_test 79 def test_get_JSON_POST_response(self): 80 self._get_transaction_data() 81 resp = get_JSON_POST_response( 82 merchantId=self.merchantId, serviceTypeId=self.serviceTypeId, 83 api_key=self.api_key, orderId=self.orderId, 84 amount=self.amount, responseurl=self.responseurl, 85 host=self.host, url=self.url, https=False, 76 86 fullname='Anton Meier', email='am@xxx.de', 77 87 lineitems=self.lineitems) 78 88 assert resp == { 79 89 u'status': u'RRR Already Exist for the orderId', 80 u'orderID': u'987698769876',81 u'RRR': u'320007640976', # strange trailing whitespace which82 90 u'orderID': self.orderId, 91 u'RRR': self.rrr + ' ', # strange trailing whitespace which 92 # obviously does not belong to the RRR 83 93 u'statuscode': u'055'} 84 85 @external_test86 def test_payment_status_via_rrr(self):87 94 88 95 resp = get_payment_status_via_rrr( 89 96 merchantId=self.merchantId, 90 97 api_key=self.api_key, 91 RRR= '320007640976',98 RRR=self.rrr, 92 99 host=self.host, 93 100 https=False, 94 101 ) 95 assert resp == { 96 u'orderId': u'987698769876', 97 u'status': u'021', 98 u'amount': 1000.0, 99 u'transactiontime': u'2017-08-01 12:10:32 PM', 100 u'message': u'Transaction Pending', 101 u'lineitems': [{u'status': u'021', u'lineItemsId': u'itemid1'}, 102 {u'status': u'021', u'lineItemsId': u'itemid2'} 103 ], 104 u'RRR': u'320007640976'} 102 assert resp['orderId'] == self.orderId 103 assert resp['status'] == '021' 104 assert resp['amount'] == self.amount 105 assert resp['lineitems'] == [ 106 {u'status': u'021', u'lineItemsId': u'itemid1'}, 107 {u'status': u'021', u'lineItemsId': u'itemid2'}] 108 assert resp['RRR'] == self.rrr 109 assert resp['message'] == u'Transaction Pending' 105 110 106 111 class RemitaTestsStudents(StudentsFullSetup): … … 113 118 serviceTypeId = '4430731' 114 119 api_key = '1946' 115 orderId = '3456346346'116 amount = '1000'117 120 responseurl = 'http://xxxx' 118 121 host = 'www.remitademo.net' 122 123 # successful transaction 124 # (hopefully this transaction remain in the Remita database) 125 orderId = '3456346346' 126 rrr = u'280007640804' 127 amount = 1000.0 128 129 # pending transaction 130 #orderId_p = '987698769876' 131 rrr_p = u'320007640976' 119 132 120 133 def setUp(self): … … 141 154 @external_test 142 155 def test_query_remita(self): 143 # We can only test the first part of query_interswitch since 144 # we have no succesful payment. 156 #requery pending transaction 145 157 qr = query_remita( 146 158 self.payment, 147 159 merchantId=self.merchantId, 148 160 api_key=self.api_key, 149 RRR= '320007640976',161 RRR=self.rrr_p, 150 162 host=self.host, 151 163 https=False, … … 157 169 % self.payment.p_id) 158 170 171 #requery successful transaction 172 self.payment.amount_auth = 1000.0 173 self.payment.p_id = self.orderId 174 qr = query_remita( 175 self.payment, 176 merchantId=self.merchantId, 177 api_key=self.api_key, 178 RRR=self.rrr, 179 host=self.host, 180 https=False, 181 verify=False) 182 assert qr[0] == True 183 assert qr[1] == u'Successful callback received' 184 159 185 @external_test 160 186 def test_remita_form(self): … … 162 188 self.browser.getLink("Pay via Remita").click() 163 189 # The RRR has been retrieved 164 self.assertTrue('<input name="rrr" type="hidden" value=" 280007640804">'165 in self.browser.contents) 166 self.assertEqual(self.payment.r_pay_reference, '280007640804')190 self.assertTrue('<input name="rrr" type="hidden" value="%s">' % self.rrr 191 in self.browser.contents) 192 self.assertEqual(self.payment.r_pay_reference, self.rrr) 167 193 # Means of testing end here. 168 194 return 195 196 @external_test 197 def test_requery_verify_payment_status(self): 198 # Manager can access InterswitchForm 199 self.browser.getLink("Requery Remita Payment Status").click() 200 self.assertTrue('Remita Retrieval Reference not found.' 201 in self.browser.contents) 202 self.payment.r_pay_reference = self.rrr 203 self.browser.getLink("Requery Remita Payment Status").click() 204 self.assertTrue('Callback amount does not match.' 205 in self.browser.contents) 206 self.payment.amount_auth = 1000.0 207 self.browser.getLink("Requery Remita Payment Status").click() 208 self.assertTrue('Callback order id does not match.' 209 in self.browser.contents) 210 self.payment.p_id = self.orderId 211 self.browser.getLink("Requery Remita Payment Status").click() 212 self.assertTrue('Successful payment' in self.browser.contents) 213 self.assertEqual(self.payment.r_desc, 'Approved') 214 self.assertEqual(self.payment.r_amount_approved , 1000.0) 215 self.assertEqual(self.payment.r_code, '01') 216 self.browser.getLink("Verify Remita Payment Status").click() 217 self.assertTrue('Successful payment' in self.browser.contents) 218 return
Note: See TracChangeset for help on using the changeset viewer.