forked from mercadopago/sdk-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_merchant_order.py
More file actions
69 lines (60 loc) · 2.33 KB
/
test_merchant_order.py
File metadata and controls
69 lines (60 loc) · 2.33 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
"""
Module: test_merchant_order
"""
import sys
sys.path.append("../")
import unittest #pylint: disable=wrong-import-position
import uuid #pylint: disable=wrong-import-position
import mercadopago #pylint: disable=wrong-import-position
class TestMerchantOrder(unittest.TestCase):
"""
Test Module: Merchant Order
"""
sdk = mercadopago.SDK(
"APP_USR-558881221729581-091712-44fdc612e60e3e638775d8b4003edd51-471763966")
def test_all(self):
"""
Test Function: Merchant Order
"""
preference_object = {
"items": [
{
"description": "Test Update Success",
"id": "5678",
"picture_url": "http://product1.image.png",
"quantity": 1,
"title": "Item 1",
"currency_id": "R$",
"unit_price": 20.5
}
]
}
preference_saved = self.sdk.preference().create(preference_object)
merchant_order_object = {
"preference_id": preference_saved["response"]["id"],
"site_id": "MLB",
"notification_url": "https://seller/notification",
"additional_info": "Aditional info",
"external_reference": str(uuid.uuid4().int),
"marketplace": "NONE",
"items": [ {
"description": "Test Update Success",
"id": "5678",
"picture_url": "http://product1.image.png",
"quantity": 1,
"title": "Item 1",
"currency_id": "BRL",
"unit_price": 20.5
} ]
}
merchant_order_created = self.sdk.merchant_order().create(merchant_order_object)
self.assertEqual(merchant_order_created["status"], 201)
merchant_order_updated = self.sdk.merchant_order().update(
merchant_order_created["response"]["id"], {"additional_info": "Info 2"})
self.assertEqual(merchant_order_updated["status"], 200)
merchant_order_finded = self.sdk.merchant_order().get(
merchant_order_created["response"]["id"])
self.assertEqual(merchant_order_finded["status"], 200)
self.assertEqual(merchant_order_finded["response"]["additional_info"], "Info 2")
if __name__ == "__main__":
unittest.main()