API tolerate None environment string

If an API request has a None environment argument, we should not
reject the request, but treat it the same as an empty environment.

Change-Id: I812f308ef38833e89dfa2ce01263a297032f563a
Closes-Bug: #1273993
This commit is contained in:
Steven Hardy 2014-01-29 13:58:13 +00:00
parent 3d2517b2c7
commit 7530b16513
2 changed files with 6 additions and 2 deletions

View File

@ -24,9 +24,10 @@ SECTIONS = (PARAMETERS, RESOURCE_REGISTRY) = \
def parse(env_str):
'''
Takes a string and returns a dict containing the parsed structure.
This includes determination of whether the string is using the
JSON or YAML format.
'''
if env_str is None:
return {}
try:
env = yaml.load(env_str, Loader=yaml_loader)
except yaml.YAMLError as yea:

View File

@ -45,6 +45,9 @@ parameters: }
'''
self.assertRaises(ValueError, environment_format.parse, env)
def test_yaml_none(self):
self.assertEqual({}, environment_format.parse(None))
class YamlParseExceptions(common.HeatTestCase):