Merge "Don't log exception for None timeout_mins"
This commit is contained in:
commit
ae89d172b4
|
@ -29,13 +29,17 @@ def extract_args(params):
|
|||
conversion where appropriate
|
||||
'''
|
||||
kwargs = {}
|
||||
try:
|
||||
timeout_mins = int(params.get(api.PARAM_TIMEOUT, 0))
|
||||
except (ValueError, TypeError):
|
||||
logger.exception(_('create timeout conversion'))
|
||||
else:
|
||||
if timeout_mins > 0:
|
||||
kwargs[api.PARAM_TIMEOUT] = timeout_mins
|
||||
timeout_mins = params.get(api.PARAM_TIMEOUT)
|
||||
if timeout_mins not in ('0', 0, None):
|
||||
try:
|
||||
timeout = int(timeout_mins)
|
||||
except (ValueError, TypeError):
|
||||
logger.exception(_('Timeout conversion failed'))
|
||||
else:
|
||||
if timeout > 0:
|
||||
kwargs[api.PARAM_TIMEOUT] = timeout
|
||||
else:
|
||||
raise ValueError(_('Invalid timeout value %s') % timeout)
|
||||
|
||||
if api.PARAM_DISABLE_ROLLBACK in params:
|
||||
disable_rollback = params.get(api.PARAM_DISABLE_ROLLBACK)
|
||||
|
|
|
@ -51,6 +51,11 @@ class EngineApiTest(HeatTestCase):
|
|||
args = api.extract_args(p)
|
||||
self.assertNotIn('timeout_mins', args)
|
||||
|
||||
def test_timeout_extract_negative(self):
|
||||
p = {'timeout_mins': '-100'}
|
||||
error = self.assertRaises(ValueError, api.extract_args, p)
|
||||
self.assertIn('Invalid timeout value', str(error))
|
||||
|
||||
def test_timeout_extract_not_present(self):
|
||||
args = api.extract_args({})
|
||||
self.assertNotIn('timeout_mins', args)
|
||||
|
|
Loading…
Reference in New Issue