示例#1
0
def test_generate_activation(secrets_mock):
    secrets_mock.token_urlsafe.return_value = 'token'
    user = User()

    user.generate_activation()

    assert user.activation_token == 'token'
    assert user.activation_token_created_at
示例#2
0
def test_activate():
    user = User(is_active=False)
    user.generate_activation()

    user.activate()

    assert user.is_active
    assert not user.activation_token
    assert not user.activation_token_created_at
示例#3
0
def test_activate_user_success(get_mock, save_mock):
    user = User()
    user.generate_activation()
    get_mock.return_value = user

    ActivateUser().execute(activation_token=user.activation_token)

    assert user.is_active
    assert not user.activation_token
    assert not user.activation_token_created_at
    assert save_mock.call_count == 1
示例#4
0
    def execute(self, params):
        hashed_password = self.__authentication_service.hash_password(
            password=params.get('password'))

        user = User()
        user.full_name = params.get('full_name')
        user.email = params.get('email')
        user.password = hashed_password
        user.generate_activation()
        user.save(force_insert=True)

        return user
示例#5
0
def test_send_activation_email(sendgrid_service_mock):
    user = User()
    user.generate_activation()

    SendActivationEmail().execute(
        user=user
    )

    sendgrid_service_mock().send_message.assert_called_once_with(
        to=user.email,
        subject='Confirme seu e-mail',
        html_content=build_html_content(user)
    )