コード例 #1
0
    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')
コード例 #2
0
 def test_email_hash(self):
     request = DummyRequest()
     gravatar = Gravatar(request, 'http://localhost/default_gravatar.png')
     self.assertEqual(gravatar.get_email_hash('*****@*****.**'),
                      'd4c74594d841139328695756648b6bd6')
     self.assertEqual(gravatar.get_email_hash('*****@*****.**'),
                      'd4c74594d841139328695756648b6bd6')
コード例 #3
0
 def test_email_hash(self):
     request = DummyRequest()
     gravatar = Gravatar(request, 'http://localhost/default_gravatar.png')
     self.assertEqual(gravatar.get_email_hash('*****@*****.**'),
                      'd4c74594d841139328695756648b6bd6')
     self.assertEqual(gravatar.get_email_hash('*****@*****.**'),
                      'd4c74594d841139328695756648b6bd6')
コード例 #4
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')
コード例 #5
0
    def test_has_avatar(self):
        request = DummyRequest()
        request.user = None
        gravatar = Gravatar(request, 'http://localhost/default_gravatar.png')
        self.assertFalse(gravatar.has_avatar())

        request = DummyRequest()
        request.user = {'email': '*****@*****.**'}
        gravatar = Gravatar(request, 'http://localhost/default_gravatar.png')
        self.assertTrue(gravatar.has_avatar())
コード例 #6
0
    def test_get_email(self):
        request = DummyRequest()
        request.user = None
        gravatar = Gravatar(request, 'http://localhost/default_gravatar.png')
        self.assertEqual(gravatar.get_email(), None)

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

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

        request = DummyRequest()
        request.user = {'email': '*****@*****.**'}
        gravatar = Gravatar(request, 'http://localhost/default_gravatar.png')
        self.assertEqual(gravatar.get_email(), '*****@*****.**')
コード例 #7
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')
コード例 #8
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')
コード例 #9
0
 def test_has_avatar_valid_user(self):
     request = DummyRequest()
     request.user = User(email='*****@*****.**')
     gravatar = Gravatar(request, 'http://localhost/default_gravatar.png')
     self.assertTrue(gravatar.has_avatar())
コード例 #10
0
 def test_has_avatar_no_user(self):
     request = DummyRequest()
     request.user = None
     gravatar = Gravatar(request, 'http://localhost/default_gravatar.png')
     self.assertFalse(gravatar.has_avatar())
コード例 #11
0
 def test_get_email_valid_email(self):
     request = DummyRequest()
     request.user = User(email='*****@*****.**')
     gravatar = Gravatar(request, 'http://localhost/default_gravatar.png')
     self.assertEqual(gravatar.get_email(), '*****@*****.**')
コード例 #12
0
 def test_get_email_default_user(self):
     request = DummyRequest()
     request.user = User()
     gravatar = Gravatar(request, 'http://localhost/default_gravatar.png')
     self.assertEqual(gravatar.get_email(), None)