test helper: Ensure to populate JS_CATALOG in context
_script_i18n.html which tries to access 'jsi18n' url assumes context['JS_CATALOG'] is populated, but openstack_dashboard test helper clears it by mocking a context processor. This leads to a error in rendering templates in unit tests. Note that template rendering error is caught by a rendering engine so unit test itself succeeds even when this happens. Change-Id: I0f5013c4e9ed7b166c527b1aacd0302413948d51 Closes-Bug: #1699509
This commit is contained in:
parent
4a882c14b9
commit
ce82c1f805
|
@ -96,6 +96,12 @@ def openstack(request):
|
|||
context['x_trace_info'] = profiler.update_trace_headers(
|
||||
hmac_keys, parent_id=index_view_id)
|
||||
|
||||
context['JS_CATALOG'] = get_js_catalog(conf)
|
||||
|
||||
return context
|
||||
|
||||
|
||||
def get_js_catalog(conf):
|
||||
# Search for external plugins and append to javascript message catalog
|
||||
# internal plugins are under the openstack_dashboard domain
|
||||
# so we exclude them from the js_catalog
|
||||
|
@ -103,6 +109,4 @@ def openstack(request):
|
|||
regex = re.compile(r'^openstack_dashboard')
|
||||
all_plugins = conf.HORIZON_CONFIG['plugins']
|
||||
js_catalog.extend(p for p in all_plugins if not regex.search(p))
|
||||
context['JS_CATALOG'] = '+'.join(js_catalog)
|
||||
|
||||
return context
|
||||
return '+'.join(js_catalog)
|
||||
|
|
|
@ -195,7 +195,10 @@ class TestCase(horizon_helpers.TestCase):
|
|||
def _setup_test_data(self):
|
||||
super(TestCase, self)._setup_test_data()
|
||||
test_utils.load_test_data(self)
|
||||
self.context = {'authorized_tenants': self.tenants.list()}
|
||||
self.context = {
|
||||
'authorized_tenants': self.tenants.list(),
|
||||
'JS_CATALOG': context_processors.get_js_catalog(settings),
|
||||
}
|
||||
|
||||
def _setup_factory(self):
|
||||
# For some magical reason we need a copy of this here.
|
||||
|
|
Loading…
Reference in New Issue