Skip to content

Commit 5dc113a

Browse files
corentinalcoynioperas06
authored andcommitted
fix test for setup_payout function
1 parent 3646dde commit 5dc113a

File tree

2 files changed

+50
-6
lines changed

2 files changed

+50
-6
lines changed

kkiapay/core.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ def refund_transaction(self, transaction_id):
5757
)
5858

5959
def setup_payout(self, algorithm: str, destination: str, destination_type: str, roof_amount: str = None,
60-
send_notification: bool = True, rate_frequency: str = None, country_code: str = "229"):
60+
send_notification: bool = True, rate_frequency: str = DESTINATION_TYPES["1"],
61+
country_code: str = "229"):
6162
options = {
6263
"destination": country_code + destination if destination_type == "1" else destination,
6364
"send_notification": 1 if send_notification else 0,

tests/test_kkiapay.py

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,55 @@ def teardown_module(module):
1414

1515

1616
class TestKkiapay(object):
17-
def test_urls(self):
18-
live = Kkiapay("public_key", "private_key", "secret")
19-
sandbox = Kkiapay("public_key", "private_key", "secret", sandbox=True)
17+
live = Kkiapay("public_key", "private_key", "secret")
18+
sandbox = Kkiapay("public_key", "private_key", "secret", sandbox=True)
2019

21-
assert live.url == Kkiapay.BASE_URL
22-
assert sandbox.url == Kkiapay.SANDBOX_URL
20+
def test_urls(self):
21+
assert self.live.url == Kkiapay.BASE_URL
22+
assert self.sandbox.url == Kkiapay.SANDBOX_URL
2323

2424
def test_requests(self, requests_mock):
2525
pass
26+
27+
def test_setup_payout(self, monkeypatch):
28+
results = {
29+
'response': {
30+
'merchant': '5d34445784deb700073a0281',
31+
'meta_data': '',
32+
'algorithm': 'roof',
33+
'rate_frequency': '',
34+
'roof_amount': '50000',
35+
'active': True,
36+
'send_notification': True,
37+
'destination_type': 'MOBILE_MONEY',
38+
'destination': '22961000000',
39+
'job_name': '',
40+
'account': '5d34445784deb700073a0282'
41+
},
42+
'status_code': 200}
43+
44+
class MockJsonResponse:
45+
status_code = 200
46+
47+
@staticmethod
48+
def json():
49+
return {
50+
'merchant': '5d34445784deb700073a0281',
51+
'meta_data': '',
52+
'algorithm': 'roof',
53+
'rate_frequency': '',
54+
'roof_amount': '50000',
55+
'active': True,
56+
'send_notification': True,
57+
'destination_type': 'MOBILE_MONEY',
58+
'destination': '22961000000',
59+
'job_name': '',
60+
'account': '5d34445784deb700073a0282'
61+
}
62+
63+
def kkiapay_api_mock_return(*args, **kwargs):
64+
return MockJsonResponse()
65+
66+
monkeypatch.setattr(requests, 'post', kkiapay_api_mock_return)
67+
assert self.sandbox.setup_payout(algorithm="2", destination="61000000", destination_type="1") == results
68+
assert self.live.setup_payout(algorithm="1", destination="61000000", destination_type="1") == results

0 commit comments

Comments
 (0)