forked from andela-sjames/paystack-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_base.py
More file actions
61 lines (46 loc) · 1.69 KB
/
test_base.py
File metadata and controls
61 lines (46 loc) · 1.69 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
"""Script defined to test the Class instance."""
import unittest
import httpretty
from paystackapi.base import PayStackBase, PayStackRequests
class TestHttpMethods(unittest.TestCase):
"""Method defined to test transaction instance."""
def setUp(self):
paystackbase = PayStackBase()
@httpretty.activate
def test_get_method_called(self):
httpretty.register_uri(
httpretty.GET,
"https://api.paystack.co/transaction/4013",
content_type='text/json',
body='{"status": true, "contributors": true}',
status=201,
)
req = PayStackRequests()
response = req.get('transaction/4013',)
self.assertTrue(response['status'])
@httpretty.activate
def test_post_method_called(self):
httpretty.register_uri(
httpretty.POST,
"https://api.paystack.co/transaction/charge_token",
content_type='text/json',
body='{"status": true, "contributors": null}',
status=302,
)
req = PayStackRequests()
response = req.post('transaction/charge_token',
data={'track': 'requests'})
self.assertTrue(response['status'])
@httpretty.activate
def test_put_method_called(self):
httpretty.register_uri(
httpretty.PUT,
"https://api.paystack.co/customer/4013",
content_type='text/json',
body='{"status": true, "contributors": null}',
status=302,
)
req = PayStackRequests()
response = req.put('customer/4013',
data={'test': 'requests'})
self.assertTrue(response['status'])