Browse Source

Add unit tests for timeout extraction

Change-Id: I87837b78dc04683aa686f0573bb7b643667c4553
Signed-off-by: Zane Bitter <zbitter@redhat.com>
changes/70/270/1
Zane Bitter 10 years ago
parent
commit
4fe38c787e
  1. 2
      heat/engine/manager.py
  2. 24
      heat/tests/test_manager.py

2
heat/engine/manager.py

@ -67,7 +67,7 @@ def _extract_args(params):
kwargs = {}
try:
timeout_mins = int(params.get('TimeoutInMinutes', 0))
except ValueError:
except (ValueError, TypeError):
logger.exception('create timeout conversion')
else:
if timeout_mins > 0:

24
heat/tests/test_manager.py

@ -53,3 +53,27 @@ class managerTest(unittest.TestCase):
'Parameters.member.Foo.Bar.ParameterValue': 'bar'}
params = manager._extract_user_params(p)
self.assertFalse(params)
def test_timeout_extract(self):
p = {'TimeoutInMinutes': '5'}
args = manager._extract_args(p)
self.assertEqual(args['timeout_in_minutes'], 5)
def test_timeout_extract_zero(self):
p = {'TimeoutInMinutes': '0'}
args = manager._extract_args(p)
self.assertTrue('timeout_in_minutes' not in args)
def test_timeout_extract_garbage(self):
p = {'TimeoutInMinutes': 'wibble'}
args = manager._extract_args(p)
self.assertTrue('timeout_in_minutes' not in args)
def test_timeout_extract_none(self):
p = {'TimeoutInMinutes': None}
args = manager._extract_args(p)
self.assertTrue('timeout_in_minutes' not in args)
def test_timeout_extract_not_present(self):
args = manager._extract_args({})
self.assertTrue('timeout_in_minutes' not in args)

Loading…
Cancel
Save