Esempio n. 1
0
def test_activate_expired():
    expired_date = datetime.datetime.now() - datetime.timedelta(seconds=8000)
    user = User(is_active=False)
    user.activation_token_created_at = expired_date

    with pytest.raises(ActivationExpiredError):
        user.activate()
Esempio n. 2
0
def test_activate_user_with_expired_token(get_mock):
    expired_date = datetime.datetime.now() - datetime.timedelta(seconds=8000)
    user = User()
    user.activation_token_created_at = expired_date
    get_mock.return_value = user

    with pytest.raises(ActivationExpiredError):
        ActivateUser().execute(activation_token=user.activation_token)
Esempio n. 3
0
def _build_user(**kwargs):
    now = datetime.datetime.now()

    user = User()
    user.full_name = kwargs.get('full_name', 'Antonie Russo')
    user.email = kwargs.get('email', '*****@*****.**')
    user.password = kwargs.get('password', 'a-secret')
    user.reset_password_token = kwargs.get('reset_password_token', uuid.uuid4())
    user.reset_password_token_created_at = kwargs.get('reset_password_token_created_at', now)
    user.is_active = kwargs.get('is_active', True)
    user.activation_token = kwargs.get('activation_token', uuid.uuid4())
    user.activation_token_created_at = kwargs.get('activation_token_created_at', now)
    user.save(force_insert=True)

    return user