def test_avatar_url_outdated(self):
     john = User.objects.create_user('john', '*****@*****.**', 'password')
     avatar = Avatar.objects.create(
         user=john, received_for='*****@*****.**')
     self.assertEqual(
         utils.get_avatar_url(john, 120), 'avatar/120x120/{}'.format(
             self.default_img))
 def test_avatar_url(self):
     john = User.objects.create_user('john', '*****@*****.**', 'password')
     avatar = Avatar.objects.create(user=john, received_for=john.email)
     self.assertEqual(
         utils.get_avatar_url(john, 120),
         'avatar/120x120/'
         '855f96e983f1f8e8be944692b6f719fd54329826cb62e98015efee8e2e071dd4')
 def test_url(self):
     self.assertEqual(
         self.john.avatar.url(resolution=160),
         utils.get_avatar_url(self.john, resolution=160))
 def test_avatar_url_without_avatar(self):
     john = User.objects.create_user('john', '*****@*****.**', 'password')
     self.assertEqual(
         utils.get_avatar_url(john, 120), 'avatar/120x120/{}'.format(
             self.default_img))
 def test_avatar_url_empty_mail(self):
     john = User.objects.create_user('john', '', 'password')
     self.assertEqual(
         utils.get_avatar_url(john, 120), 'avatar/120x120/{}'.format(
             self.default_img))
def avatar_url(user, resolution=160):
    return staticfiles_storage.url(utils.get_avatar_url(user, resolution))