forked from andela-sjames/paystack-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_transaction.py
More file actions
107 lines (89 loc) · 3.23 KB
/
test_transaction.py
File metadata and controls
107 lines (89 loc) · 3.23 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
"""Script defined to test the Customer class."""
import httpretty
from paystackapi.transaction import Transaction
from paystackapi.tests.base_test_case import BaseTestCase
class TestTransaction(BaseTestCase):
"""Method defined to test transaction initialize."""
@httpretty.activate
def test_initialize(self):
httpretty.register_uri(
httpretty.POST,
self.endpoint_url("/transaction/initialize"),
content_type='text/json',
body='{"status": true, "contributors": true}',
status=201,
)
response = Transaction.initialize(
reference='getupall', amount=12000,
email='[email protected]')
self.assertTrue(response['status'])
@httpretty.activate
def test_charge(self):
httpretty.register_uri(
httpretty.POST,
self.endpoint_url("/transaction/charge_authorization"),
content_type='text/json',
body='{"status": true, "contributors": true}',
status=201,
)
response = Transaction.charge(
reference='getupall', authorization_code='authorization_code',
email='email', amount='amount')
self.assertTrue(response['status'])
@httpretty.activate
def test_charge_token(self):
httpretty.register_uri(
httpretty.POST,
self.endpoint_url("/transaction/charge_token"),
content_type='text/json',
body='{"status": true, "contributors": true}',
status=201,
)
response = Transaction.charge_token(
reference='getupall', token='token',
email='email', amount=100000)
self.assertTrue(response['status'])
@httpretty.activate
def test_get(self):
httpretty.register_uri(
httpretty.GET,
self.endpoint_url("/transaction/4013"),
content_type='text/json',
body='{"status": true, "contributors": true}',
status=201,
)
response = Transaction.get(transaction_id=4013)
self.assertTrue(response['status'])
@httpretty.activate
def test_list(self):
httpretty.register_uri(
httpretty.GET,
self.endpoint_url("/transaction"),
content_type='text/json',
body='{"status": true, "contributors": true}',
status=201,
)
response = Transaction.list()
self.assertTrue(response['status'])
@httpretty.activate
def test_totals(self):
httpretty.register_uri(
httpretty.GET,
self.endpoint_url("/transaction/totals"),
content_type='text/json',
body='{"status": true, "contributors": true}',
status=201,
)
response = Transaction.totals()
self.assertTrue(response['status'])
@httpretty.activate
def test_verify(self):
httpretty.register_uri(
httpretty.GET,
self.endpoint_url("/transaction/verify/reference"),
content_type='text/json',
body='{"status": true, "contributors": true}',
status=201,
)
response = Transaction.verify('reference')
self.assertTrue(response['status'])