Added tests for Identity Groups
Added integration tests for Identity Groups - Create/Delete Group - Edit Group (Row level action) Implements blueprint: horizon-integration-tests-coverage Change-Id: I163a5d6ab7d57651fe4d52fb2402b29240b04ec6
This commit is contained in:
parent
f7bf13d69b
commit
7da5ba66ba
@ -0,0 +1,84 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from openstack_dashboard.test.integration_tests.pages import basepage
|
||||
from openstack_dashboard.test.integration_tests.regions import forms
|
||||
from openstack_dashboard.test.integration_tests.regions import tables
|
||||
|
||||
|
||||
class GroupsTable(tables.TableRegion):
|
||||
|
||||
name = "groups"
|
||||
|
||||
@property
|
||||
def form_fields(self):
|
||||
return ("name", "description")
|
||||
|
||||
@tables.bind_table_action('create')
|
||||
def create_group(self, create_button):
|
||||
create_button.click()
|
||||
return forms.FormRegion(self.driver, self.conf,
|
||||
field_mappings=self.form_fields)
|
||||
|
||||
@tables.bind_table_action('delete')
|
||||
def delete_group(self, delete_button):
|
||||
delete_button.click()
|
||||
return forms.BaseFormRegion(self.driver, self.conf)
|
||||
|
||||
@tables.bind_row_action('edit')
|
||||
def edit_group(self, edit_button, row):
|
||||
edit_button.click()
|
||||
return forms.FormRegion(self.driver, self.conf,
|
||||
field_mappings=self.form_fields)
|
||||
|
||||
|
||||
class GroupsPage(basepage.BaseNavigationPage):
|
||||
|
||||
def __init__(self, driver, conf):
|
||||
super(GroupsPage, self).__init__(driver, conf)
|
||||
self._page_title = 'Groups'
|
||||
|
||||
@property
|
||||
def table_name_column(self):
|
||||
return "name"
|
||||
|
||||
@property
|
||||
def groups_table(self):
|
||||
return GroupsTable(self.driver, self.conf)
|
||||
|
||||
def _get_row_with_group_name(self, name):
|
||||
return self.groups_table.get_row(self.table_name_column, name)
|
||||
|
||||
def create_group(self, name, description=None):
|
||||
create_form = self.groups_table.create_group()
|
||||
create_form.name.text = name
|
||||
if description is not None:
|
||||
create_form.description.text = description
|
||||
create_form.submit()
|
||||
|
||||
def delete_group(self, name):
|
||||
row = self._get_row_with_group_name(name)
|
||||
row.mark()
|
||||
confirm_delete_form = self.groups_table.delete_group()
|
||||
confirm_delete_form.submit()
|
||||
|
||||
def edit_group(self, name, new_name=None, new_description=None):
|
||||
row = self._get_row_with_group_name(name)
|
||||
edit_form = self.groups_table.edit_group(row)
|
||||
if new_name is not None:
|
||||
edit_form.name.text = new_name
|
||||
if new_description is not None:
|
||||
edit_form.description.text = new_description
|
||||
edit_form.submit()
|
||||
|
||||
def is_group_present(self, name):
|
||||
return bool(self._get_row_with_group_name(name))
|
@ -0,0 +1,66 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from openstack_dashboard.test.integration_tests import helpers
|
||||
from openstack_dashboard.test.integration_tests.regions import messages
|
||||
|
||||
|
||||
class TestGroup(helpers.AdminTestCase):
|
||||
"""Checks if the user is able to create/delete/edit groups"""
|
||||
|
||||
def setUp(self):
|
||||
super(TestGroup, self).setUp()
|
||||
self.groups_page = self.home_pg.go_to_identity_groupspage()
|
||||
|
||||
@property
|
||||
def group_name(self):
|
||||
return helpers.gen_random_resource_name("group")
|
||||
|
||||
@property
|
||||
def group_description(self):
|
||||
return helpers.gen_random_resource_name('description')
|
||||
|
||||
def _test_create_group(self, group_name, group_desc=None):
|
||||
self.groups_page.create_group(name=group_name, description=group_desc)
|
||||
self.assertTrue(
|
||||
self.groups_page.find_message_and_dismiss(messages.SUCCESS))
|
||||
self.assertFalse(
|
||||
self.groups_page.find_message_and_dismiss(messages.ERROR))
|
||||
self.assertTrue(self.groups_page.is_group_present(group_name))
|
||||
|
||||
def _test_delete_group(self, group_name):
|
||||
self.groups_page.delete_group(name=group_name)
|
||||
self.assertTrue(
|
||||
self.groups_page.find_message_and_dismiss(messages.SUCCESS))
|
||||
self.assertFalse(
|
||||
self.groups_page.find_message_and_dismiss(messages.ERROR))
|
||||
self.assertFalse(self.groups_page.is_group_present(group_name))
|
||||
|
||||
def test_create_delete_group(self):
|
||||
"""Tests ability to create and delete a group"""
|
||||
group_name = self.group_name
|
||||
self._test_create_group(group_name)
|
||||
self._test_delete_group(group_name)
|
||||
|
||||
def test_edit_group(self):
|
||||
"""Tests ability to edit group name and description"""
|
||||
group_name = self.group_name
|
||||
self._test_create_group(group_name)
|
||||
new_group_name = self.group_name
|
||||
new_group_desc = self.group_description
|
||||
self.groups_page.edit_group(group_name, new_group_name, new_group_desc)
|
||||
self.assertTrue(
|
||||
self.groups_page.find_message_and_dismiss(messages.SUCCESS))
|
||||
self.assertFalse(
|
||||
self.groups_page.find_message_and_dismiss(messages.ERROR))
|
||||
self.assertTrue(self.groups_page.is_group_present(new_group_name))
|
||||
self._test_delete_group(new_group_name)
|
Loading…
Reference in New Issue
Block a user