@@ 10-69 (lines=60) @@ | ||
7 | from paystackapi.customer import Customer |
|
8 | ||
9 | ||
10 | class TestCustomer(unittest.TestCase): |
|
11 | """Class to test customer actions.""" |
|
12 | ||
13 | @httpretty.activate |
|
14 | def test_create(self): |
|
15 | """Method defined to test customer creation.""" |
|
16 | httpretty.register_uri( |
|
17 | httpretty.POST, |
|
18 | "https://api.paystack.co/customer", |
|
19 | content_type='text/json', |
|
20 | body='{"status": true, "contributors": true}', |
|
21 | status=201, |
|
22 | ) |
|
23 | ||
24 | response = Customer.create( |
|
25 | first_name='samuel', last_name='james', |
|
26 | email='[email protected]', phone='00000000000') |
|
27 | self.assertTrue(response['status']) |
|
28 | ||
29 | @httpretty.activate |
|
30 | def test_get(self): |
|
31 | """Function defined to test Customer get method.""" |
|
32 | httpretty.register_uri( |
|
33 | httpretty.GET, |
|
34 | "https://api.paystack.co/customer/4013", |
|
35 | content_type='text/json', |
|
36 | body='{"status": true, "contributors": true}', |
|
37 | status=201, |
|
38 | ) |
|
39 | ||
40 | response = Customer.get(customer_id=4013) |
|
41 | self.assertEqual(response['status'], True) |
|
42 | ||
43 | @httpretty.activate |
|
44 | def test_list(self): |
|
45 | """Function defined to test paystackapi customer list method.""" |
|
46 | httpretty.register_uri( |
|
47 | httpretty.GET, |
|
48 | "https://api.paystack.co/customer", |
|
49 | content_type='text/json', |
|
50 | body='{"status": true, "contributors": true}', |
|
51 | status=201, |
|
52 | ) |
|
53 | ||
54 | response = Customer.list() |
|
55 | self.assertEqual(response['status'], True) |
|
56 | ||
57 | @httpretty.activate |
|
58 | def test_update(self): |
|
59 | """Function defined to test paystackapi customer update.""" |
|
60 | httpretty.register_uri( |
|
61 | httpretty.PUT, |
|
62 | "https://api.paystack.co/customer/4013", |
|
63 | content_type='text/json', |
|
64 | body='{"status": true, "contributors": true}', |
|
65 | status=201, |
|
66 | ) |
|
67 | ||
68 | response = Customer.update(customer_id=4013, first_name='andela') |
|
69 | self.assertEqual(response['status'], True) |
|
70 |
@@ 10-69 (lines=60) @@ | ||
7 | from paystackapi.plan import Plan |
|
8 | ||
9 | ||
10 | class TestPlan(unittest.TestCase): |
|
11 | """Class to test Plans.""" |
|
12 | ||
13 | @httpretty.activate |
|
14 | def test_create(self): |
|
15 | """Method defined to test plan creation.""" |
|
16 | httpretty.register_uri( |
|
17 | httpretty.POST, |
|
18 | "https://api.paystack.co/plan", |
|
19 | content_type='text/json', |
|
20 | body='{"status": true, "contributors": true}', |
|
21 | status=201, |
|
22 | ) |
|
23 | ||
24 | response = Plan.create( |
|
25 | name="John Doe", description="Payment plan for awesome people contributions", |
|
26 | amount=50000, interval="daily", send_invoices=True, ) |
|
27 | self.assertTrue(response['status']) |
|
28 | ||
29 | @httpretty.activate |
|
30 | def test_get(self): |
|
31 | """Function defined to test Plan get method.""" |
|
32 | httpretty.register_uri( |
|
33 | httpretty.GET, |
|
34 | "https://api.paystack.co/plan/78", |
|
35 | content_type='text/json', |
|
36 | body='{"status": true, "contributors": true}', |
|
37 | status=201, |
|
38 | ) |
|
39 | ||
40 | response = Plan.get(plan_id=78) |
|
41 | self.assertEqual(response['status'], True) |
|
42 | ||
43 | @httpretty.activate |
|
44 | def test_list(self): |
|
45 | """Function defined to test paystackapi plan list method.""" |
|
46 | httpretty.register_uri( |
|
47 | httpretty.GET, |
|
48 | "https://api.paystack.co/plan", |
|
49 | content_type='text/json', |
|
50 | body='{"status": true, "contributors": true}', |
|
51 | status=201, |
|
52 | ) |
|
53 | ||
54 | response = Plan.list() |
|
55 | self.assertEqual(response['status'], True) |
|
56 | ||
57 | @httpretty.activate |
|
58 | def test_update(self): |
|
59 | """Function defined to test paystackapi plan update.""" |
|
60 | httpretty.register_uri( |
|
61 | httpretty.PUT, |
|
62 | "https://api.paystack.co/plan/78", |
|
63 | content_type='text/json', |
|
64 | body='{"status": true, "contributors": true}', |
|
65 | status=201, |
|
66 | ) |
|
67 | ||
68 | response = Plan.update(plan_id=78, interval="monthly", amount=70000) |
|
69 | self.assertEqual(response['status'], True) |
|
70 |