1
|
|
|
"""Script defined to test the Class instance.""" |
2
|
|
|
|
3
|
|
|
|
4
|
|
|
import unittest |
5
|
|
|
import httpretty |
6
|
|
|
|
7
|
|
|
from paystackapi.base import PayStackBase, PayStackRequests |
8
|
|
|
|
9
|
|
|
|
10
|
|
|
class TestHttpMethods(unittest.TestCase): |
11
|
|
|
"""Method defined to test transaction instance.""" |
12
|
|
|
|
13
|
|
|
def setUp(self): |
14
|
|
|
paystackbase = PayStackBase() |
15
|
|
|
|
16
|
|
|
@httpretty.activate |
17
|
|
|
def test_get_method_called(self): |
18
|
|
|
|
19
|
|
|
httpretty.register_uri( |
20
|
|
|
httpretty.GET, |
21
|
|
|
"https://api.paystack.co/transaction/4013", |
22
|
|
|
content_type='text/json', |
23
|
|
|
body='{"status": true, "contributors": true}', |
24
|
|
|
status=201, |
25
|
|
|
) |
26
|
|
|
|
27
|
|
|
req = PayStackRequests() |
28
|
|
|
response = req.get('transaction/4013',) |
29
|
|
|
self.assertTrue(response['status']) |
30
|
|
|
|
31
|
|
|
@httpretty.activate |
32
|
|
|
def test_post_method_called(self): |
33
|
|
|
|
34
|
|
|
httpretty.register_uri( |
35
|
|
|
httpretty.POST, |
36
|
|
|
"https://api.paystack.co/transaction/charge_token", |
37
|
|
|
content_type='text/json', |
38
|
|
|
body='{"status": true, "contributors": null}', |
39
|
|
|
status=302, |
40
|
|
|
) |
41
|
|
|
|
42
|
|
|
req = PayStackRequests() |
43
|
|
|
response = req.post('transaction/charge_token', |
44
|
|
|
data={'track': 'requests'}) |
45
|
|
|
self.assertTrue(response['status']) |
46
|
|
|
|
47
|
|
|
@httpretty.activate |
48
|
|
|
def test_put_method_called(self): |
49
|
|
|
|
50
|
|
|
httpretty.register_uri( |
51
|
|
|
httpretty.PUT, |
52
|
|
|
"https://api.paystack.co/customer/4013", |
53
|
|
|
content_type='text/json', |
54
|
|
|
body='{"status": true, "contributors": null}', |
55
|
|
|
status=302, |
56
|
|
|
) |
57
|
|
|
|
58
|
|
|
req = PayStackRequests() |
59
|
|
|
response = req.put('customer/4013', |
60
|
|
|
data={'test': 'requests'}) |
61
|
|
|
self.assertTrue(response['status']) |
62
|
|
|
|