@@ -14,12 +14,55 @@ def teardown_module(module):
1414
1515
1616class 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