# HG changeset patch # User Marcin Kuzminski # Date 2017-11-07 22:22:00 # Node ID 03c882754ec4be06248d96063cac968214fe70d3 # Parent 830b678e849ea22be21442c648f38d57887921b3 tests: change lib tests to use proper pyramid mocks. diff --git a/rhodecode/tests/lib/test_libs.py b/rhodecode/tests/lib/test_libs.py --- a/rhodecode/tests/lib/test_libs.py +++ b/rhodecode/tests/lib/test_libs.py @@ -316,27 +316,26 @@ def test_metatags_stylize(tag_data, expe def test_gravatar_url_builder(tmpl_url, email, expected, request_stub): from rhodecode.lib.helpers import gravatar_url - # mock pyramid.threadlocals - def fake_get_current_request(): - request_stub.scheme = 'https' - request_stub.host = 'server.com' - return request_stub - - # mock pylons.tmpl_context def fake_tmpl_context(_url): _c = AttributeDict() _c.visual = AttributeDict() _c.visual.use_gravatar = True _c.visual.gravatar_url = _url + return _c - return _c + # mock pyramid.threadlocals + def fake_get_current_request(): + request_stub.scheme = 'https' + request_stub.host = 'server.com' + + request_stub._call_context = fake_tmpl_context(tmpl_url) + return request_stub with mock.patch('rhodecode.lib.helpers.get_current_request', fake_get_current_request): - fake = fake_tmpl_context(_url=tmpl_url) - with mock.patch('pylons.tmpl_context', fake): - grav = gravatar_url(email_address=email, size=24) - assert grav == expected + + grav = gravatar_url(email_address=email, size=24) + assert grav == expected @pytest.mark.parametrize(