import pytest

import konviva
from config import KONVIVA_API_URL


def test_konviva_token():
    token = konviva.token('sergio@somosbeta.com.br')

    assert isinstance(token, konviva.KonvivaToken)

    redirect_uri = konviva.redirect_uri(token)
    assert KONVIVA_API_URL in redirect_uri


def test_konviva_token_error():
    with pytest.raises(konviva.KonvivaError):
        konviva.token('sergio@doesnotexist.com')
