forked from andela-sjames/paystack-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_invoice.py
More file actions
176 lines (152 loc) · 5.46 KB
/
test_invoice.py
File metadata and controls
176 lines (152 loc) · 5.46 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
import httpretty
from paystackapi.tests.base_test_case import BaseTestCase
from paystackapi.invoice import Invoice
class TestInvoice(BaseTestCase):
@httpretty.activate
def test_create_invoice(self):
"""Method defined to test create Invoice."""
httpretty.register_uri(
httpretty.POST,
self.endpoint_url("/paymentrequest"),
content_type='text/json',
body='{"status": true, "message": "Invoice created"}',
status=201,
)
response = Invoice.create(
customer="CUS_je02lbimlqixzax",
amount=42000,
due_date="2019-05-08T00:00:00.000Z"
)
self.assertTrue(response['status'])
@httpretty.activate
def test_list_invoice(self):
"""Method defined to test list Invoice."""
httpretty.register_uri(
httpretty.GET,
self.endpoint_url("/paymentrequest"),
content_type='text/json',
body='{"status": true, "message": "Invoice retrieved"}',
status=201,
)
response = Invoice.list(
customer="CUS_je02lbimlqixzax",
status="pending",
currency="NGN",
paid="false",
include_archive="true"
)
self.assertTrue(response['status'])
@httpretty.activate
def test_view_invoice(self):
"""Method defined to test view Invoice."""
httpretty.register_uri(
httpretty.GET,
self.endpoint_url("/paymentrequest/PRQ_kp4lleqc7g8xckk"),
content_type='text/json',
body='{"status": true, "message": "Invoice retrieved"}',
status=201,
)
response = Invoice.view(
invoice_id_or_code="PRQ_kp4lleqc7g8xckk",
)
self.assertTrue(response['status'])
@httpretty.activate
def test_verify_invoice(self):
"""Method defined to test verify Invoice."""
httpretty.register_uri(
httpretty.GET,
self.endpoint_url("/paymentrequest/verify/PRQ_kp4lleqc7g8xckk"),
content_type='text/json',
body='{"status": true, "message": "Payment request retrieved"}',
status=201,
)
response = Invoice.verify(
invoice_code="PRQ_kp4lleqc7g8xckk",
)
self.assertTrue(response['status'])
@httpretty.activate
def test_send_notifications(self):
"""Method defined to test notifications Invoice."""
httpretty.register_uri(
httpretty.POST,
self.endpoint_url("/paymentrequest/notify/PRQ_kp4lleqc7g8xckk"),
content_type='text/json',
body='{"status": true}',
status=201,
)
response = Invoice.send_notification(
id_or_code="PRQ_kp4lleqc7g8xckk",
)
self.assertTrue(response['status'])
@httpretty.activate
def test_dashboard_metrics(self):
"""Method defined to test Invoice dashboard metrics."""
httpretty.register_uri(
httpretty.GET,
self.endpoint_url("/paymentrequest/totals"),
content_type='text/json',
body='{"status": true}',
status=201,
)
response = Invoice.dashboard_metrics()
self.assertTrue(response['status'])
@httpretty.activate
def test_finalize_draft(self):
"""Method defined to test finalize_draft Invoice."""
httpretty.register_uri(
httpretty.POST,
self.endpoint_url("/paymentrequest/finalize/PRQ_kp4lleqc7g8xckk"),
content_type='text/json',
body='{"status": true}',
status=201,
)
response = Invoice.finalize_draft(
id_or_code="PRQ_kp4lleqc7g8xckk",
send_notification=False
)
self.assertTrue(response['status'])
@httpretty.activate
def test_update(self):
"""Method defined to test Invoice update."""
httpretty.register_uri(
httpretty.PUT,
self.endpoint_url("/paymentrequest/PRQ_kp4lleqc7g8xckk"),
content_type='text/json',
body='{"status": true, "message": "Payment request updated"}',
status=201,
)
response = Invoice.update(
id_or_code="PRQ_kp4lleqc7g8xckk",
amount=450000
)
self.assertTrue(response['status'])
@httpretty.activate
def test_archive(self):
"""Method defined to test Invoice archive."""
httpretty.register_uri(
httpretty.POST,
self.endpoint_url("/invoice/archive/PRQ_kp4lleqc7g8xckk"),
content_type='text/json',
body='{"status": true, "message": "Payment request archived"}',
status=201,
)
response = Invoice.archive(
id_or_code="PRQ_kp4lleqc7g8xckk",
)
self.assertTrue(response['status'])
@httpretty.activate
def test_update_transfer_recipient(self):
"""Method defined to test Invoice archive."""
httpretty.register_uri(
httpretty.POST,
self.endpoint_url("/transferrecipient/PRQ_kp4lleqc7g8xckk"),
content_type='text/json',
body='{"status": true}',
status=201,
)
response = Invoice.update_transfer_recipient(
recipient_code_or_id="PRQ_kp4lleqc7g8xckk",
name="new name",
email="[email protected]"
)
self.assertTrue(response['status'])