Esempio n. 1
0
def test_remove():
    boyu_dict, wenyao_dict = initialise_data()
    admin_user_remove(boyu_dict['token'], wenyao_dict['u_id'])
    users_dict = users_all(boyu_dict['token'])
    assert len(users_dict['users']) == 1
    assert users_dict['users'][0]['u_id'] == boyu_dict['u_id']
    assert users_dict['users'][0]['email'] == '*****@*****.**'
    assert users_dict['users'][0]['name_first'] == 'Boyu'
    assert users_dict['users'][0]['name_last'] == 'Cai'
Esempio n. 2
0
def test_remove_token_not_valid():
    _, wenyao_dict = initialise_data()
    with pytest.raises(AccessError):
        assert admin_user_remove("invalid.token", wenyao_dict['u_id'])
Esempio n. 3
0
def test_remove_invalid_uid():
    boyu_dict, _ = initialise_data()
    with pytest.raises(InputError):
        assert admin_user_remove(boyu_dict['token'], -1)
Esempio n. 4
0
def test_remove_not_owner():
    _, wenyao_dict = initialise_data()
    with pytest.raises(AccessError):
        assert admin_user_remove(wenyao_dict['token'], wenyao_dict['u_id'])
Esempio n. 5
0
def user_delete():
    data = request.get_json()
    token = str(data["token"])
    u_id = int(data["u_id"])
    admin_user_remove(token, u_id)
    return dumps({})