'Test if the correct mugshot is returned when the user makes use of gravatar.'

def test_get_mugshot_url_with_gravatar(self):

    profile = Profile.objects.get(pk=1)
    gravatar_hash = hashlib.md5(profile.user.email.encode('utf-8')).hexdigest()
    mugshot_url = profile.get_mugshot_url()
    parsed = urlparse(mugshot_url)
    self.assertEqual(parsed.netloc, 'www.gravatar.com')
    self.assertEqual(parsed.path, ('/avatar/' + gravatar_hash))
    self.assertEqual(parse_qs(parsed.query), parse_qs(('s=%(size)s&d=%(default)s' % {'size': userena_settings.USERENA_MUGSHOT_SIZE, 'default': userena_settings.USERENA_MUGSHOT_DEFAULT})))
    userena_settings.USERENA_MUGSHOT_SIZE = 180
    userena_settings.USERENA_MUGSHOT_DEFAULT = '404'
    mugshot_url = profile.get_mugshot_url()
    parsed = urlparse(mugshot_url)
    self.assertEqual(parsed.netloc, 'www.gravatar.com')
    self.assertEqual(parsed.path, ('/avatar/' + gravatar_hash))
    self.assertEqual(parse_qs(parsed.query), parse_qs(('s=%(size)s&d=%(default)s' % {'size': userena_settings.USERENA_MUGSHOT_SIZE, 'default': userena_settings.USERENA_MUGSHOT_DEFAULT})))
    userena_settings.USERENA_MUGSHOT_SIZE = 80
    userena_settings.USERENA_MUGSHOT_DEFAULT = 'identicon'
