forked from andela-sjames/paystack-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_product.py
More file actions
69 lines (58 loc) · 2.23 KB
/
test_product.py
File metadata and controls
69 lines (58 loc) · 2.23 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
import httpretty
from paystackapi.tests.base_test_case import BaseTestCase
from paystackapi.product import Product
class TestProduct(BaseTestCase):
@httpretty.activate
def test_product_create(self):
"""Method defined to test product creation."""
httpretty.register_uri(
httpretty.POST,
self.endpoint_url("/product"),
content_type='text/json',
body='{"status": true, "message": "Product successfully created"}',
status=201,
)
response = Product.create(
name="Product pypaystack test", description="my test description",
price=500000, currency="NGN"
)
self.assertTrue(response['status'])
@httpretty.activate
def test_product_list(self):
"""Method defined to test Product list."""
httpretty.register_uri(
httpretty.GET,
self.endpoint_url("/product"),
content_type='text/json',
body='{"status": true, "message": "Products retrieved", "data":[{}], "meta":{}}',
status=201,
)
response = Product.list()
self.assertEqual(response['status'], True)
@httpretty.activate
def test_product_fetch(self):
"""Method defined to test Product fetch."""
httpretty.register_uri(
httpretty.GET,
self.endpoint_url("/product/5499"),
content_type='text/json',
body='{"status": true, "message": "Products retrieved", "data":[{}]}',
status=201,
)
response = Product.fetch(product_id=5499)
self.assertEqual(response['status'], True)
@httpretty.activate
def test_product_update(self):
"""Method defined to test Product update."""
httpretty.register_uri(
httpretty.PUT,
self.endpoint_url("/product/5499"),
content_type='text/json',
body='{"status": true, "message": "Products retrieved", "data":[{}]}',
status=201,
)
response = Product.update(product_id=5499, name="Product pypaystack test",
description="my test description", price=500000000,
currency="USD"
)
self.assertEqual(response['status'], True)