Ejemplo n.º 1
0
# LOGIN
LOGIN_REQUEST_DICT = {"ethAddress": ETH_ADDRESS, "password": PASSWORD}
LOGIN_REQUEST_OBJECT = AuthLoginRequest(eth_address=ETH_ADDRESS, password=PASSWORD)
LOGIN_RESPONSE_DICT = {
    "jwtTokens": {"access": ACCESS_TOKEN_1, "refresh": REFRESH_TOKEN_1}
}
LOGIN_RESPONSE_OBJECT = AuthLoginResponse(
    access_token=ACCESS_TOKEN_1, refresh_token=REFRESH_TOKEN_1
)

# LOGOUT
LOGOUT_REQUEST_DICT = LOGOUT = {"global": GLOBAL_LOGOUT}
LOGOUT_REQUEST_OBJECT = AuthLogoutRequest()
LOGOUT_RESPONSE_DICT = {}
LOGOUT_RESPONSE_OBJECT = AuthLogoutResponse()

# REFRESH
REFRESH_REQUEST_PAYLOAD_DICT = {
    "jwtTokens": {"access": ACCESS_TOKEN_1, "refresh": REFRESH_TOKEN_1}
}
REFRESH_REQUEST_DICT = LOGIN_RESPONSE_DICT
REFRESH_REQUEST_OBJECT = AuthRefreshRequest(
    access_token=ACCESS_TOKEN_1, refresh_token=REFRESH_TOKEN_1
)
REFRESH_RESPONSE_DICT = LOGIN_RESPONSE_DICT
REFRESH_RESPONSE_OBJECT = AuthRefreshResponse(
    access_token=ACCESS_TOKEN_1, refresh_token=REFRESH_TOKEN_1
)

# OPENAPI
def test_auth_login_response_from_valid_json():
    resp = AuthLogoutResponse.from_json("{}")
    assert type(resp) == AuthLogoutResponse
def test_auth_login_response_from_invalid_dict():
    with pytest.raises(ValidationError):
        AuthLogoutResponse.from_dict({"foo": "bar"})
def test_auth_login_response_from_valid_dict():
    resp = AuthLogoutResponse.from_dict({})
    assert type(resp) == AuthLogoutResponse
import pytest

from mythx_models.response import AuthLogoutResponse

from .common import get_test_case

JSON_DATA, DICT_DATA = get_test_case("testdata/auth-logout-response.json")
OBJ_DATA = AuthLogoutResponse.from_json(JSON_DATA)


def test_auth_login_response_from_valid_json():
    resp = AuthLogoutResponse.from_json("{}")
    assert type(resp) == AuthLogoutResponse


# def test_auth_login_response_from_invalid_json():
#     with pytest.raises(ValidationError):
#         AuthLogoutResponse.from_json('{"foo": "bar"}')


def test_auth_login_response_from_valid_dict():
    resp = AuthLogoutResponse.from_dict({})
    assert type(resp) == AuthLogoutResponse


# def test_auth_login_response_from_invalid_dict():
#     with pytest.raises(ValidationError):
#         AuthLogoutResponse.from_dict({"foo": "bar"})


def test_auth_login_response_to_json():
def test_auth_login_response_from_valid_json():
    resp = AuthLogoutResponse()
    assert resp.dict() == {}