Flavors page and basic create flavor test
Added the flavorspage under the admin tab and test_flavor_create that checks basic flavor creation and deletion. Partially implements blueprint: selenium-integration-testing Closes-Bug: #1403397 Change-Id: I9841c34b27d61195c4603109cdb7cc0d7e8633ae
This commit is contained in:
parent
e3e25a6e8b
commit
504bc18c1b
|
@ -0,0 +1,83 @@
|
||||||
|
# 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 selenium.webdriver.common import by
|
||||||
|
|
||||||
|
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 FlavorsPage(basepage.BaseNavigationPage):
|
||||||
|
DEFAULT_ID = "auto"
|
||||||
|
FLAVORS_TABLE_NAME_COLUMN_INDEX = 0
|
||||||
|
|
||||||
|
_flavors_table_locator = (by.By.CSS_SELECTOR, 'table#flavors')
|
||||||
|
|
||||||
|
FLAVORS_TABLE_ACTIONS = ("create_flavor", "delete_flavors")
|
||||||
|
FLAVORS_TABLE_ROW_ACTIONS = {
|
||||||
|
tables.ComplexActionRowRegion.PRIMARY_ACTION: "edit_flavor",
|
||||||
|
tables.ComplexActionRowRegion.SECONDARY_ACTIONS: (
|
||||||
|
"modify_access", "update_metadata", "delete_flavor")
|
||||||
|
}
|
||||||
|
|
||||||
|
CREATE_FLAVOR_FORM_FIELDS = (("name", "id_", "vcpus", "ram",
|
||||||
|
"root_disk", "ephemeral_disk",
|
||||||
|
"swap_disk"),
|
||||||
|
("all_projects", "selected_projects"))
|
||||||
|
|
||||||
|
def __init__(self, driver, conf):
|
||||||
|
super(FlavorsPage, self).__init__(driver, conf)
|
||||||
|
self._page_title = "Flavors"
|
||||||
|
|
||||||
|
def _get_row_with_flavor_name(self, name):
|
||||||
|
return self.flavors_table.get_row(
|
||||||
|
self.FLAVORS_TABLE_NAME_COLUMN_INDEX, name)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def flavors_table(self):
|
||||||
|
src_elem = self._get_element(*self._flavors_table_locator)
|
||||||
|
return tables.ComplexActionTableRegion(self.driver,
|
||||||
|
self.conf, src_elem,
|
||||||
|
self.FLAVORS_TABLE_ACTIONS,
|
||||||
|
self.FLAVORS_TABLE_ROW_ACTIONS)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def create_flavor_form(self):
|
||||||
|
return forms.TabbedFormRegion(self.driver, self.conf, None,
|
||||||
|
self.CREATE_FLAVOR_FORM_FIELDS)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def confirm_delete_flavors_form(self):
|
||||||
|
return forms.BaseFormRegion(self.driver, self.conf, None)
|
||||||
|
|
||||||
|
def create_flavor(self, name, id_=DEFAULT_ID, vcpus=None, ram=None,
|
||||||
|
root_disk=None, ephemeral_disk=None, swap_disk=None):
|
||||||
|
self.flavors_table.create_flavor.click()
|
||||||
|
self.create_flavor_form.name.text = name
|
||||||
|
if id_ is not None:
|
||||||
|
self.create_flavor_form.id_.text = id_
|
||||||
|
self.create_flavor_form.vcpus.value = vcpus
|
||||||
|
self.create_flavor_form.ram.value = ram
|
||||||
|
self.create_flavor_form.root_disk.value = root_disk
|
||||||
|
self.create_flavor_form.ephemeral_disk.value = ephemeral_disk
|
||||||
|
self.create_flavor_form.swap_disk.value = swap_disk
|
||||||
|
self.create_flavor_form.submit.click()
|
||||||
|
|
||||||
|
def delete_flavor(self, name):
|
||||||
|
row = self._get_row_with_flavor_name(name)
|
||||||
|
row.mark()
|
||||||
|
self.flavors_table.delete_flavors.click()
|
||||||
|
self.confirm_delete_flavors_form.submit.click()
|
||||||
|
|
||||||
|
def is_flavor_present(self, name):
|
||||||
|
return bool(self._get_row_with_flavor_name(name))
|
|
@ -0,0 +1,37 @@
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
import uuid
|
||||||
|
|
||||||
|
from openstack_dashboard.test.integration_tests import helpers
|
||||||
|
|
||||||
|
|
||||||
|
class TestFlavors(helpers.AdminTestCase):
|
||||||
|
FLAVOR_NAME = 'horizonflavor_' + str(uuid.uuid4())
|
||||||
|
|
||||||
|
def test_flavor_create(self):
|
||||||
|
"""tests the flavor creation and deletion functionalities:
|
||||||
|
* creates a new flavor
|
||||||
|
* verifies the flavor appears in the flavors table
|
||||||
|
* deletes the newly created flavor
|
||||||
|
* verifies the flavor does not appear in the table after deletion
|
||||||
|
"""
|
||||||
|
|
||||||
|
flavors_page = self.home_pg.go_to_system_flavorspage()
|
||||||
|
|
||||||
|
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.is_flavor_present(self.FLAVOR_NAME))
|
||||||
|
|
||||||
|
flavors_page.delete_flavor(self.FLAVOR_NAME)
|
||||||
|
self.assertFalse(flavors_page.is_flavor_present(self.FLAVOR_NAME))
|
Loading…
Reference in New Issue