|
2 | 2 | PyMango Tests for Resources |
3 | 3 | """ |
4 | 4 | import os |
| 5 | +from random import randint |
5 | 6 |
|
6 | 7 | from nose.tools import eq_, ok_, raises |
7 | 8 |
|
@@ -34,6 +35,16 @@ def _create_token(): |
34 | 35 | return token_response.get("uid") |
35 | 36 |
|
36 | 37 |
|
| 38 | +def _create_ccv(): |
| 39 | + ccv_response = mango.client.req( |
| 40 | + public_test_key, |
| 41 | + "post", |
| 42 | + "v1/ccvs/", |
| 43 | + data={"ccv": randint(100, 999)} |
| 44 | + ) |
| 45 | + return ccv_response.get("uid") |
| 46 | + |
| 47 | + |
37 | 48 | # |
38 | 49 | # Charges |
39 | 50 | # |
@@ -117,6 +128,14 @@ def test_customers_get(): |
117 | 128 | ok_(customer.get("uid")) |
118 | 129 |
|
119 | 130 |
|
| 131 | +def test_customers_update(): |
| 132 | + """Should update customer data""" |
| 133 | + sample_name = "test-pymango-{0}".format(randint(1000, 999999)) |
| 134 | + customer_uid = mango.Customers.list()[0].get("uid") |
| 135 | + ok_(mango.Customers.update(customer_uid, name=sample_name)) |
| 136 | + eq_(sample_name, mango.Customers.get(customer_uid).get("name")) |
| 137 | + |
| 138 | + |
120 | 139 | @raises(mango.error.NotFound) |
121 | 140 | def test_customers_delete(): |
122 | 141 | """Should delete a customer""" |
@@ -146,11 +165,17 @@ def test_cards_get(): |
146 | 165 | ok_(card) |
147 | 166 |
|
148 | 167 |
|
| 168 | +def test_cards_update(): |
| 169 | + """Should update card CCV""" |
| 170 | + card_uid = mango.Cards.get(mango.Cards.list()[0].get("uid")).get("uid") |
| 171 | + ok_(mango.Cards.update(card_uid, ccv=_create_ccv())) |
| 172 | + |
| 173 | + |
149 | 174 | @raises(mango.error.NotFound) |
150 | 175 | def test_cards_delete(): |
151 | 176 | """Should delete a Card""" |
152 | | - card_uid = mango.Cards.get(mango.Cards.list()[0].get("uid")) |
153 | | - ok_(mango.Cards.delete(card_uid)) |
| 177 | + card_uid = mango.Cards.get(mango.Cards.list()[0].get("uid")).get("uid") |
| 178 | + eq_(True, mango.Cards.delete(card_uid)) |
154 | 179 | mango.Cards.get(card_uid) |
155 | 180 |
|
156 | 181 |
|
|
0 commit comments