2007-07-29 02:30:40 +08:00
|
|
|
"""
|
2007-09-16 02:01:29 +08:00
|
|
|
>>> from models import User, AnonymousUser
|
2007-07-29 02:30:40 +08:00
|
|
|
>>> u = User.objects.create_user('testuser', 'test@example.com', 'testpw')
|
|
|
|
>>> u.has_usable_password()
|
|
|
|
True
|
|
|
|
>>> u.check_password('bad')
|
|
|
|
False
|
|
|
|
>>> u.check_password('testpw')
|
|
|
|
True
|
|
|
|
>>> u.set_unusable_password()
|
|
|
|
>>> u.save()
|
|
|
|
>>> u.check_password('testpw')
|
|
|
|
False
|
|
|
|
>>> u.has_usable_password()
|
|
|
|
False
|
|
|
|
>>> u2 = User.objects.create_user('testuser2', 'test2@example.com')
|
|
|
|
>>> u2.has_usable_password()
|
|
|
|
False
|
2007-12-11 14:37:07 +08:00
|
|
|
|
|
|
|
>>> u.is_authenticated()
|
|
|
|
True
|
|
|
|
>>> u.is_staff
|
|
|
|
False
|
|
|
|
>>> u.is_active
|
|
|
|
True
|
|
|
|
|
2007-09-16 02:01:29 +08:00
|
|
|
>>> a = AnonymousUser()
|
2007-12-11 14:37:07 +08:00
|
|
|
>>> a.is_authenticated()
|
|
|
|
False
|
2007-09-16 02:01:29 +08:00
|
|
|
>>> a.is_staff
|
|
|
|
False
|
2007-12-11 14:37:07 +08:00
|
|
|
>>> a.is_active
|
|
|
|
False
|
2007-09-16 02:01:29 +08:00
|
|
|
>>> a.groups.all()
|
|
|
|
[]
|
|
|
|
>>> a.user_permissions.all()
|
|
|
|
[]
|
2007-07-29 02:30:40 +08:00
|
|
|
"""
|