tests: remove usage of pylons context var in home app test.

This commit is contained in:
Marcin Kuzminski 2017-07-08 00:03:39 +02:00
parent f0ff4c5ce2
commit ff28358243
2 changed files with 11 additions and 6 deletions

View file

@ -54,14 +54,15 @@ class TestHomeController(TestController):
response.mustcontain('"name_raw": "%s"' % repo.repo_name)
def test_index_contains_statics_with_ver(self):
from pylons import tmpl_context as c
from rhodecode.lib.base import calculate_version_hash
self.log_user()
response = self.app.get(route_path('home'))
rhodecode_version_hash = c.rhodecode_version_hash
rhodecode_version_hash = calculate_version_hash()
response.mustcontain('style.css?ver={0}'.format(rhodecode_version_hash))
response.mustcontain('rhodecode-components.js?ver={0}'.format(rhodecode_version_hash))
response.mustcontain('rhodecode-components.js?ver={0}'.format(
rhodecode_version_hash))
def test_index_contains_backend_specific_details(self, backend):
self.log_user()

View file

@ -266,6 +266,12 @@ class BasicAuth(AuthBasicAuthenticator):
def attach_context_attributes(context, request, user_id, attach_to_request=False):
def calculate_version_hash():
return md5(
config.get('beaker.session.secret', '') +
rhodecode.__version__)[:8]
"""
Attach variables into template context called `c`, please note that
request could be pylons or pyramid request in here.
@ -275,9 +281,7 @@ def attach_context_attributes(context, request, user_id, attach_to_request=False
context.rhodecode_version = rhodecode.__version__
context.rhodecode_edition = config.get('rhodecode.edition')
# unique secret + version does not leak the version but keep consistency
context.rhodecode_version_hash = md5(
config.get('beaker.session.secret', '') +
rhodecode.__version__)[:8]
context.rhodecode_version_hash = calculate_version_hash()
# Default language set for the incoming request
context.language = translation.get_lang()[0]