Merge "Added a warning message if environment name is empty"

This commit is contained in:
Jenkins 2016-06-17 10:12:23 +00:00 committed by Gerrit Code Review
commit 02fd0fdafb
2 changed files with 22 additions and 1 deletions

View File

@ -403,6 +403,10 @@ class UpdateServiceRow(tables.Row):
class UpdateName(tables.UpdateAction):
def update_cell(self, request, datum, obj_id, cell_name, new_cell_value):
try:
if not new_cell_value or new_cell_value.isspace():
message = _("The environment name field cannot be empty.")
messages.warning(request, message)
raise ValueError(message)
mc = api_utils.muranoclient(request)
mc.environments.update(datum.id, name=new_cell_value)
except exc.HTTPConflict:
@ -428,7 +432,7 @@ class EnvironmentsTable(tables.DataTable):
name = tables.Column('name',
link='horizon:murano:environments:services',
verbose_name=_('Name'),
form_field=forms.CharField(),
form_field=forms.CharField(required=False),
update_action=UpdateName,
truncate=40)

View File

@ -83,6 +83,23 @@ class TestSuiteEnvironment(base.ApplicationTestCase):
self.check_element_on_page(by.By.LINK_TEXT, 'edited_env')
self.check_element_not_on_page(by.By.LINK_TEXT, 'test_edit_env')
def test_edit_environment_to_empty(self):
"""Test gives warning message if change environment name to empty
Scenario:
1. Create environment
2. Change environment's name to empty
3. Check warning message appear
"""
self.go_to_submenu('Environments')
self.create_environment('test_edit_env')
self.go_to_submenu('Environments')
self.edit_environment(old_name='test_edit_env', new_name='')
warning_message = 'The environment name field cannot be empty.'
self.check_alert_message(warning_message)
def test_create_env_from_the_catalog_page(self):
"""Test create environment from the catalog page