コード例 #1
0
ファイル: forms.py プロジェクト: t-kenji/kallithea-mirror
    class _LoginForm(formencode.Schema):
        allow_extra_fields = True
        filter_extra_fields = True
        username = v.UnicodeString(
            strip=True,
            min=1,
            not_empty=True,
            messages={
                'empty': _('Please enter a login'),
                'tooShort': _('Enter a value %(min)i characters long or more')
            })

        password = v.UnicodeString(strip=False,
                                   min=3,
                                   not_empty=True,
                                   messages={
                                       'empty':
                                       _('Please enter a password'),
                                       'tooShort':
                                       _('Enter %(min)i characters or more')
                                   })

        remember = v.StringBoolean(if_missing=False)

        chained_validators = [v.ValidAuth()]
コード例 #2
0
 def test_ValidAuth(self):
     validator = v.ValidAuth()
     valid_creds = {
         'username': base.TEST_USER_REGULAR2_LOGIN,
         'password': base.TEST_USER_REGULAR2_PASS,
     }
     invalid_creds = {
         'username': '******',
         'password': '******',
     }
     assert valid_creds == validator.to_python(valid_creds)
     with pytest.raises(formencode.Invalid):
         validator.to_python(invalid_creds)
コード例 #3
0
 def test_ValidAuth(self):
     validator = v.ValidAuth()
     valid_creds = {
         'username': TEST_USER_REGULAR2_LOGIN,
         'password': TEST_USER_REGULAR2_PASS,
     }
     invalid_creds = {
         'username': '******',
         'password': '******',
     }
     self.assertEqual(valid_creds, validator.to_python(valid_creds))
     self.assertRaises(formencode.Invalid,
                       validator.to_python, invalid_creds)