Пример #1
0
    def test_user_activate(self, client, db):
        # Registers a user
        res = client.get(url_for('auth.register'), status=200)
        user = User(email="*****@*****.**", username='******')
        form = fill_register_form(res.forms['register-form'], user)
        res = form.submit().follow()

        # Registered user is not verified
        user = User.find_by_email(user.email)
        assert not user.verified

        # Activate token is created for registered user
        assert user.activate_token

        # An invalid user/token combination does not verify the user
        res = client.get(
            url_for('auth.activate', userid=user.id, activate_token="moop"))
        assert not user.verified

        # A valid user/token combination verifies the user
        res = client.get(
            url_for('auth.activate',
                    userid=user.id,
                    activate_token=user.activate_token))
        assert user.verified
Пример #2
0
    def test_register(self, client, db):
        # Go to register page
        res = client.get(url_for('auth.register'), status=200)

        # Register form successfully submits and redirects
        user = User(email="*****@*****.**", username='******')
        form = fill_register_form(res.forms['register-form'], user)
        res = form.submit().follow()

        # Register-form is no longer displayed
        assert not res.forms.get('register-form')

        # Registered user persists in the database
        assert User.find_by_email(user.email)

        # Cannot register same user twice. Register-form should still be displayed
        res = client.get(url_for('auth.register'), status=200)
        res = fill_register_form(res.forms['register-form'], user).submit()
        assert res.forms['register-form']
Пример #3
0
    def test_register(self, client, db):
        # Go to register page
        res = client.get(url_for('auth.register'), status=200)

        # Register form successfully submits and redirects
        user = User(email="*****@*****.**", username='******')
        form = fill_register_form(res.forms['register-form'], user)
        res = form.submit().follow()

        # Register-form is no longer displayed
        assert not res.forms.get('register-form')

        # Registered user persists in the database
        assert User.find_by_email(user.email)

        # Cannot register same user twice. Register-form should still be displayed
        res = client.get(url_for('auth.register'), status=200)
        res = fill_register_form(res.forms['register-form'], user).submit()
        assert res.forms['register-form']
Пример #4
0
    def test_user_activate(self, client, db):
        # Registers a user
        res = client.get(url_for('auth.register'), status=200)
        user = User(email="*****@*****.**", username='******')
        form = fill_register_form(res.forms['register-form'], user)
        res = form.submit().follow()

        # Registered user is not verified
        user = User.find_by_email(user.email)
        assert not user.verified

        # Activate token is created for registered user
        assert user.activate_token

        # An invalid user/token combination does not verify the user
        res = client.get(url_for('auth.activate', userid=user.id, activate_token="moop"))
        assert not user.verified

        # A valid user/token combination verifies the user
        res = client.get(url_for('auth.activate', userid=user.id, activate_token=user.activate_token))
        assert user.verified
Пример #5
0
 def test_find_by_email(self, db):
     email = "*****@*****.**"
     u1 = generate_user(email=email)
     u1.save()
     assert User.find_by_email(email) == u1
 def test_find_by_email(self, db):
     email = "*****@*****.**"
     u1 = generate_user(email=email)
     u1.save()
     assert User.find_by_email(email) == u1