Ejemplo n.º 1
0
def test_user_login_200(rf, users_context):
    data = {
        "username": users_context.get('init_username'),
        "password": users_context.get('init_password'),
    }
    url = reverse(viewname="users-login")
    response = pytest_request(rf, method='put', url=url, user=None, data=data)

    assert response.status_code == status.HTTP_200_OK
Ejemplo n.º 2
0
def test_user_logout_204(rf, users_context):
    data = {'uuid': users_context.get('session').uuid}
    url = reverse(viewname="users-logout")
    response = pytest_request(rf,
                              method='delete',
                              url=url,
                              user=None,
                              data=data)

    assert response.status_code == status.HTTP_200_OK
Ejemplo n.º 3
0
def test_user_create_400(rf, users_context):
    data = {
        "username": users_context.get('user').username,
        "password": "******",
        "name": "엔라이즈"
    }
    url = reverse(viewname="users-list")
    response = pytest_request(rf, method='post', url=url, user=None, data=data)

    assert response.status_code == status.HTTP_400_BAD_REQUEST
Ejemplo n.º 4
0
def test_user_delete_204(rf, users_context):
    user_id = users_context.get('user').id
    data = {'uuid': users_context.get('session').uuid}
    url = reverse(viewname="users-detail", kwargs={'pk': user_id})
    response = pytest_request(rf,
                              method='delete',
                              url=url,
                              user=None,
                              data=data)

    assert response.status_code == status.HTTP_204_NO_CONTENT
Ejemplo n.º 5
0
def test_user_logout_403(rf, users_context):
    data = {'uuid': users_context.get('session').uuid}
    session = users_context.get('session')
    session.last_logout = datetime.now()
    session.save(update_fields=['last_logout'])

    url = reverse(viewname="users-logout")
    response = pytest_request(rf,
                              method='delete',
                              url=url,
                              user=None,
                              data=data)

    assert response.status_code == status.HTTP_403_FORBIDDEN
Ejemplo n.º 6
0
def test_user_name_check_200(rf, users_context):
    data = {'username': '******'}
    url = reverse(viewname="users-check")
    response = pytest_request(rf, method='get', url=url, user=None, data=data)

    assert response.status_code == status.HTTP_200_OK
Ejemplo n.º 7
0
def test_user_session_200(rf, users_context):
    user_id = users_context.get('user').id
    url = reverse(viewname="users-sessions", kwargs={'pk': user_id})
    response = pytest_request(rf, method='get', url=url, user=None)

    assert response.status_code == status.HTTP_200_OK
Ejemplo n.º 8
0
def test_user_create_201(rf, users_context):
    data = {"username": "******", "password": "******", "name": "엔라이즈"}
    url = reverse(viewname="users-list")
    response = pytest_request(rf, method='post', url=url, user=None, data=data)

    assert response.status_code == status.HTTP_201_CREATED
Ejemplo n.º 9
0
def test_user_name_check_400(rf, users_context):
    data = {'username': users_context.get('user').username}
    url = reverse(viewname="users-check")
    response = pytest_request(rf, method='get', url=url, user=None, data=data)

    assert response.status_code == status.HTTP_400_BAD_REQUEST