Fix TypeError if no input_parameters added
By calling solution.add_action with no input_parameters, TypeError: 'NoneType' object does not support item assignment was occurred. This patch fix it. Change-Id: Ia2ad0c18bc20468ca73c0ab70495fac2c90e0640 Closes-Bug: #1647927
This commit is contained in:
@@ -41,6 +41,9 @@ class DefaultSolution(base.BaseSolution):
|
||||
if baction.BaseAction.RESOURCE_ID in input_parameters.keys():
|
||||
raise exception.ReservedWord(name=baction.BaseAction.
|
||||
RESOURCE_ID)
|
||||
else:
|
||||
input_parameters = {}
|
||||
|
||||
if resource_id is not None:
|
||||
input_parameters[baction.BaseAction.RESOURCE_ID] = resource_id
|
||||
action = {
|
||||
|
||||
@@ -43,3 +43,18 @@ class TestDefaultSolution(base.TestCase):
|
||||
solution.actions[0].get('action_type'))
|
||||
self.assertEqual(expected_parameters,
|
||||
solution.actions[0].get('input_parameters'))
|
||||
|
||||
def test_default_solution_with_no_input_parameters(self):
|
||||
solution = default.DefaultSolution(
|
||||
goal=mock.Mock(), strategy=mock.Mock())
|
||||
solution.add_action(action_type="nop",
|
||||
resource_id="b199db0c-1408-4d52-b5a5-5ca14de0ff36")
|
||||
self.assertEqual(1, len(solution.actions))
|
||||
expected_action_type = "nop"
|
||||
expected_parameters = {
|
||||
"resource_id": "b199db0c-1408-4d52-b5a5-5ca14de0ff36"
|
||||
}
|
||||
self.assertEqual(expected_action_type,
|
||||
solution.actions[0].get('action_type'))
|
||||
self.assertEqual(expected_parameters,
|
||||
solution.actions[0].get('input_parameters'))
|
||||
|
||||
Reference in New Issue
Block a user