Show More
@@ -25,9 +25,10 b'' | |||||
25 |
|
25 | |||
26 | import unittest |
|
26 | import unittest | |
27 | import datetime |
|
27 | import datetime | |
|
28 | import hashlib | |||
|
29 | import mock | |||
28 | from rhodecode.tests import * |
|
30 | from rhodecode.tests import * | |
29 |
|
31 | |||
30 |
|
||||
31 | proto = 'http' |
|
32 | proto = 'http' | |
32 | TEST_URLS = [ |
|
33 | TEST_URLS = [ | |
33 | ('%s://127.0.0.1' % proto, ['%s://' % proto, '127.0.0.1'], |
|
34 | ('%s://127.0.0.1' % proto, ['%s://' % proto, '127.0.0.1'], | |
@@ -147,3 +148,30 b' class TestLibs(unittest.TestCase):' | |||||
147 | self.assertTrue('<div class="metatag" tag="lang">python</div>' in res) |
|
148 | self.assertTrue('<div class="metatag" tag="lang">python</div>' in res) | |
148 | self.assertTrue('<div class="metatag" tag="requires">requires => <a href="/url">url</a></div>' in res) |
|
149 | self.assertTrue('<div class="metatag" tag="requires">requires => <a href="/url">url</a></div>' in res) | |
149 | self.assertTrue('<div class="metatag" tag="tag">tag</div>' in res) |
|
150 | self.assertTrue('<div class="metatag" tag="tag">tag</div>' in res) | |
|
151 | ||||
|
152 | def test_alternative_gravatar(self): | |||
|
153 | from rhodecode.lib.helpers import gravatar_url | |||
|
154 | _md5 = lambda s: hashlib.md5(s).hexdigest() | |||
|
155 | ||||
|
156 | def fake_conf(**kwargs): | |||
|
157 | from pylons import config | |||
|
158 | config['app_conf'] = {} | |||
|
159 | config['app_conf']['use_gravatar'] = True | |||
|
160 | config['app_conf'].update(kwargs) | |||
|
161 | return config | |||
|
162 | fake = fake_conf(alternative_gravatar_url='http://test.com/{email}') | |||
|
163 | with mock.patch('pylons.config', fake): | |||
|
164 | grav = gravatar_url(email_address='test@foo.com', size=24) | |||
|
165 | assert grav == 'http://test.com/test@foo.com' | |||
|
166 | ||||
|
167 | fake = fake_conf(alternative_gravatar_url='http://test.com/{md5email}') | |||
|
168 | with mock.patch('pylons.config', fake): | |||
|
169 | em = 'test@foo.com' | |||
|
170 | grav = gravatar_url(email_address=em, size=24) | |||
|
171 | assert grav == 'http://test.com/%s' % (_md5(em)) | |||
|
172 | ||||
|
173 | fake = fake_conf(alternative_gravatar_url='http://test.com/{md5email}/{size}') | |||
|
174 | with mock.patch('pylons.config', fake): | |||
|
175 | em = 'test@foo.com' | |||
|
176 | grav = gravatar_url(email_address=em, size=24) | |||
|
177 | assert grav == 'http://test.com/%s/%s' % (_md5(em), 24) |
General Comments 0
You need to be logged in to leave comments.
Login now