##// END OF EJS Templates
tests: change lib tests to use proper pyramid mocks.
marcink -
r2318:03c88275 default
parent child Browse files
Show More
@@ -316,25 +316,24 b' def test_metatags_stylize(tag_data, expe'
316 def test_gravatar_url_builder(tmpl_url, email, expected, request_stub):
316 def test_gravatar_url_builder(tmpl_url, email, expected, request_stub):
317 from rhodecode.lib.helpers import gravatar_url
317 from rhodecode.lib.helpers import gravatar_url
318
318
319 # mock pyramid.threadlocals
320 def fake_get_current_request():
321 request_stub.scheme = 'https'
322 request_stub.host = 'server.com'
323 return request_stub
324
325 # mock pylons.tmpl_context
326 def fake_tmpl_context(_url):
319 def fake_tmpl_context(_url):
327 _c = AttributeDict()
320 _c = AttributeDict()
328 _c.visual = AttributeDict()
321 _c.visual = AttributeDict()
329 _c.visual.use_gravatar = True
322 _c.visual.use_gravatar = True
330 _c.visual.gravatar_url = _url
323 _c.visual.gravatar_url = _url
324 return _c
331
325
332 return _c
326 # mock pyramid.threadlocals
327 def fake_get_current_request():
328 request_stub.scheme = 'https'
329 request_stub.host = 'server.com'
330
331 request_stub._call_context = fake_tmpl_context(tmpl_url)
332 return request_stub
333
333
334 with mock.patch('rhodecode.lib.helpers.get_current_request',
334 with mock.patch('rhodecode.lib.helpers.get_current_request',
335 fake_get_current_request):
335 fake_get_current_request):
336 fake = fake_tmpl_context(_url=tmpl_url)
336
337 with mock.patch('pylons.tmpl_context', fake):
338 grav = gravatar_url(email_address=email, size=24)
337 grav = gravatar_url(email_address=email, size=24)
339 assert grav == expected
338 assert grav == expected
340
339
General Comments 0
You need to be logged in to leave comments. Login now