Improve parsing of Pseudo-boolean config options
The charm has a number of config options which should have been defined as booleans but are strings and previously yes/no was used to toggle them. This change extends what strings users can set here to include, among others, 'true' and 'false' Change-Id: I87702b779eca8389623ed698f8b745f779e3564b Closes-Bug: 1484746
This commit is contained in:
parent
1e3fe19243
commit
2c93f187f0
|
@ -25,6 +25,7 @@ from charmhelpers.core.hookenv import (
|
|||
WARNING,
|
||||
ERROR,
|
||||
)
|
||||
from charmhelpers.core.strutils import bool_from_string
|
||||
from charmhelpers.contrib.openstack.context import (
|
||||
OSContextGenerator,
|
||||
HAProxyContext,
|
||||
|
@ -178,11 +179,12 @@ class HorizonContext(OSContextGenerator):
|
|||
''' Provide all configuration for Horizon '''
|
||||
projects_yaml = git_default_repos(config('openstack-origin-git'))
|
||||
ctxt = {
|
||||
'compress_offline': config('offline-compression') in ['yes', True],
|
||||
'debug': config('debug') in ['yes', True],
|
||||
'compress_offline':
|
||||
bool_from_string(config('offline-compression')),
|
||||
'debug': bool_from_string(config('debug')),
|
||||
'default_role': config('default-role'),
|
||||
"webroot": config('webroot'),
|
||||
"ubuntu_theme": config('ubuntu-theme') in ['yes', True],
|
||||
"ubuntu_theme": bool_from_string(config('ubuntu-theme')),
|
||||
"default_theme": config('default-theme'),
|
||||
"secret": config('secret') or pwgen(),
|
||||
'support_profile': config('profile')
|
||||
|
|
|
@ -133,7 +133,7 @@ class TestHorizonContexts(CharmTestCase):
|
|||
"cinder_backup": False})
|
||||
|
||||
def test_HorizonContext_ubuntu_theme(self):
|
||||
self.test_config.set('ubuntu-theme', False)
|
||||
self.test_config.set('ubuntu-theme', 'False')
|
||||
self.assertEquals(horizon_contexts.HorizonContext()(),
|
||||
{'compress_offline': True, 'debug': False,
|
||||
'default_role': 'Member', 'webroot': '/horizon',
|
||||
|
@ -150,7 +150,7 @@ class TestHorizonContexts(CharmTestCase):
|
|||
"cinder_backup": False})
|
||||
|
||||
def test_HorizonContext_default_theme(self):
|
||||
self.test_config.set('ubuntu-theme', False)
|
||||
self.test_config.set('ubuntu-theme', 'False')
|
||||
self.test_config.set('default-theme', 'material')
|
||||
self.assertEquals(horizon_contexts.HorizonContext()(),
|
||||
{'compress_offline': True, 'debug': False,
|
||||
|
@ -167,6 +167,10 @@ class TestHorizonContexts(CharmTestCase):
|
|||
"neutron_network_vpn": False,
|
||||
"cinder_backup": False})
|
||||
|
||||
def test_HorizonContext_default_theme_true(self):
|
||||
self.test_config.set('ubuntu-theme', 'true')
|
||||
self.assertTrue(horizon_contexts.HorizonContext()()['ubuntu_theme'])
|
||||
|
||||
def test_HorizonContext_compression(self):
|
||||
self.test_config.set('offline-compression', 'no')
|
||||
self.assertEquals(horizon_contexts.HorizonContext()(),
|
||||
|
|
Loading…
Reference in New Issue