##// END OF EJS Templates
fixed gravatar tests
marcink -
r3913:5f192af1 beta
parent child Browse files
Show More
@@ -172,9 +172,9 b' class TestLibs(BaseTestCase):'
172
172
173 def fake_conf(**kwargs):
173 def fake_conf(**kwargs):
174 from pylons import config
174 from pylons import config
175 config['app_conf'] = {}
175 config = {}
176 config['app_conf']['use_gravatar'] = True
176 config['use_gravatar'] = True
177 config['app_conf'].update(kwargs)
177 config.update(kwargs)
178 return config
178 return config
179
179
180 class fake_url():
180 class fake_url():
@@ -184,31 +184,31 b' class TestLibs(BaseTestCase):'
184
184
185 with mock.patch('pylons.url', fake_url):
185 with mock.patch('pylons.url', fake_url):
186 fake = fake_conf(alternative_gravatar_url='http://test.com/{email}')
186 fake = fake_conf(alternative_gravatar_url='http://test.com/{email}')
187 with mock.patch('pylons.config', fake):
187 with mock.patch('rhodecode.CONFIG', fake):
188 from pylons import url
188 from pylons import url
189 assert url.current() == 'https://server.com'
189 assert url.current() == 'https://server.com'
190 grav = gravatar_url(email_address='test@foo.com', size=24)
190 grav = gravatar_url(email_address='test@foo.com', size=24)
191 assert grav == 'http://test.com/test@foo.com'
191 assert grav == 'http://test.com/test@foo.com'
192
192
193 fake = fake_conf(alternative_gravatar_url='http://test.com/{email}')
193 fake = fake_conf(alternative_gravatar_url='http://test.com/{email}')
194 with mock.patch('pylons.config', fake):
194 with mock.patch('rhodecode.CONFIG', fake):
195 grav = gravatar_url(email_address='test@foo.com', size=24)
195 grav = gravatar_url(email_address='test@foo.com', size=24)
196 assert grav == 'http://test.com/test@foo.com'
196 assert grav == 'http://test.com/test@foo.com'
197
197
198 fake = fake_conf(alternative_gravatar_url='http://test.com/{md5email}')
198 fake = fake_conf(alternative_gravatar_url='http://test.com/{md5email}')
199 with mock.patch('pylons.config', fake):
199 with mock.patch('rhodecode.CONFIG', fake):
200 em = 'test@foo.com'
200 em = 'test@foo.com'
201 grav = gravatar_url(email_address=em, size=24)
201 grav = gravatar_url(email_address=em, size=24)
202 assert grav == 'http://test.com/%s' % (_md5(em))
202 assert grav == 'http://test.com/%s' % (_md5(em))
203
203
204 fake = fake_conf(alternative_gravatar_url='http://test.com/{md5email}/{size}')
204 fake = fake_conf(alternative_gravatar_url='http://test.com/{md5email}/{size}')
205 with mock.patch('pylons.config', fake):
205 with mock.patch('rhodecode.CONFIG', fake):
206 em = 'test@foo.com'
206 em = 'test@foo.com'
207 grav = gravatar_url(email_address=em, size=24)
207 grav = gravatar_url(email_address=em, size=24)
208 assert grav == 'http://test.com/%s/%s' % (_md5(em), 24)
208 assert grav == 'http://test.com/%s/%s' % (_md5(em), 24)
209
209
210 fake = fake_conf(alternative_gravatar_url='{scheme}://{netloc}/{md5email}/{size}')
210 fake = fake_conf(alternative_gravatar_url='{scheme}://{netloc}/{md5email}/{size}')
211 with mock.patch('pylons.config', fake):
211 with mock.patch('rhodecode.CONFIG', fake):
212 em = 'test@foo.com'
212 em = 'test@foo.com'
213 grav = gravatar_url(email_address=em, size=24)
213 grav = gravatar_url(email_address=em, size=24)
214 assert grav == 'https://server.com/%s/%s' % (_md5(em), 24)
214 assert grav == 'https://server.com/%s/%s' % (_md5(em), 24)
General Comments 0
You need to be logged in to leave comments. Login now