def test_user_not_login(): reset_data() A = auth_register("*****@*****.**", "wsad1990", "Good", "Morning") token = A['token'] auth_logout(token) with pytest.raises(UF.AccessError): UF.users_all(token)
def users_all(): ''' Show all users ''' token = request.args.get("token") return dumps(user.users_all(token))
def test_users_all(): ''' Shows all users ''' # Initialisation global_var.initialise_all() # Creating a user user = auth_functions.auth_register("*****@*****.**", "pass123", \ "Rayden", "Smith") token = user["token"] assert funcs.users_all(token) == { "users": [{ "u_id": 0, "email": '*****@*****.**', "name_first": 'Rayden', "name_last": 'Smith', "handle_str": 'raydensmith', "profile_img_url": 'http://*****:*****@gmail.com", "pass1234", \ "Mary", "Lamb") assert funcs.users_all(token) == { "users": [{ "u_id": 0, "email": '*****@*****.**', "name_first": 'Rayden', "name_last": 'Smith', "handle_str": 'raydensmith', "profile_img_url": 'http://*****:*****@gmail.com', "name_first": 'Mary', "name_last": 'Lamb', "handle_str": 'marylamb', "profile_img_url": 'http://localhost:5001/imgurl/server/assets/images/default.jpg' }] } # An exception occurs when token is invalid with pytest.raises(AccessError, match="Invalid token"): funcs.users_all("invalid_token")
def test_user_sucess(): reset_data() A = auth_register("*****@*****.**", "wsad1990", "Good", "Morning") token = A['token'] UF.users_all(token)
def test_invalid_token(): token = A['token'] + '10086' with pytest.raises(TF.AccessError): UF.users_all(token)
def test_invalid_tokenType(): token = None with pytest.raises(TypeError): UF.users_all(token)