Skip to content

Commit f66c7c2

Browse files
committed
Merge pull request #3 from atarantini/master
Tests: Update Customer and Card data. Documentation: Use code-block for better syntax highlight.
2 parents a589572 + 329473f commit f66c7c2

File tree

2 files changed

+36
-5
lines changed

2 files changed

+36
-5
lines changed

README.rst

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ Documentation is available at https://developers.getmango.com/en/api/?platform=p
2424
Usage
2525
=====
2626

27-
Import the library and set your secret API key::
27+
Import the library and set your secret API key:
28+
29+
.. code-block:: python
2830
2931
>>> import pymango as mango
3032
>>> mango.api_key = "your Mango secret API key"
@@ -34,7 +36,9 @@ Create a charge
3436
---------------
3537

3638
In order to create a Charge, you must call the ``create()`` method with
37-
the required arguments (see `API documentation <https://developers.getmango.com/en/api/charges/?platform=python#arguments>`_)::
39+
the required arguments (see `API documentation <https://developers.getmango.com/en/api/charges/?platform=python#arguments>`_):
40+
41+
.. code-block:: python
3842
3943
>>> charge = mango.Charges.create(amount=2000, email="[email protected]", token="token_mwhushs06o62aruq9n3pmvu7f0ia696y")
4044
>>> print charge.get("uid")
@@ -46,7 +50,9 @@ the required arguments (see `API documentation <https://developers.getmango.com/
4650
Get single Charge
4751
-----------------
4852

49-
When you have a Charge ``uid``, you can get a full detail using the ``get()`` method::
53+
When you have a Charge ``uid``, you can get a full detail using the ``get()`` method:
54+
55+
.. code-block:: python
5056
5157
>>> mango.Charges.get("charge_72t1r7vmb9pknrl4otg6xy3wrkwrrpzt")
5258
{

pymango/tests/tests_resources.py

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
PyMango Tests for Resources
33
"""
44
import os
5+
from random import randint
56

67
from nose.tools import eq_, ok_, raises
78

@@ -34,6 +35,16 @@ def _create_token():
3435
return token_response.get("uid")
3536

3637

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+
3748
#
3849
# Charges
3950
#
@@ -117,6 +128,14 @@ def test_customers_get():
117128
ok_(customer.get("uid"))
118129

119130

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+
120139
@raises(mango.error.NotFound)
121140
def test_customers_delete():
122141
"""Should delete a customer"""
@@ -146,11 +165,17 @@ def test_cards_get():
146165
ok_(card)
147166

148167

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+
149174
@raises(mango.error.NotFound)
150175
def test_cards_delete():
151176
"""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))
154179
mango.Cards.get(card_uid)
155180

156181

0 commit comments

Comments
 (0)