Skip to content

Commit bd866c6

Browse files
author
Juan Rossi
committed
Added Promotion Resource with Get and List with tests. Fixed Installment test.
1 parent f66c7c2 commit bd866c6

File tree

4 files changed

+36
-3
lines changed

4 files changed

+36
-3
lines changed

README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ You can also work with all the other resources authenticated with a secret API K
9191
* `Cards <https://developers.getmango.com/en/api/cards/?platform=python>`_
9292
* `Queue <https://developers.getmango.com/en/api/queue/?platform=python>`_
9393
* `Installments <https://developers.getmango.com/en/api/installments/?platform=python>`_
94+
* `Promotions <https://developers.getmango.com/en/api/promotions/?platform=python>`_
9495

9596

9697
Tests

pymango/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from resources import Card as Cards
88
from resources import Queue
99
from resources import Installment as Installments
10+
from resources import Promotion as Promotions
1011

1112
api_key = ""
1213
version = 1
13-

pymango/resources.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,9 @@ class Queue(GetableResource, ListableResource, ResourceDeletable, ResourceDeleta
138138

139139
class Installment(ListableResource, Resource):
140140
"""Mango Installment resource"""
141-
name = "installments"
141+
name = "installments"
142+
143+
144+
class Promotion(GetableResource, ListableResource, Resource):
145+
"""Mango Promotion resource"""
146+
name = "promotions"

pymango/tests/tests_resources.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def test_queue_delete_all():
219219
#
220220
def test_installments_list():
221221
"""Should return a list of queued resources"""
222-
eq_(list, type(mango.Queue.list()))
222+
eq_(list, type(mango.Installments.list()))
223223

224224

225225
def test_installments_list_filters():
@@ -228,3 +228,30 @@ def test_installments_list_filters():
228228
for installment in installments:
229229
eq_("visa", installment.get("cardtype"))
230230
eq_(5000, installment.get("amount"))
231+
232+
233+
#
234+
# Promotions
235+
#
236+
def test_promotions_list():
237+
"""Should return a list of promotion resources"""
238+
eq_(list, type(mango.Promotions.list()))
239+
240+
241+
def test_promotions_list_filters():
242+
"""Should return a filtered list of promotions resources"""
243+
promotions = mango.Promotions.list(status="active")
244+
for promotion in promotions:
245+
eq_("active", promotion.get("status"))
246+
ok_(promotion.get("name"))
247+
ok_(promotion.get("valid_to"))
248+
ok_(promotion.get("valid_from"))
249+
250+
251+
def test_promotions_get_item():
252+
"""Should return a single promotion resource"""
253+
promotion_uid = mango.Promotions.list(status="active")[0].get("uid")
254+
promotion = mango.Promotions.get(promotion_uid)
255+
ok_(promotion)
256+
eq_(promotion_uid, promotion.get("uid"))
257+
eq_("active", promotion.get("status"))

0 commit comments

Comments
 (0)