mirror of
https://github.com/jazzband/django-avatar.git
synced 2026-03-16 22:20:30 +00:00
Add test for kwargs in template tag.
This commit is contained in:
parent
61a6d56d55
commit
c1f7abd2e4
2 changed files with 11 additions and 2 deletions
|
|
@ -57,13 +57,13 @@ def cache_result(default_size=settings.AVATAR_DEFAULT_SIZE):
|
|||
return decorator
|
||||
|
||||
def decorator(func):
|
||||
def cached_func(user, size=None):
|
||||
def cached_func(user, size=None, **kwargs):
|
||||
prefix = func.__name__
|
||||
cached_funcs.add(prefix)
|
||||
key = get_cache_key(user, size or default_size, prefix=prefix)
|
||||
result = cache.get(key)
|
||||
if result is None:
|
||||
result = func(user, size or default_size)
|
||||
result = func(user, size or default_size, **kwargs)
|
||||
cache_set(key, result)
|
||||
return result
|
||||
return cached_func
|
||||
|
|
|
|||
|
|
@ -210,6 +210,15 @@ class AvatarTests(TestCase):
|
|||
self.assertIn('<img src="{}"'.format(avatar.avatar_url(100)), result)
|
||||
self.assertIn('alt="test" width="100" height="100" />', result)
|
||||
|
||||
def test_avatar_tag_works_with_kwargs(self):
|
||||
upload_helper(self, "test.png")
|
||||
avatar = get_primary_avatar(self.user)
|
||||
|
||||
result = avatar_tags.avatar(self.user, title="Avatar")
|
||||
|
||||
self.assertIn('<img src="{}"'.format(avatar.avatar_url(80)), result)
|
||||
self.assertIn('width="80" height="80" alt="test" title="Avatar" />', result)
|
||||
|
||||
def test_default_add_template(self):
|
||||
response = self.client.get('/avatar/add/')
|
||||
self.assertContains(response, 'Upload New Image')
|
||||
|
|
|
|||
Loading…
Reference in a new issue