Merge "Treat null values in JSON as being absent rather than 'None'"

This commit is contained in:
Jenkins 2014-10-30 17:33:35 +00:00 committed by Gerrit Code Review
commit 29db0f43e8
2 changed files with 11 additions and 0 deletions

View File

@ -86,6 +86,8 @@ def print_key(
for key in keys:
try:
config = config[key]
if config is None:
raise TypeError()
except (KeyError, TypeError):
try:
if type(config) == list:

View File

@ -33,6 +33,7 @@ TEMPLATES = os.path.join(os.path.dirname(__file__), 'templates')
CONFIG = {
"x": "foo",
"y": False,
"z": None,
"database": {
"url": "sqlite:///blah"
},
@ -120,6 +121,14 @@ class TestRunOSConfigApplier(testtools.TestCase):
self.stdout.read().strip())
self.assertEqual('', self.logger.output)
def test_print_null_key(self):
self.assertEqual(0, apply_config.main(
['os-apply-config.py', '--metadata', self.path, '--key',
'z', '--type', 'raw', '--key-default', '']))
self.stdout.seek(0)
self.assertEqual('', self.stdout.read().strip())
self.assertEqual('', self.logger.output)
def test_print_key_missing(self):
self.assertEqual(1, apply_config.main(
['os-apply-config.py', '--metadata', self.path, '--key',