示例#1
0
 def test_gravatar(self):
     email = '*****@*****.**'
     expected =['<a href="http://gravatar.com" target="_blank">', '<img src="http://gravatar.com/avatar/7856421db6a63efa5b248909c472fbd2?s=200&amp;d=mm" />', '</a>']
     # Hash the email address
     import hashlib
     email_hash = hashlib.md5(email).hexdigest()
     res = h.linked_gravatar(email_hash, 200)
     for e in expected:
         assert e in res, e
示例#2
0
 def test_gravatar_encodes_url_correctly(self):
     """Test when the default gravatar is a url, it gets urlencoded"""
     email = '*****@*****.**'
     default = 'http://example.com/images/avatar.jpg'
     expected =['<a href="https://gravatar.com/"',
                '<img src="http://gravatar.com/avatar/7856421db6a63efa5b248909c472fbd2?s=200&amp;d=http%3A%2F%2Fexample.com%2Fimages%2Favatar.jpg"',
                '</a>']
     # Hash the email address
     import hashlib
     email_hash = hashlib.md5(email).hexdigest()
     res = h.linked_gravatar(email_hash, 200, default=default)
     for e in expected:
         assert e in res, (e,res)
示例#3
0
 def test_gravatar_config_set_default(self):
     """Test when default gravatar is None, it is pulled from the config file"""
     email = '*****@*****.**'
     default = config.get('ckan.gravatar_default', 'identicon')
     expected =['<a href="https://gravatar.com/"',
                '<img src="http://gravatar.com/avatar/7856421db6a63efa5b248909c472fbd2?s=200&amp;d=%s"' % default,
                '</a>']
     # Hash the email address
     import hashlib
     email_hash = hashlib.md5(email).hexdigest()
     res = h.linked_gravatar(email_hash, 200)
     for e in expected:
         assert e in res, (e,res)
示例#4
0
 def test_gravatar_config_set_default(self):
     """Test when default gravatar is None, it is pulled from the config file"""
     email = '*****@*****.**'
     default = config.get('ckan.gravatar_default', 'identicon')
     expected = ['<a href="https://gravatar.com/"',
                '<img src="//gravatar.com/avatar/7856421db6a63efa5b248909c472fbd2?s=200&amp;d=%s"' % default,
                '</a>']
     # Hash the email address
     import hashlib
     email_hash = hashlib.md5(email).hexdigest()
     res = h.linked_gravatar(email_hash, 200)
     for e in expected:
         assert e in res, (e, res)
示例#5
0
 def test_gravatar_encodes_url_correctly(self):
     """Test when the default gravatar is a url, it gets urlencoded"""
     email = '*****@*****.**'
     default = 'http://example.com/images/avatar.jpg'
     expected = ['<a href="https://gravatar.com/"',
                '<img src="//gravatar.com/avatar/7856421db6a63efa5b248909c472fbd2?s=200&amp;d=http%3A%2F%2Fexample.com%2Fimages%2Favatar.jpg"',
                '</a>']
     # Hash the email address
     import hashlib
     email_hash = hashlib.md5(email).hexdigest()
     res = h.linked_gravatar(email_hash, 200, default=default)
     for e in expected:
         assert e in res, (e, res)
    def test_gravatar(self):
        email = "*****@*****.**"
        expected = [
            '<a href="https://gravatar.com/"',
            '<img src="//gravatar.com/avatar/7856421db6a63efa5b248909c472fbd2?s=200&amp;d=mm"',
            "</a>",
        ]
        # Hash the email address
        import hashlib

        email_hash = hashlib.md5(six.ensure_binary(email)).hexdigest()
        res = h.linked_gravatar(email_hash, 200, default="mm")
        for e in expected:
            assert e in res, (e, res)
示例#7
0
    def test_gravatar(self):
        email = "*****@*****.**"
        expected = [
            '<a href="https://gravatar.com/"',
            '<img src="//gravatar.com/avatar/7856421db6a63efa5b248909c472fbd2?s=200&amp;d=mm"',
            "</a>",
        ]
        # Hash the email address
        import hashlib

        email_hash = hashlib.md5(email).hexdigest()
        res = h.linked_gravatar(email_hash, 200, default="mm")
        for e in expected:
            assert e in res, (e, res)