def test_get_image_url(self):
        request = DummyRequest()
        request.user = None
        gravatar = Gravatar(request, 'http://localhost/default_gravatar.png')
        self.assertEqual(gravatar.get_image_url(),
                         'http://localhost/default_gravatar.png')

        request = DummyRequest()
        request.user = {}
        gravatar = Gravatar(request, 'http://localhost/default_gravatar.png')
        self.assertEqual(gravatar.get_image_url(),
                         'http://localhost/default_gravatar.png')

        request = DummyRequest()
        request.user = {'email': ''}
        gravatar = Gravatar(request, 'http://localhost/default_gravatar.png')
        self.assertEqual(gravatar.get_image_url(),
                         'http://localhost/default_gravatar.png')

        request = DummyRequest()
        request.user = {'email': '*****@*****.**'}
        gravatar = Gravatar(request, 'http://localhost/default_gravatar.png')
        self.assertEqual(
            gravatar.get_image_url(),
            'https://www.gravatar.com/avatar/d4c74594d841139328695756648b6bd6?s=32&d=http%3A%2F%2Flocalhost%2Fdefault_gravatar.png')

        gravatar = Gravatar(request, 'http://localhost/default_gravatar.png')
        self.assertEqual(
            gravatar.get_image_url(100),
            'https://www.gravatar.com/avatar/d4c74594d841139328695756648b6bd6?s=100&d=http%3A%2F%2Flocalhost%2Fdefault_gravatar.png')
Example #2
0
 def test_get_image_url_with_size(self):
     request = DummyRequest()
     request.user = User(email='*****@*****.**')
     gravatar = Gravatar(request, 'http://localhost/default_gravatar.png')
     self.assertURLEqual(
         gravatar.get_image_url(100),
         'https://www.gravatar.com/avatar/d4c74594d841139328695756648b6bd6?s=100&d=http%3A%2F%2Flocalhost%2Fdefault_gravatar.png')
Example #3
0
 def test_get_image_url_empty_email(self):
     request = DummyRequest()
     request.user = User(email='')
     gravatar = Gravatar(request, 'http://localhost/default_gravatar.png')
     self.assertURLEqual(gravatar.get_image_url(),
                         'http://localhost/default_gravatar.png')
Example #4
0
 def test_get_image_url_no_user(self):
     request = DummyRequest()
     request.user = None
     gravatar = Gravatar(request, 'http://localhost/default_gravatar.png')
     self.assertEqual(gravatar.get_image_url(),
                      'http://localhost/default_gravatar.png')