# Path: pagarme/payment_link.py
# def cancel(payment_link_id):
# def create(dictionary):
# def find_all():
# def find_by(search_params):
# def find_by_id(payment_link_id):
# def update_by_id(payment_link_id, dictionary):
# 
# Path: tests/resources/dictionaries/payment_link_dictionary.py
# VALID_PAYMENT_LINK = {
#     'amount': 1000,
#     'items': [
#         {
#             'id': '1',
#             'title': 'Bola de futebol',
#             'unit_price': 400,
#             'quantity': 1,
#             'tangible': True
#         },
#         {
#             'id': 'a123',
#             'title': 'Caderno do Goku',
#             'unit_price': 600,
#             'quantity': 1,
#             'tangible': True
#         }
#     ]
# }
# INVALID_REQUEST = {
#     'amount': '1'
# }
# UPDATE_NAME = {
#     'name': 'aqueles pique link pago'
# }


from pagarme import payment_link
from tests.resources.dictionaries import payment_link_dictionary
import pytest
import time

def test_cancel_payment_link():
    pl = payment_link.create(payment_link_dictionary.VALID_PAYMENT_LINK)
    cancel_payment_link = payment_link.cancel(pl['id'])
    assert 'canceled' == cancel_payment_link['status']

def test_create_payment_link():
    pl = payment_link.create(payment_link_dictionary.VALID_PAYMENT_LINK)
    assert pl['id'] is not None

def test_error_request():
    with pytest.raises(Exception) as PagarMeException:
        payment_link.create(payment_link_dictionary.INVALID_REQUEST)
    assert 'amount' in str(PagarMeException.value)

def test_find_all_payment_links():

# Path: pagarme/payment_link.py
# def cancel(payment_link_id):
# def create(dictionary):
# def find_all():
# def find_by(search_params):
# def find_by_id(payment_link_id):
# def update_by_id(payment_link_id, dictionary):
# 
# Path: tests/resources/dictionaries/payment_link_dictionary.py
# VALID_PAYMENT_LINK = {
#     'amount': 1000,
#     'items': [
#         {
#             'id': '1',
#             'title': 'Bola de futebol',
#             'unit_price': 400,
#             'quantity': 1,
#             'tangible': True
#         },
#         {
#             'id': 'a123',
#             'title': 'Caderno do Goku',
#             'unit_price': 600,
#             'quantity': 1,
#             'tangible': True
#         }
#     ]
# }
# INVALID_REQUEST = {
#     'amount': '1'
# }
# UPDATE_NAME = {
#     'name': 'aqueles pique link pago'
# }


# Path: tests/payment_link_test.py
from pagarme import payment_link
from tests.resources.dictionaries import payment_link_dictionary
import pytest
import time


def test_cancel_payment_link():
    pl = payment_link.create(payment_link_dictionary.VALID_PAYMENT_LINK)
    cancel_payment_link = payment_link.cancel(pl['id'])
    assert 'canceled' == cancel_payment_link['status']

def test_create_payment_link():
    pl = payment_link.create(payment_link_dictionary.VALID_PAYMENT_LINK)
    assert pl['id'] is not None

def test_error_request():
    with pytest.raises(Exception) as PagarMeException:
        payment_link.create(payment_link_dictionary.INVALID_REQUEST)
    assert 'amount' in str(PagarMeException.value)

def test_find_all_payment_links():

    all_payment_links = payment_link.find_all()