Exemple #1
0
    def test_profile_form_nickname(self):
        """Test ProfileForm nickname."""
        from invenio_accounts.forms import ProfileForm
        from flask_login import login_user, logout_user
        from invenio.ext.login import UserInfo

        form = ProfileForm(nickname=self.nickname,
                           email=self.email,
                           repeat_email=self.email)
        assert form.validate() is False

        form = ProfileForm(nickname=" nickname",
                           email=self.email,
                           repeat_email=self.email)
        assert form.validate() is False

        form = ProfileForm(nickname="nickname ",
                           email=self.email,
                           repeat_email=self.email)
        assert form.validate() is False

        form = ProfileForm(nickname="nick.name",
                           email=self.email,
                           repeat_email=self.email)
        assert form.validate() is False

        form = ProfileForm(nickname="nick@name",
                           email=self.email,
                           repeat_email=self.email)
        assert form.validate() is False

        form = ProfileForm(nickname="*****@*****.**",
                           email=self.email,
                           repeat_email=self.email)
        assert form.validate() is False

        form = ProfileForm(nickname="guest",
                           email=self.email,
                           repeat_email=self.email)
        assert form.validate() is False

        form = ProfileForm(nickname="Guest",
                           email=self.email,
                           repeat_email=self.email)
        assert form.validate() is False

        login_user(UserInfo(self.user.id))
        form = ProfileForm(nickname=self.nickname,
                           email=self.email,
                           repeat_email=self.email)
        assert form.validate() is True

        self.delete_objects([self.user])
        form = ProfileForm(nickname=self.nickname,
                           email=self.email,
                           repeat_email=self.email)
        assert form.validate() is True

        logout_user()
Exemple #2
0
    def test_profile_form_repeat_email(self):
        """Test ProfileForm repeat email."""
        from invenio_accounts.forms import ProfileForm

        self.delete_objects([self.user])

        form = ProfileForm(
            nickname=self.nickname,
            email=self.email,
            repeat_email=self.email + 'fuu',
        )
        assert form.validate() is False

        form = ProfileForm(
            nickname=self.nickname,
            email=self.email,
            repeat_email=self.email,
        )
        assert form.validate() is True
    def test_profile_form_repeat_email(self):
        """Test ProfileForm repeat email."""
        from invenio_accounts.forms import ProfileForm

        self.delete_objects([self.user])

        form = ProfileForm(
            nickname=self.nickname,
            email=self.email,
            repeat_email=self.email + 'fuu',
        )
        assert form.validate() is False

        form = ProfileForm(
            nickname=self.nickname,
            email=self.email,
            repeat_email=self.email,
        )
        assert form.validate() is True
Exemple #4
0
    def test_profile_form_email(self):
        """Test ProfileForm email."""
        from invenio_accounts.forms import ProfileForm

        form = ProfileForm(
            nickname=self.nickname,
            email="not-email",
            repeat_email="not-email",
        )
        assert form.validate() is False

        form = ProfileForm(nickname=self.nickname,
                           email="not@email",
                           repeat_email="not@email")
        assert form.validate() is False

        form = ProfileForm(nickname=self.nickname,
                           email="*****@*****.**",
                           repeat_email="*****@*****.**")
        assert form.validate() is False

        form = ProfileForm(nickname=self.nickname, email="", repeat_email="")
        assert form.validate() is False

        form = ProfileForm(nickname=self.nickname,
                           email=self.email,
                           repeat_email=self.email)
        assert form.validate() is False

        self.delete_objects([self.user])
        form = ProfileForm(nickname=self.nickname,
                           email=self.email,
                           repeat_email=self.email)
        assert form.validate() is True
    def test_profile_form_email(self):
        """Test ProfileForm email."""
        from invenio_accounts.forms import ProfileForm

        form = ProfileForm(
            nickname=self.nickname,
            email="not-email",
            repeat_email="not-email",
        )
        assert form.validate() is False

        form = ProfileForm(
            nickname=self.nickname,
            email="not@email",
            repeat_email="not@email"
        )
        assert form.validate() is False

        form = ProfileForm(
            nickname=self.nickname,
            email="*****@*****.**",
            repeat_email="*****@*****.**"
        )
        assert form.validate() is False

        form = ProfileForm(
            nickname=self.nickname,
            email="",
            repeat_email=""
        )
        assert form.validate() is False

        form = ProfileForm(
            nickname=self.nickname,
            email=self.email,
            repeat_email=self.email
        )
        assert form.validate() is False

        self.delete_objects([self.user])
        form = ProfileForm(
            nickname=self.nickname,
            email=self.email,
            repeat_email=self.email
        )
        assert form.validate() is True
    def test_profile_form_nickname(self):
        """Test ProfileForm nickname."""
        from invenio_accounts.forms import ProfileForm
        from flask_login import login_user, logout_user
        from invenio_ext.login import UserInfo

        form = ProfileForm(
            nickname=self.nickname,
            email=self.email,
            repeat_email=self.email
        )
        assert form.validate() is False

        form = ProfileForm(
            nickname=" nickname",
            email=self.email,
            repeat_email=self.email
        )
        assert form.validate() is False

        form = ProfileForm(
            nickname="nickname ",
            email=self.email,
            repeat_email=self.email
        )
        assert form.validate() is False

        form = ProfileForm(
            nickname="nick.name",
            email=self.email,
            repeat_email=self.email
        )
        assert form.validate() is False

        form = ProfileForm(
            nickname="nick@name",
            email=self.email,
            repeat_email=self.email
        )
        assert form.validate() is False

        form = ProfileForm(
            nickname="*****@*****.**",
            email=self.email,
            repeat_email=self.email
        )
        assert form.validate() is False

        form = ProfileForm(
            nickname="guest",
            email=self.email,
            repeat_email=self.email
        )
        assert form.validate() is False

        form = ProfileForm(
            nickname="Guest",
            email=self.email,
            repeat_email=self.email
        )
        assert form.validate() is False

        login_user(UserInfo(self.user.id))
        form = ProfileForm(
            nickname=self.nickname,
            email=self.email,
            repeat_email=self.email
        )
        assert form.validate() is True

        self.delete_objects([self.user])
        form = ProfileForm(
            nickname=self.nickname,
            email=self.email,
            repeat_email=self.email
        )
        assert form.validate() is True

        logout_user()