Merge "Auto-detect in i9n tests which row action to bind to"

This commit is contained in:
Jenkins 2016-03-21 18:53:37 +00:00 committed by Gerrit Code Review
commit 4a5eb9644d
6 changed files with 17 additions and 21 deletions
openstack_dashboard/test/integration_tests

@ -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)

@ -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)

@ -47,7 +47,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,

@ -44,7 +44,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,

@ -231,7 +231,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
@ -250,12 +250,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
@ -272,15 +266,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: