fix workflow exception on host aggregate create form
Under the circumstance that there are existing aggregates, this bug happens when create button is clicked without the required "name" field filled. Error toast shows instead of the expected error message on the create form. When the form posts without name filed filled, the name attribute in the clean data is None instead of an empty string, which causes AttributeError on the following string operation. 1. patch an empty string as the fallback value for the 'name' variable 2. corresponding unit test is attached Change-Id: I0bdf469d87aa06ab58b73e6ce41bdf63bb36a538 Closes-Bug: #1617140
This commit is contained in:
parent
d8b6fa9e44
commit
eedac01a9c
@ -117,6 +117,17 @@ class CreateAggregateWorkflowTests(BaseAggregateWorkflowTests):
|
||||
self._test_generic_create_aggregate(workflow_data, aggregate, (), 1,
|
||||
u'This field is required')
|
||||
|
||||
def test_create_aggregate_fails_missing_fields_existing_aggregates(self):
|
||||
aggregate = self.aggregates.first()
|
||||
existing_aggregates = self.aggregates.list()
|
||||
workflow_data = self._get_create_workflow_data(aggregate)
|
||||
workflow_data['name'] = ''
|
||||
workflow_data['availability_zone'] = ''
|
||||
|
||||
self._test_generic_create_aggregate(workflow_data, aggregate,
|
||||
existing_aggregates, 1,
|
||||
u'This field is required')
|
||||
|
||||
def test_create_aggregate_fails_duplicated_name(self):
|
||||
aggregate = self.aggregates.first()
|
||||
existing_aggregates = self.aggregates.list()
|
||||
|
@ -37,7 +37,7 @@ class SetAggregateInfoAction(workflows.Action):
|
||||
|
||||
def clean(self):
|
||||
cleaned_data = super(SetAggregateInfoAction, self).clean()
|
||||
name = cleaned_data.get('name')
|
||||
name = cleaned_data.get('name', '')
|
||||
|
||||
try:
|
||||
aggregates = api.nova.aggregate_details_list(self.request)
|
||||
|
Loading…
Reference in New Issue
Block a user