Flavors row level actions integration tests
Added integration tests to cover the row level actions functionality for the Admin>Flavors panel: Added test to verify update flavor info functionality Added test to verify update access functionality Implements blueprint: horizon-integration-tests-coverage Change-Id: If126f9ed74e899276b1021e1a8cb39c82bb683c5
This commit is contained in:
parent
4e384db0cf
commit
9468222929
@ -12,6 +12,7 @@
|
||||
|
||||
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 menus
|
||||
from openstack_dashboard.test.integration_tests.regions import tables
|
||||
|
||||
|
||||
@ -19,25 +20,57 @@ class FlavorsTable(tables.TableRegion):
|
||||
name = "flavors"
|
||||
|
||||
CREATE_FLAVOR_FORM_FIELDS = (("name", "flavor_id", "vcpus", "memory_mb",
|
||||
"disk_gb", "eph_gb", "swap_mb"),
|
||||
("all_projects", "selected_projects"))
|
||||
"disk_gb", "eph_gb",
|
||||
"swap_mb",
|
||||
"rxtx_factor"),
|
||||
{"members": menus.MembershipMenuRegion})
|
||||
|
||||
UPDATE_FLAVOR_FORM_FIELDS = (("name", "vcpus", "memory_mb",
|
||||
"disk_gb", "eph_gb", "swap_mb",
|
||||
"rxtx_factor"),
|
||||
{"members": menus.MembershipMenuRegion})
|
||||
|
||||
@tables.bind_table_action('create')
|
||||
def create_flavor(self, create_button):
|
||||
create_button.click()
|
||||
return forms.TabbedFormRegion(
|
||||
self.driver, self.conf,
|
||||
field_mappings=self.CREATE_FLAVOR_FORM_FIELDS)
|
||||
self.driver,
|
||||
self.conf,
|
||||
field_mappings=self.CREATE_FLAVOR_FORM_FIELDS
|
||||
)
|
||||
|
||||
@tables.bind_table_action('delete')
|
||||
def delete_flavor(self, delete_button):
|
||||
@tables.bind_row_action('update')
|
||||
def update_flavor_info(self, edit_button, row):
|
||||
edit_button.click()
|
||||
return forms.TabbedFormRegion(
|
||||
self.driver,
|
||||
self.conf,
|
||||
field_mappings=self.UPDATE_FLAVOR_FORM_FIELDS
|
||||
)
|
||||
|
||||
@tables.bind_row_action('projects')
|
||||
def update_flavor_access(self, update_button, row):
|
||||
update_button.click()
|
||||
return forms.TabbedFormRegion(
|
||||
self.driver,
|
||||
self.conf,
|
||||
field_mappings=self.UPDATE_FLAVOR_FORM_FIELDS,
|
||||
default_tab=1
|
||||
)
|
||||
|
||||
@tables.bind_row_action('delete')
|
||||
def delete_by_row(self, delete_button, row):
|
||||
delete_button.click()
|
||||
return forms.BaseFormRegion(self.driver, self.conf, None)
|
||||
return forms.BaseFormRegion(self.driver, self.conf)
|
||||
|
||||
|
||||
class FlavorsPage(basepage.BaseNavigationPage):
|
||||
DEFAULT_ID = "auto"
|
||||
FLAVORS_TABLE_NAME_COLUMN = 'name'
|
||||
FLAVORS_TABLE_VCPUS_COLUMN = 'vcpus'
|
||||
FLAVORS_TABLE_RAM_COLUMN = 'ram'
|
||||
FLAVORS_TABLE_DISK_COLUMN = 'disk'
|
||||
FLAVORS_TABLE_PUBLIC_COLUMN = 'public'
|
||||
|
||||
def __init__(self, driver, conf):
|
||||
super(FlavorsPage, self).__init__(driver, conf)
|
||||
@ -63,11 +96,51 @@ class FlavorsPage(basepage.BaseNavigationPage):
|
||||
create_flavor_form.swap_mb.value = swap_disk
|
||||
create_flavor_form.submit()
|
||||
|
||||
def delete_flavor(self, name):
|
||||
row = self._get_flavor_row(name)
|
||||
row.mark()
|
||||
confirm_delete_flavors_form = self.flavors_table.delete_flavor()
|
||||
confirm_delete_flavors_form.submit()
|
||||
|
||||
def is_flavor_present(self, name):
|
||||
return bool(self._get_flavor_row(name))
|
||||
|
||||
def update_flavor_info(self, name, add_up):
|
||||
row = self._get_flavor_row(name)
|
||||
update_flavor_form = self.flavors_table.update_flavor_info(row)
|
||||
|
||||
update_flavor_form.name.text = "edited-" + name
|
||||
update_flavor_form.vcpus.value = \
|
||||
int(update_flavor_form.vcpus.value) + add_up
|
||||
update_flavor_form.memory_mb.value =\
|
||||
int(update_flavor_form.memory_mb.value) + add_up
|
||||
update_flavor_form.disk_gb.value =\
|
||||
int(update_flavor_form.disk_gb.value) + add_up
|
||||
|
||||
update_flavor_form.submit()
|
||||
|
||||
def update_flavor_access(self, name, project_name, allocate=True):
|
||||
row = self._get_flavor_row(name)
|
||||
update_flavor_form = self.flavors_table.update_flavor_access(row)
|
||||
|
||||
if allocate:
|
||||
update_flavor_form.members.allocate_member(project_name)
|
||||
else:
|
||||
update_flavor_form.members.deallocate_member(project_name)
|
||||
|
||||
update_flavor_form.submit()
|
||||
|
||||
def delete_flavor_by_row(self, name):
|
||||
row = self._get_flavor_row(name)
|
||||
delete_form = self.flavors_table.delete_by_row(row)
|
||||
delete_form.submit()
|
||||
|
||||
def get_flavor_vcpus(self, name):
|
||||
row = self._get_flavor_row(name)
|
||||
return row.cells[self.FLAVORS_TABLE_VCPUS_COLUMN].text
|
||||
|
||||
def get_flavor_ram(self, name):
|
||||
row = self._get_flavor_row(name)
|
||||
return row.cells[self.FLAVORS_TABLE_RAM_COLUMN].text
|
||||
|
||||
def get_flavor_disk(self, name):
|
||||
row = self._get_flavor_row(name)
|
||||
return row.cells[self.FLAVORS_TABLE_DISK_COLUMN].text
|
||||
|
||||
def is_flavor_public(self, name):
|
||||
row = self._get_flavor_row(name)
|
||||
return row.cells[self.FLAVORS_TABLE_PUBLIC_COLUMN].text == "Yes"
|
||||
|
@ -10,6 +10,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import random
|
||||
|
||||
from openstack_dashboard.test.integration_tests import helpers
|
||||
from openstack_dashboard.test.integration_tests.regions import messages
|
||||
|
||||
@ -17,6 +19,35 @@ from openstack_dashboard.test.integration_tests.regions import messages
|
||||
class TestFlavors(helpers.AdminTestCase):
|
||||
FLAVOR_NAME = helpers.gen_random_resource_name("flavor")
|
||||
|
||||
def setUp(self):
|
||||
super(TestFlavors, self).setUp()
|
||||
self.flavors_page = self.home_pg.go_to_system_flavorspage()
|
||||
|
||||
def _create_flavor(self, flavor_name):
|
||||
self.flavors_page.create_flavor(
|
||||
name=flavor_name,
|
||||
vcpus=1,
|
||||
ram=1024,
|
||||
root_disk=20,
|
||||
ephemeral_disk=0,
|
||||
swap_disk=0
|
||||
)
|
||||
self.assertTrue(
|
||||
self.flavors_page.find_message_and_dismiss(messages.SUCCESS))
|
||||
self.assertFalse(
|
||||
self.flavors_page.find_message_and_dismiss(messages.ERROR))
|
||||
self.assertTrue(
|
||||
self.flavors_page.is_flavor_present(self.FLAVOR_NAME))
|
||||
|
||||
def _delete_flavor(self, flavor_name):
|
||||
self.flavors_page.delete_flavor_by_row(flavor_name)
|
||||
self.assertTrue(
|
||||
self.flavors_page.find_message_and_dismiss(messages.SUCCESS))
|
||||
self.assertFalse(
|
||||
self.flavors_page.find_message_and_dismiss(messages.ERROR))
|
||||
self.assertFalse(
|
||||
self.flavors_page.is_flavor_present(self.FLAVOR_NAME))
|
||||
|
||||
def test_flavor_create(self):
|
||||
"""tests the flavor creation and deletion functionalities:
|
||||
* creates a new flavor
|
||||
@ -24,19 +55,54 @@ class TestFlavors(helpers.AdminTestCase):
|
||||
* deletes the newly created flavor
|
||||
* verifies the flavor does not appear in the table after deletion
|
||||
"""
|
||||
self._create_flavor(self.FLAVOR_NAME)
|
||||
self._delete_flavor(self.FLAVOR_NAME)
|
||||
|
||||
flavors_page = self.home_pg.go_to_system_flavorspage()
|
||||
def test_flavor_update_info(self):
|
||||
"""Tests the flavor Edit row action finctionality:
|
||||
"""
|
||||
|
||||
self._create_flavor(self.FLAVOR_NAME)
|
||||
|
||||
add_up = random.randint(1, 10)
|
||||
old_vcpus = self.flavors_page.get_flavor_vcpus(self.FLAVOR_NAME)
|
||||
old_ram = self.flavors_page.get_flavor_ram(self.FLAVOR_NAME)
|
||||
old_disk = self.flavors_page.get_flavor_disk(self.FLAVOR_NAME)
|
||||
|
||||
self.flavors_page.update_flavor_info(self.FLAVOR_NAME, add_up)
|
||||
|
||||
flavors_page.create_flavor(name=self.FLAVOR_NAME, vcpus=1, ram=1024,
|
||||
root_disk=20, ephemeral_disk=0,
|
||||
swap_disk=0)
|
||||
self.assertTrue(
|
||||
flavors_page.find_message_and_dismiss(messages.SUCCESS))
|
||||
self.assertFalse(flavors_page.find_message_and_dismiss(messages.ERROR))
|
||||
self.assertTrue(flavors_page.is_flavor_present(self.FLAVOR_NAME))
|
||||
|
||||
flavors_page.delete_flavor(self.FLAVOR_NAME)
|
||||
self.flavors_page.find_message_and_dismiss(messages.SUCCESS))
|
||||
self.assertFalse(
|
||||
self.flavors_page.find_message_and_dismiss(messages.ERROR))
|
||||
self.assertTrue(
|
||||
flavors_page.find_message_and_dismiss(messages.SUCCESS))
|
||||
self.assertFalse(flavors_page.find_message_and_dismiss(messages.ERROR))
|
||||
self.assertFalse(flavors_page.is_flavor_present(self.FLAVOR_NAME))
|
||||
self.flavors_page.is_flavor_present("edited-" + self.FLAVOR_NAME))
|
||||
|
||||
new_vcpus = self.flavors_page.get_flavor_vcpus(
|
||||
"edited-" + self.FLAVOR_NAME)
|
||||
new_ram = self.flavors_page.get_flavor_ram(
|
||||
"edited-" + self.FLAVOR_NAME)
|
||||
new_disk = self.flavors_page.get_flavor_disk(
|
||||
"edited-" + self.FLAVOR_NAME)
|
||||
|
||||
self.assertIsNot(old_disk, new_disk)
|
||||
self.assertIsNot(old_ram, new_ram)
|
||||
self.assertIsNot(old_vcpus, new_vcpus)
|
||||
|
||||
self._delete_flavor("edited-" + self.FLAVOR_NAME)
|
||||
|
||||
def test_flavor_update_access(self):
|
||||
self._create_flavor(self.FLAVOR_NAME)
|
||||
|
||||
self.flavors_page.update_flavor_access(self.FLAVOR_NAME,
|
||||
self.HOME_PROJECT)
|
||||
|
||||
self.assertFalse(self.flavors_page.is_flavor_public(self.FLAVOR_NAME))
|
||||
|
||||
self.flavors_page.update_flavor_access(self.FLAVOR_NAME,
|
||||
self.HOME_PROJECT,
|
||||
allocate=False)
|
||||
|
||||
self.assertTrue(self.flavors_page.is_flavor_public(self.FLAVOR_NAME))
|
||||
|
||||
self._delete_flavor(self.FLAVOR_NAME)
|
||||
|
Loading…
Reference in New Issue
Block a user