File: test_customer.py

package info (click to toggle)
python-mercadopago 2.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,104 kB
  • sloc: python: 2,191; makefile: 4
file content (51 lines) | stat: -rw-r--r-- 1,490 bytes parent folder | download
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
"""
    Module: test_customer
"""
import os
import random
import unittest
import mercadopago


class TestCustomer(unittest.TestCase):
    """
    Test Module: Customer
    """
    sdk = mercadopago.SDK(os.environ['ACCESS_TOKEN'])

    def test_all(self):
        """
        Test Function: Customer
        """
        random_email_id = random.randint(100000, 999999)
        customer_object = {
            "email": f"test_payer_{random_email_id}@testuser.com",
            "first_name": "Katniss",
            "last_name": "Everdeen",
            "phone": {
                "area_code": "03492",
                "number": "432334"
            },
            "identification": {
                "type": "DNI",
                "number": "29804555"
            },
            "description": "customer description"
        }

        customer_saved = self.sdk.customer().create(customer_object)
        self.assertEqual(201, customer_saved["status"])

        customer_update = self.sdk.customer().update(
            customer_saved["response"]["id"], {"last_name": "Payer"})
        self.assertEqual(200, customer_update["status"])

        customer_updated = self.sdk.customer().get(customer_saved["response"]["id"])
        self.assertEqual(customer_updated["response"]["last_name"], "Payer")

        customer_deleted = self.sdk.customer().delete(customer_saved["response"]["id"])
        self.assertEqual(200, customer_deleted["status"])


if __name__ == "__main__":
    unittest.main()