Auto-detect in i9n tests which row action to bind to
It is no longer needed to specify `primary=True|False` in integration tests. Now test first tries to bind the action as primary and then (if unsuccessful) tries to bind one of secondary actions. Change-Id: Id1e2c921c15d6ef8ce7d2781623b3968ec7df374 Closes-Bug: #1552686
This commit is contained in:
parent
5bd01f3381
commit
222774b210
openstack_dashboard/test/integration_tests
pages
admin/system
project/compute
regions
@ -34,7 +34,7 @@ class HostAggregatesTable(tables.TableRegion):
|
||||
return forms.BaseFormRegion(self.driver, self.conf, None)
|
||||
|
||||
# Examples of how to bind to secondary actions
|
||||
@tables.bind_row_action('update', primary=True)
|
||||
@tables.bind_row_action('update')
|
||||
def update_host_aggregate(self, edit_host_aggregate_button, row):
|
||||
edit_host_aggregate_button.click()
|
||||
pass
|
||||
|
@ -37,13 +37,13 @@ class FloatingIPTable(tables.TableRegion):
|
||||
release_button.click()
|
||||
return forms.BaseFormRegion(self.driver, self.conf)
|
||||
|
||||
@tables.bind_row_action('associate', primary=True)
|
||||
@tables.bind_row_action('associate')
|
||||
def associate_ip(self, associate_button, row):
|
||||
associate_button.click()
|
||||
return forms.FormRegion(self.driver, self.conf,
|
||||
field_mappings=self.FLOATING_IP_ASSOCIATIONS)
|
||||
|
||||
@tables.bind_row_action('disassociate', primary=True)
|
||||
@tables.bind_row_action('disassociate')
|
||||
def disassociate_ip(self, disassociate_button, row):
|
||||
disassociate_button.click()
|
||||
return forms.BaseFormRegion(self.driver, self.conf)
|
||||
|
2
openstack_dashboard/test/integration_tests/pages/project/compute/access_and_security/keypairspage.py
2
openstack_dashboard/test/integration_tests/pages/project/compute/access_and_security/keypairspage.py
@ -29,7 +29,7 @@ class KeypairsTable(tables.TableRegion):
|
||||
self.driver, self.conf,
|
||||
field_mappings=self.CREATE_KEY_PAIR_FORM_FIELDS)
|
||||
|
||||
@tables.bind_row_action('delete', primary=True)
|
||||
@tables.bind_row_action('delete')
|
||||
def delete_keypair(self, delete_button, row):
|
||||
delete_button.click()
|
||||
return forms.BaseFormRegion(self.driver, self.conf)
|
||||
|
@ -39,7 +39,7 @@ class VolumesnapshotsTable(tables.TableRegion):
|
||||
return forms.FormRegion(self.driver, self.conf,
|
||||
field_mappings=self.EDIT_SNAPSHOT_FORM_FIELDS)
|
||||
|
||||
@tables.bind_row_action('create_from_snapshot', primary=True)
|
||||
@tables.bind_row_action('create_from_snapshot')
|
||||
def create_volume(self, create_volume_button, row):
|
||||
create_volume_button.click()
|
||||
return forms.FormRegion(self.driver, self.conf,
|
||||
|
@ -46,7 +46,7 @@ class VolumesTable(tables.TableRegion):
|
||||
delete_button.click()
|
||||
return forms.BaseFormRegion(self.driver, self.conf)
|
||||
|
||||
@tables.bind_row_action('edit', primary=True)
|
||||
@tables.bind_row_action('edit')
|
||||
def edit_volume(self, edit_button, row):
|
||||
edit_button.click()
|
||||
return forms.FormRegion(self.driver, self.conf,
|
||||
|
@ -209,7 +209,7 @@ def bind_table_action(action_name):
|
||||
return decorator
|
||||
|
||||
|
||||
def bind_row_action(action_name, primary=False):
|
||||
def bind_row_action(action_name):
|
||||
"""A decorator to bind table region method to an actual row action button.
|
||||
|
||||
Many table actions when started (by clicking a corresponding button
|
||||
@ -228,12 +228,6 @@ def bind_row_action(action_name, primary=False):
|
||||
Part of the action button id which is specific to action itself. It
|
||||
is safe to use action `name` attribute from the dashboard tables.py
|
||||
code.
|
||||
|
||||
.. param:: primary
|
||||
|
||||
Whether an action being bound is primary or secondary. In latter case
|
||||
a button drop-down needs to be clicked prior to clicking a button.
|
||||
Defaults to `False`.
|
||||
"""
|
||||
# NOTE(tsufiev): button tag could be either <a> or <button> - target
|
||||
# both with *. Also primary action could be single as well, do not use
|
||||
@ -250,15 +244,17 @@ def bind_row_action(action_name, primary=False):
|
||||
def decorator(method):
|
||||
@functools.wraps(method)
|
||||
def wrapper(table, row):
|
||||
action_element = None
|
||||
if primary:
|
||||
action_element = row._get_element(*primary_action_locator)
|
||||
else:
|
||||
def find_action(element):
|
||||
pattern = "__action_%s" % action_name
|
||||
return element.get_attribute('id').endswith(pattern)
|
||||
|
||||
action_element = row._get_element(*primary_action_locator)
|
||||
if not find_action(action_element):
|
||||
action_element = None
|
||||
row._get_element(*secondary_actions_opener_locator).click()
|
||||
for action in row._get_elements(*secondary_actions_locator):
|
||||
pattern = "__action_%s" % action_name
|
||||
if action.get_attribute('id').endswith(pattern):
|
||||
action_element = action
|
||||
for element in row._get_elements(*secondary_actions_locator):
|
||||
if find_action(element):
|
||||
action_element = element
|
||||
break
|
||||
|
||||
if action_element is None:
|
||||
|
Loading…
x
Reference in New Issue
Block a user