1
|
|
|
"""Script defined to test the Customer class.""" |
2
|
|
|
|
3
|
|
|
|
4
|
|
|
import unittest |
5
|
|
|
import httpretty |
6
|
|
|
|
7
|
|
|
from paystackapi.transaction import Transaction |
8
|
|
|
|
9
|
|
|
|
10
|
|
|
class TestTransaction(unittest.TestCase): |
11
|
|
|
"""Method defined to test transaction initialize.""" |
12
|
|
|
|
13
|
|
|
@httpretty.activate |
14
|
|
|
def test_initialize(self): |
15
|
|
|
httpretty.register_uri( |
16
|
|
|
httpretty.POST, |
17
|
|
|
"https://api.paystack.co/transaction/initialize", |
18
|
|
|
content_type='text/json', |
19
|
|
|
body='{"status": true, "contributors": true}', |
20
|
|
|
status=201, |
21
|
|
|
) |
22
|
|
|
|
23
|
|
|
response = Transaction.initialize( |
24
|
|
|
reference='getupall', amount=12000, |
25
|
|
|
email='[email protected]') |
26
|
|
|
self.assertTrue(response['status']) |
27
|
|
|
|
28
|
|
|
@httpretty.activate |
29
|
|
|
def test_charge(self): |
30
|
|
|
httpretty.register_uri( |
31
|
|
|
httpretty.POST, |
32
|
|
|
"https://api.paystack.co/transaction/charge_authorization", |
33
|
|
|
content_type='text/json', |
34
|
|
|
body='{"status": true, "contributors": true}', |
35
|
|
|
status=201, |
36
|
|
|
) |
37
|
|
|
|
38
|
|
|
response = Transaction.charge( |
39
|
|
|
reference='getupall', authorization_code='authorization_code', |
40
|
|
|
email='email', amount='amount') |
41
|
|
|
self.assertTrue(response['status']) |
42
|
|
|
|
43
|
|
|
@httpretty.activate |
44
|
|
|
def test_charge_token(self): |
45
|
|
|
httpretty.register_uri( |
46
|
|
|
httpretty.POST, |
47
|
|
|
"https://api.paystack.co/transaction/charge_token", |
48
|
|
|
content_type='text/json', |
49
|
|
|
body='{"status": true, "contributors": true}', |
50
|
|
|
status=201, |
51
|
|
|
) |
52
|
|
|
|
53
|
|
|
response = Transaction.charge_token( |
54
|
|
|
reference='getupall', token='token', |
55
|
|
|
email='email', amount=100000) |
56
|
|
|
self.assertTrue(response['status']) |
57
|
|
|
|
58
|
|
|
@httpretty.activate |
59
|
|
|
def test_get(self): |
60
|
|
|
httpretty.register_uri( |
61
|
|
|
httpretty.GET, |
62
|
|
|
"https://api.paystack.co/transaction/4013", |
63
|
|
|
content_type='text/json', |
64
|
|
|
body='{"status": true, "contributors": true}', |
65
|
|
|
status=201, |
66
|
|
|
) |
67
|
|
|
|
68
|
|
|
response = Transaction.get(transaction_id=4013) |
69
|
|
|
self.assertTrue(response['status']) |
70
|
|
|
|
71
|
|
|
@httpretty.activate |
72
|
|
|
def test_list(self): |
73
|
|
|
httpretty.register_uri( |
74
|
|
|
httpretty.GET, |
75
|
|
|
"https://api.paystack.co/transaction", |
76
|
|
|
content_type='text/json', |
77
|
|
|
body='{"status": true, "contributors": true}', |
78
|
|
|
status=201, |
79
|
|
|
) |
80
|
|
|
|
81
|
|
|
response = Transaction.list() |
82
|
|
|
self.assertTrue(response['status']) |
83
|
|
|
|
84
|
|
|
@httpretty.activate |
85
|
|
|
def test_totals(self): |
86
|
|
|
httpretty.register_uri( |
87
|
|
|
httpretty.GET, |
88
|
|
|
"https://api.paystack.co/transaction/totals", |
89
|
|
|
content_type='text/json', |
90
|
|
|
body='{"status": true, "contributors": true}', |
91
|
|
|
status=201, |
92
|
|
|
) |
93
|
|
|
|
94
|
|
|
response = Transaction.totals() |
95
|
|
|
self.assertTrue(response['status']) |
96
|
|
|
|
97
|
|
|
@httpretty.activate |
98
|
|
|
def test_verify(self): |
99
|
|
|
httpretty.register_uri( |
100
|
|
|
httpretty.GET, |
101
|
|
|
"https://api.paystack.co/transaction/verify/reference", |
102
|
|
|
content_type='text/json', |
103
|
|
|
body='{"status": true, "contributors": true}', |
104
|
|
|
status=201, |
105
|
|
|
) |
106
|
|
|
|
107
|
|
|
response = Transaction.verify('reference') |
108
|
|
|
self.assertTrue(response['status']) |
109
|
|
|
|