Merge "Treat null values in JSON as being absent rather than 'None'"
This commit is contained in:
commit
29db0f43e8
@ -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:
|
||||
|
@ -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',
|
||||
|
Loading…
Reference in New Issue
Block a user