Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_response_init(c, res):
Response(c, res)
def test_long_live_access_token(self):
if not ll_access_token is None:
preference = {
"items": [
{
"title": "sdk-python test_long_live_access_token",
"quantity": 1,
"currency_id": "ARS",
"unit_price": 10.5
}
]
}
mp = mercadopago.MP(ll_access_token)
self.assertEquals(mp.preference.create(preference)["status"], 201)
print("test_long_live_access_token OK!")
else:
print("test_long_live_access_token (NOT EXECUTED)")
def test_update_preference(self):
preference = {
"items": [
{
"title": "sdk-python",
"quantity": 1,
"currency_id": "ARS",
"unit_price": 10.5
}
]
}
mp = mercadopago.MP(client_id, client_secret)
create_preference_result = mp.preference.create(preference)
self.assertEquals(create_preference_result["status"], 201)
created_preference_id = create_preference_result["response"]["id"]
preference_update = {
"items": [
{
"title": "sdk-python rules!",
"quantity": 2,
"currency_id": "ARS",
"unit_price": 19.99
}
]
def test_get_preference(self):
preference = {
"items": [
{
"title": "sdk-python",
"quantity": 1,
"currency_id": "ARS",
"unit_price": 10.5
}
]
}
mp = mercadopago.MP(client_id, client_secret)
create_preference_result = mp.preference.create(preference)
#print(create_preference_result)
self.assertEquals(create_preference_result["status"], 201)
created_preference_id = create_preference_result["response"]["id"]
get_preference_result = mp.preference.get(created_preference_id)
self.assertEquals(get_preference_result["status"], 200)
obtained_preference = get_preference_result["response"]
self.assertEquals(obtained_preference["items"][0]["title"], "sdk-python")
def test_response_is_last_page(c, res):
res.data['paging']['total'] = 20
res.data['paging']['limit'] = 10
res.data['paging']['offset'] = 10
response = PaginatedResponse(c, res)
assert response.has_next() is False
assert response.has_prev() is True
def test_response_is_first_page(c, res):
res.data['paging']['total'] = 100
res.data['paging']['offset'] = 0
response = PaginatedResponse(c, res)
assert response.has_next() is True
assert response.has_prev() is False
def test_response_has_next_prev(c, res):
response = PaginatedResponse(c, res)
assert response.has_next() is True
assert response.has_prev() is False
def test_paginated_response_is_iterable(c, res):
response = PaginatedResponse(c, res)
assert list(iter(response)) == res.data['results']
def test_response_next(c, res):
res.data['paging']['total'] = 100
response = PaginatedResponse(c, res)
expect(c, 'GET', '/v1/payments/search', params={'offset': 10})
response.next()
def test_paginated_response_paging(c, res):
res.data['paging']['total'] = 20
res.data['paging']['limit'] = 10
res.data['paging']['offset'] = 0
response = PaginatedResponse(c, res)
assert response.total == 20
assert response.limit == 10
assert response.offset == 0