forked from andela-sjames/paystack-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_subscription.py
More file actions
84 lines (70 loc) · 2.74 KB
/
test_subscription.py
File metadata and controls
84 lines (70 loc) · 2.74 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
"""Script defined to test the Subscription class."""
import httpretty
from paystackapi.subscription import Subscription
from paystackapi.tests.base_test_case import BaseTestCase
class TestSubscription(BaseTestCase):
"""Class to test subscription actions."""
@httpretty.activate
def test_create(self):
"""Method defined to test subscription creation."""
httpretty.register_uri(
httpretty.POST,
self.endpoint_url("/subscription"),
content_type='text/json',
body='{"status": true, "contributors": true}',
status=201,
)
response = Subscription.create(
customer = 'CUS_xnxdt6s1zg1f4nx',
plan = 'Pln_2yudUnIds2p',
authorization = '34'
)
self.assertTrue(response['status'])
@httpretty.activate
def test_fetch(self):
"""Function defined to test Subscription fetch method."""
httpretty.register_uri(
httpretty.GET,
self.endpoint_url("/subscription/4013"),
content_type='text/json',
body='{"status": true, "contributors": true}',
status=201,
)
response = Subscription.fetch(subscription_id=4013)
self.assertEqual(response['status'], True)
@httpretty.activate
def test_list(self):
"""Function defined to test paystackapi subscription list method."""
httpretty.register_uri(
httpretty.GET,
self.endpoint_url("/subscription"),
content_type='text/json',
body='{"status": true, "contributors": true}',
status=201,
)
response = Subscription.list()
self.assertEqual(response['status'], True)
@httpretty.activate
def test_disable(self):
"""Function defined to test paystackapi subscription disable method."""
httpretty.register_uri(
httpretty.POST,
self.endpoint_url("/subscription/disable"),
content_type='text/json',
body='{"status": true, "contributors": true}',
status=201,
)
response = Subscription.disable(code="SUB_vsyqdmlzble3uii",token="d7gofp6yppn3qz7")
self.assertEqual(response['status'], True)
@httpretty.activate
def test_enable(self):
"""Function defined to test paystackapi subscription enable method."""
httpretty.register_uri(
httpretty.POST,
self.endpoint_url("/subscription/enable"),
content_type='text/json',
body='{"status": true, "contributors": true}',
status=201,
)
response = Subscription.enable(code="SUB_vsyqdmlzble3uii", token="d7gofp6yppn3qz7")
self.assertEqual(response['status'], True)