def test_incorrect_method(): h = User.hash_password('somepassword') h = h.replace('sha512'.encode('utf-8'), 'bb'.encode('utf-8')) u = User({'username': '', 'password': h}) with pytest.raises(Exception): u.check_password('aaa')
def test_check_password_incorrect(): h = User.hash_password('somepassword') u = User({'username': '', 'password': h}) assert not u.check_password('incorrect'), 'Password check failed'
def test_check_password_success(): h = User.hash_password('somepassword') u = User({'username': '', 'password': h}) assert u.check_password('somepassword'), 'Password check failed'