Exemplo n.º 1
0
    class _UserForm(formencode.Schema):
        allow_extra_fields = True
        filter_extra_fields = True
        username = All(v.UnicodeString(strip=True, min=1, not_empty=True),
                       v.ValidUsername(edit, old_data))
        if edit:
            new_password = All(
                v.ValidPassword(),
                v.UnicodeString(strip=False, min=6, not_empty=False))
            password_confirmation = All(
                v.ValidPassword(),
                v.UnicodeString(strip=False, min=6, not_empty=False),
            )
            admin = v.StringBoolean(if_missing=False)
        else:
            password = All(v.ValidPassword(),
                           v.UnicodeString(strip=False, min=6, not_empty=True))
            password_confirmation = All(
                v.ValidPassword(),
                v.UnicodeString(strip=False, min=6, not_empty=False))

        active = v.StringBoolean(if_missing=False)
        firstname = v.UnicodeString(strip=True, min=1, not_empty=False)
        lastname = v.UnicodeString(strip=True, min=1, not_empty=False)
        email = All(v.Email(not_empty=True), v.UniqSystemEmail(old_data))

        chained_validators = [v.ValidPasswordsMatch()]
def test_UniqSystemEmail():
    validator = v.UniqSystemEmail(old_data={})

    assert '*****@*****.**' == validator.to_python('*****@*****.**')

    email = TEST_USER_REGULAR2_EMAIL
    pytest.raises(formencode.Invalid, validator.to_python, email)
Exemplo n.º 3
0
    class _UserForm(formencode.Schema):
        allow_extra_fields = True
        filter_extra_fields = True
        username = All(v.UnicodeString(strip=True, min=1, not_empty=True),
                       v.ValidUsername(edit, old_data))
        if edit:
            new_password = All(
                v.ValidPassword(),
                v.UnicodeString(strip=False, min=6, not_empty=False))
            password_confirmation = All(
                v.ValidPassword(),
                v.UnicodeString(strip=False, min=6, not_empty=False),
            )
            admin = v.StringBoolean(if_missing=False)
        else:
            password = All(v.ValidPassword(),
                           v.UnicodeString(strip=False, min=6, not_empty=True))
            password_confirmation = All(
                v.ValidPassword(),
                v.UnicodeString(strip=False, min=6, not_empty=False))

        password_change = v.StringBoolean(if_missing=False)
        create_repo_group = v.StringBoolean(if_missing=False)

        active = v.StringBoolean(if_missing=False)
        firstname = v.UnicodeString(strip=True, min=1, not_empty=False)
        lastname = v.UnicodeString(strip=True, min=1, not_empty=False)
        email = All(v.Email(not_empty=True), v.UniqSystemEmail(old_data))
        extern_name = v.UnicodeString(strip=True)
        extern_type = v.UnicodeString(strip=True)
        language = v.OneOf(available_languages,
                           hideList=False,
                           testValueList=True,
                           if_missing=None)
        chained_validators = [v.ValidPasswordsMatch()]
Exemplo n.º 4
0
    def test_UniqSystemEmail(self):
        validator = v.UniqSystemEmail(old_data={})

        self.assertEqual('*****@*****.**',
                         validator.to_python('*****@*****.**'))

        email = TEST_USER_REGULAR2_EMAIL
        self.assertRaises(formencode.Invalid, validator.to_python, email)
Exemplo n.º 5
0
 def test_register_err_same_email_case_sensitive(self):
     response = self.app.post(
         url(controller='login', action='register'), {
             'username': '******',
             'password': '******',
             'password_confirmation': 'test12',
             'email': '*****@*****.**',
             'firstname': 'test',
             'lastname': 'test'
         })
     msg = validators.UniqSystemEmail()()._messages['email_taken']
     response.mustcontain(msg)
Exemplo n.º 6
0
 def test_register_err_same_email_case_sensitive(self):
     response = self.app.post(
         register_url, {
             'username': '******',
             'password': '******',
             'password_confirmation': 'test12',
             'email': '*****@*****.**',
             'firstname': 'test',
             'lastname': 'test'
         })
     assertr = AssertResponse(response)
     msg = validators.UniqSystemEmail()()._messages['email_taken']
     assertr.element_contains('#email+.error-message', msg)
Exemplo n.º 7
0
 class _UserExtraEmailForm(formencode.Schema):
     email = All(v.UniqSystemEmail(), v.Email(not_empty=True))