Don't render None as "null"
In a config file you never want the string "null" in place of a null
value. Just render an empty string instead.
Change-Id: Ibe145c4929d4944cd8d51c07a64aee6fd5f831f2
Closes-Bug: #1830967
Story: 2005797
(cherry picked from commit 75d527ab8f
)
This commit is contained in:
parent
f822e821f4
commit
e817b6d0ca
@ -38,4 +38,6 @@ class JsonRenderer(pystache.Renderer):
|
|||||||
partials, missing_tags)
|
partials, missing_tags)
|
||||||
|
|
||||||
def str_coerce(self, val):
|
def str_coerce(self, val):
|
||||||
|
if val is None:
|
||||||
|
return b''
|
||||||
return json.dumps(val)
|
return json.dumps(val)
|
||||||
|
@ -337,6 +337,11 @@ class OSConfigApplierTestCase(testtools.TestCase):
|
|||||||
def test_render_moustache_bad_key(self):
|
def test_render_moustache_bad_key(self):
|
||||||
self.assertEqual(u'', apply_config.render_moustache("{{badkey}}", {}))
|
self.assertEqual(u'', apply_config.render_moustache("{{badkey}}", {}))
|
||||||
|
|
||||||
|
def test_render_moustache_none(self):
|
||||||
|
self.assertEqual('foo: ',
|
||||||
|
apply_config.render_moustache("foo: {{foo}}",
|
||||||
|
{'foo': None}))
|
||||||
|
|
||||||
def test_render_executable(self):
|
def test_render_executable(self):
|
||||||
params = {"x": "foo"}
|
params = {"x": "foo"}
|
||||||
self.assertEqual("foo\n", apply_config.render_executable(
|
self.assertEqual("foo\n", apply_config.render_executable(
|
||||||
|
Loading…
Reference in New Issue
Block a user