mirror of
https://github.com/jazzband/django-avatar.git
synced 2026-03-16 22:20:30 +00:00
Test get_primary_avatar behaviour
Signed-off-by: Jannis Leidel <jannis@leidel.info>
This commit is contained in:
parent
c431bf9bf8
commit
1aa882d4d6
1 changed files with 7 additions and 0 deletions
|
|
@ -8,6 +8,7 @@ from django.conf import settings
|
|||
from django.contrib.auth.models import User
|
||||
|
||||
from avatar import AVATAR_DEFAULT_URL
|
||||
from avatar.util import get_primary_avatar
|
||||
|
||||
try:
|
||||
from PIL import Image
|
||||
|
|
@ -43,6 +44,8 @@ class AvatarUploadTests(TestCase):
|
|||
f.close()
|
||||
self.failUnlessEqual(response.status_code, 200)
|
||||
self.failUnlessEqual(response.context['upload_avatar_form'].errors, {})
|
||||
avatar = get_primary_avatar(self.user)
|
||||
self.failIfEqual(avatar, None)
|
||||
|
||||
def testImageWithoutExtension(self):
|
||||
f = open(os.path.join(self.testdatapath,"imagefilewithoutext"), "rb")
|
||||
|
|
@ -82,6 +85,10 @@ class AvatarUploadTests(TestCase):
|
|||
base_url = settings.MEDIA_URL
|
||||
self.assertTrue(base_url in loc)
|
||||
self.assertTrue(loc.endswith(AVATAR_DEFAULT_URL))
|
||||
|
||||
def testNonExistingUser(self):
|
||||
a = get_primary_avatar("nonexistinguser")
|
||||
self.failUnlessEqual(a, None)
|
||||
|
||||
# def testTooManyAvatars
|
||||
# def testReplaceAvatarWhenMaxIsOne
|
||||
|
|
|
|||
Loading…
Reference in a new issue