示例#1
0
 def test_create_user_0_char_password(self):
     form = CreateAccountForm(data={
         'username': '******',
         'email_address': '*****@*****.**',
         'password1': '',
         'password2': ''
     })
     self.assertFalse(form.is_valid())
示例#2
0
 def test_create_user_9999999_char_name(self):
     form = CreateAccountForm(data={
         'username': '******' * 9999999,
         'email_address': '*****@*****.**',
         'password1': 'testpassword',
         'password2': 'testpassword'
     })
     self.assertFalse(form.is_valid())
示例#3
0
 def test_create_user_9999999_char_name(self):
     form = CreateAccountForm(
         data={
             'username': '******' * 9999999,
             'email_address': '*****@*****.**',
             'password1': 'testpassword',
             'password2': 'testpassword'
         })
     self.assertFalse(form.is_valid())
示例#4
0
 def test_create_user_31_char_password(self):
     form = CreateAccountForm(
         data={
             'username': '******',
             'email_address': '*****@*****.**',
             'password1': 'a' * 31,
             'password2': 'a' * 31
         })
     self.assertFalse(form.is_valid())
示例#5
0
 def test_create_user_30_char_name(self):
     form = CreateAccountForm(data={
         'username': '******' * 30,
         'email_address': '*****@*****.**',
         'password1': 'testpassword',
         'password2': 'testpassword'
     })
     self.assertTrue(form.is_valid())
     form.save()
示例#6
0
 def test_create_user_30_char_name(self):
     form = CreateAccountForm(
         data={
             'username': '******' * 30,
             'email_address': '*****@*****.**',
             'password1': 'testpassword',
             'password2': 'testpassword'
         })
     self.assertTrue(form.is_valid())
     form.save()
示例#7
0
def authentication_info(request):
    '''
    This context processor adds all the user info into the page that is needed for the
    login form and signup form that appear in the header of every page, as well as other
    basic information about the state of the current user.

    This way the code is DRY-er: we don't need to copy these fields into every page handler.
    '''
    profile = Profile.get(request.user)
    return {
        'login_form':
        AuthenticationForm(),
        'signup_form':
        CreateAccountForm(),
        'username':
        request.user.username,
        'is_authenticated':
        request.user.is_active and request.user.is_authenticated(),
        'is_admin':
        profile.user.is_superuser if profile is not None else None
    }