def test_generate_reset_password_token(secrets_mock): secrets_mock.token_urlsafe.return_value = 'reset_token' user = User(reset_password_token=None, reset_password_token_created_at=None) user.generate_reset_password_token() assert user.reset_password_token == 'reset_token' assert user.reset_password_token_created_at
def test_reset_password(): user = User() user.generate_reset_password_token() user.reset_password(password='******') assert not user.reset_password_token assert not user.reset_password_token_created_at assert user.password == 'a-new-secret'
def test_send_reset_password_email(sendgrid_service_mock): user = User() user.generate_reset_password_token() SendResetPasswordEmail().execute(user=user) sendgrid_service_mock().send_message.assert_called_once_with( to=user.email, subject='Criar nova senha', html_content=build_html_content(user))