Use text_format_safe instead of text_format
Use text_format_safe for traversing plugin attributes Change-Id: Ib21a7386fe7cea982c98cfeaaa26040463f72b9d Closes-Bug: #1576197
This commit is contained in:
parent
afdceb7fad
commit
a4b427fca4
@ -47,6 +47,7 @@ from nailgun.policy.merge import NetworkRoleMergePolicy
|
|||||||
from nailgun.settings import settings
|
from nailgun.settings import settings
|
||||||
from nailgun.utils import AttributesGenerator
|
from nailgun.utils import AttributesGenerator
|
||||||
from nailgun.utils import dict_merge
|
from nailgun.utils import dict_merge
|
||||||
|
from nailgun.utils import text_format_safe
|
||||||
from nailgun.utils import traverse
|
from nailgun.utils import traverse
|
||||||
|
|
||||||
|
|
||||||
@ -363,6 +364,7 @@ class Cluster(NailgunObject):
|
|||||||
|
|
||||||
plugin_attrs = traverse(
|
plugin_attrs = traverse(
|
||||||
plugin_attrs,
|
plugin_attrs,
|
||||||
|
formatter=text_format_safe,
|
||||||
formatter_context={'cluster': instance, 'settings': settings},
|
formatter_context={'cluster': instance, 'settings': settings},
|
||||||
keywords={'generator': AttributesGenerator.evaluate}
|
keywords={'generator': AttributesGenerator.evaluate}
|
||||||
)
|
)
|
||||||
|
@ -1679,6 +1679,20 @@ class TestClusterObject(BaseTestCase):
|
|||||||
updated_attributes['editable']['test_plugin']
|
updated_attributes['editable']['test_plugin']
|
||||||
['plugin_name_text']['value'])
|
['plugin_name_text']['value'])
|
||||||
|
|
||||||
|
def test_get_attributes_with_plugin(self):
|
||||||
|
cluster = self.env.create_cluster(api=False)
|
||||||
|
self.env.create_plugin(
|
||||||
|
name='test_plugin',
|
||||||
|
version='1.0.0',
|
||||||
|
package_version='4.0.0',
|
||||||
|
cluster=cluster,
|
||||||
|
attributes_metadata=self.env.get_default_plugin_env_config(
|
||||||
|
value='{}')
|
||||||
|
)
|
||||||
|
attr = objects.Cluster.get_attributes(cluster, True)
|
||||||
|
plugin_attrs = attr.editable['test_plugin']['metadata']['versions'][0]
|
||||||
|
self.assertEqual('{}', plugin_attrs['plugin_name_text']['value'])
|
||||||
|
|
||||||
|
|
||||||
class TestClusterObjectVirtRoles(BaseTestCase):
|
class TestClusterObjectVirtRoles(BaseTestCase):
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user