Do not redirect on env creation from catalog page

We should add opportunity to create env and add
 apps from the same page whithout redirection

Change-Id: If8af12bb9abf1b052c661e364ed16355cdabaf8d
Closes-Bug: #1425505
This commit is contained in:
Ekaterina Chernova
2015-02-26 14:39:28 +03:00
parent 152dfc0942
commit 97531bb34e
3 changed files with 44 additions and 21 deletions

View File

@@ -138,7 +138,14 @@ class CreateEnvironmentView(views.ModalFormView):
template_name = 'environments/create.html'
context_object_name = 'environment'
def get_form(self, form_class):
if 'next' in self.request.GET:
self.request.session['next_url'] = self.request.GET['next']
return super(CreateEnvironmentView, self).get_form(form_class)
def get_success_url(self):
if 'next_url' in self.request.session:
return self.request.session['next_url']
env_id = self.request.session.get('env_id')
if env_id:
del self.request.session['env_id']

View File

@@ -181,6 +181,24 @@ class UITestCase(BaseDeps):
self.driver.find_element_by_id(consts.ConfirmCreateEnvironment).click()
self.wait_for_alert_message()
def delete_environment(self, env_name):
self.select_action_for_environment(env_name, 'delete')
self.driver.find_element_by_xpath(consts.ConfirmDeletion).click()
self.wait_for_alert_message()
def edit_environment(self, old_name, new_name):
self.select_action_for_environment(old_name, 'edit')
self.fill_field(by.By.ID, 'id_name', new_name)
self.driver.find_element_by_xpath(consts.InputSubmit).click()
self.wait_for_alert_message()
def select_action_for_environment(self, env_name, action):
element_id = self.get_element_id(env_name)
more_button = consts.More.format(element_id)
self.driver.find_element_by_xpath(more_button).click()
btn_id = "murano__row_{0}__action_{1}".format(element_id, action)
self.driver.find_element_by_id(btn_id).click()
def wait_for_alert_message(self):
locator = (by.By.CSS_SELECTOR, 'div.alert-success')
log.debug("Waiting for a success message")
@@ -270,26 +288,6 @@ class ImageTestCase(PackageBase):
consts.TestImage.format(self.image_title))
class EnvironmentTestCase(UITestCase):
def delete_environment(self, env_name):
self.select_action_for_environment(env_name, 'delete')
self.driver.find_element_by_xpath(consts.ConfirmDeletion).click()
self.wait_for_alert_message()
def edit_environment(self, old_name, new_name):
self.select_action_for_environment(old_name, 'edit')
self.fill_field(by.By.ID, 'id_name', new_name)
self.driver.find_element_by_xpath(consts.InputSubmit).click()
self.wait_for_alert_message()
def select_action_for_environment(self, env_name, action):
element_id = self.get_element_id(env_name)
more_button = consts.More.format(element_id)
self.driver.find_element_by_xpath(more_button).click()
btn_id = "murano__row_{0}__action_{1}".format(element_id, action)
self.driver.find_element_by_id(btn_id).click()
class FieldsTestCase(PackageBase):
def check_error_message_is_present(self, error_message):
self.driver.find_element_by_xpath(consts.ButtonSubmit).click()

View File

@@ -40,7 +40,7 @@ class TestSuiteSmoke(base.UITestCase):
self.check_panel_is_present('Package Definitions')
class TestSuiteEnvironment(base.EnvironmentTestCase):
class TestSuiteEnvironment(base.ApplicationTestCase):
def test_create_delete_environment(self):
"""Test check ability to create and delete environment
@@ -72,6 +72,24 @@ class TestSuiteEnvironment(base.EnvironmentTestCase):
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_create_env_from_the_catalog_page(self):
"""Test create environment from the catalog page
Scenario:
1. Go the the Applications page
2. Press 'Create Env'
3. Make sure that it's possible to chose just created environment
"""
self.go_to_submenu('Applications')
self.driver.find_elements_by_xpath(
"//a[contains(text(), 'Create Env')]")[0].click()
self.fill_field(by.By.ID, 'id_name', 'TestEnv')
self.driver.find_element_by_xpath(c.InputSubmit).click()
self.wait_for_alert_message()
self.check_element_on_page(
by.By.XPATH,
"//div[@id='environment_switcher']/a[contains(text(), 'TestEnv')]")
class TestSuiteImage(base.ImageTestCase):
def test_rename_image(self):