forked from andela-sjames/paystack-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_charge.py
More file actions
134 lines (107 loc) · 3.66 KB
/
test_charge.py
File metadata and controls
134 lines (107 loc) · 3.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import httpretty
from paystackapi.tests.base_test_case import BaseTestCase
from paystackapi.charge import Charge
class TestCharge(BaseTestCase):
@httpretty.activate
def test_start_charge(self):
"""Method defined to test start charge."""
httpretty.register_uri(
httpretty.POST,
self.endpoint_url("/charge"),
content_type='text/json',
body='{"status": true, "message": "Charge attempted"}',
status=201,
)
response = Charge.start_charge(
email="CUS_je02lbimlqixzax",
amount=42000,
metadata={
"custom_fields": [
{
"value":"makurdi",
"display_name": "Donation for",
"variable_name": "donation_for"
},
],
},
bank={
"code":"057",
"account_number":"0000000000"
},
birthday="1995-12-23"
)
self.assertTrue(response['status'])
@httpretty.activate
def test_submit_pin(self):
"""Method defined to test submit pin."""
httpretty.register_uri(
httpretty.POST,
self.endpoint_url("/charge/submit_pin"),
content_type='text/json',
body='{"status": true, "message": "Charge attempted"}',
status=201,
)
response = Charge.submit_pin(
pin="0987",
reference="5bwib5v6anhe9xa",
)
self.assertTrue(response['status'])
@httpretty.activate
def test_submit_otp(self):
"""Method defined to test submit otp."""
httpretty.register_uri(
httpretty.POST,
self.endpoint_url("/charge/submit_otp"),
content_type='text/json',
body='{"status": true, "message": "Charge attempted"}',
status=201,
)
response = Charge.submit_otp(
otp="0987",
reference="5bwib5v6anhe9xa",
)
self.assertTrue(response['status'])
@httpretty.activate
def test_submit_phone(self):
"""Method defined to test submit phone."""
httpretty.register_uri(
httpretty.POST,
self.endpoint_url("/charge/submit_phone"),
content_type='text/json',
body='{"status": true, "message": "Charge attempted"}',
status=201,
)
response = Charge.submit_phone(
phone="0XX4XX9X0XF",
reference="5bwib5v6anhe9xa",
)
self.assertTrue(response['status'])
@httpretty.activate
def test_submit_birthday(self):
"""Method defined to test submit birthday."""
httpretty.register_uri(
httpretty.POST,
self.endpoint_url("/charge/submit_birthday"),
content_type='text/json',
body='{"status": true, "message": "Charge attempted"}',
status=201,
)
response = Charge.submit_birthday(
birthday="1975-12-23",
reference="5bwib5v6anhe9xa",
)
self.assertTrue(response['status'])
@httpretty.activate
def test_check_pending(self):
"""Method defined to test check pending charge."""
httpretty.register_uri(
httpretty.GET,
self.endpoint_url("/charge/5bwib5v6anhe9xa"),
content_type='text/json',
body='{"status": true, "message": "Reference check successful"}',
status=201,
)
response = Charge.check_pending(
reference="5bwib5v6anhe9xa",
)
self.assertTrue(response['status'])