def test_remove_user(new_user, new_user_2): glob_users = get_users() channel = channels_create(new_user['token'], "new_channel", False) channel_invite(new_user['token'], channel['channel_id'], new_user_2['u_id']) user_remove(new_user['token'], new_user_2['u_id']) assert not new_user_2 in get_channels()[channel['channel_id']]['members'] with pytest.raises(InputError): auth_login(glob_users[new_user_2['u_id']]['email'], glob_users[new_user_2['u_id']]['password_hash'])
def test_login_email_invalid(): """Tests that logging in throws an input error when a invalid email is used""" with pytest.raises(InputError): assert auth_login('1234', 'password') with pytest.raises(InputError): assert auth_login('@unsw.edu.au', 'password') with pytest.raises(InputError): assert auth_login('username', 'password') with pytest.raises(InputError): assert auth_login('', 'password')
def test_login_valid_credentials(): """Tests logging in with valid information returns a dictionary described in the spec""" new_user = auth_register('*****@*****.**', 'password', 'placeholder_first_name', 'placeholder_last_name') login = auth_login('*****@*****.**', 'password') assert isinstance(login, dict) assert 'u_id' in login assert isinstance(login['u_id'], int) assert 'token' in login assert isinstance(login['token'], str) assert login['u_id'] == new_user['u_id']
def auth_login_wsgi(): json = request.get_json() return jsonify(auth_login(json['email'], json['password']))
def test_login_no_user_found(): """Tests that logging in throws an error when no account exists with that email""" with pytest.raises(InputError): auth_login('*****@*****.**', 'password')
def test_login_password_incorrect(): """Tests that logging in throws an error when the password is incorrect""" auth_register('*****@*****.**', 'password', 'placeholder_first_name', 'placeholder_last_name') with pytest.raises(InputError): auth_login('*****@*****.**', 'incorrect password')