def test_custom_button_expression(appliance, request, setup_obj, button_group, expression): """ Test custom button as per expression enablement/visibility. Polarion: assignee: ndhandre initialEstimate: 1/4h caseimportance: medium caseposneg: positive testtype: functional startsin: 5.9 casecomponent: CustomButton tags: custom_button testSteps: 1. Create custom button group with the Object type 2. Create a custom button with expression (Tag) a. Enablement Expression b. Visibility Expression 3. Navigate to object Detail page 4. Check: button should not enable/visible without tag 5. Check: button should enable/visible with tag """ group, obj_type = button_group exp = {expression: {"tag": "My Company Tags : Department", "value": "Engineering"}} button = group.buttons.create( text=fauxfactory.gen_alphanumeric(), hover=fauxfactory.gen_alphanumeric(), display_for="Single entity", system="Request", request="InspectMe", **exp ) request.addfinalizer(button.delete_if_exists) tag_cat = appliance.collections.categories.instantiate( name="department", display_name="Department" ) tag = tag_cat.collections.tags.instantiate(name="engineering", display_name="Engineering") view = navigate_to(setup_obj, "Details") custom_button_group = Dropdown(view, group.hover) if tag.display_name in [item.display_name for item in setup_obj.get_tags()]: if expression == "enablement": assert custom_button_group.item_enabled(button.text) setup_obj.remove_tag(tag) assert not custom_button_group.is_enabled elif expression == "visibility": assert button.text in custom_button_group.items setup_obj.remove_tag(tag) assert not custom_button_group.is_displayed else: if expression == "enablement": assert not custom_button_group.is_enabled setup_obj.add_tag(tag) assert custom_button_group.item_enabled(button.text) elif expression == "visibility": assert not custom_button_group.is_displayed setup_obj.add_tag(tag) assert button.text in custom_button_group.items
def test_open_url(request, setup_obj, button_group, method): """ Test Open url functionality of custom button. Polarion: assignee: ndhandre initialEstimate: 1/2h caseimportance: high caseposneg: positive testtype: functional startsin: 5.9 casecomponent: CustomButton tags: custom_button testSteps: 1. Appliance with Infra provider 2. Create ruby method for url functionality 3. Create custom button group with the Object type 4. Create a custom button with open_url option and respective method 5. Navigate to object Detail page 6. Execute custom button 7. Check new tab open or not with respective url """ group, obj_type = button_group button = group.buttons.create( text=fauxfactory.gen_alphanumeric(), hover=fauxfactory.gen_alphanumeric(), open_url=True, display_for="Single entity", system="Request", request=method.name, ) request.addfinalizer(button.delete_if_exists) view = navigate_to(setup_obj, "Details") custom_button_group = Dropdown(view, group.hover) assert custom_button_group.has_item(button.text) # TODO: Move windows handling functionality to browser initial_count = len(view.browser.selenium.window_handles) main_window = view.browser.selenium.current_window_handle custom_button_group.item_select(button.text) wait_for( lambda: len(view.browser.selenium.window_handles) > initial_count, timeout=120, message="Check for window open", ) open_url_window = set(view.browser.selenium.window_handles) - {main_window} view.browser.selenium.switch_to_window(open_url_window.pop()) @request.addfinalizer def _reset_window(): if view.browser.selenium.current_window_handle != main_window: view.browser.selenium.close() view.browser.selenium.switch_to_window(main_window) assert "example.com" in view.browser.url
def test_custom_button_display_service_vm(request, appliance, service_vm, button_group): """ Test custom button display on UI and SSUI vm resource detail page Polarion: assignee: ndhandre initialEstimate: 1/2h caseimportance: medium caseposneg: positive testtype: functional startsin: 5.9 casecomponent: CustomButton tags: custom_button setup: 1. Order VM from service testSteps: 1. Add custom button group for VM/Instance object from automation 2. Add custom button in above group 3. Navigate to VM Details page from service (UI and SSUI) expectedResults: 1. 2. 3. Check for button group and button displayed or not Bugzilla: 1427430 1450473 """ service, _ = service_vm with appliance.context.use(ViaUI): button = button_group.buttons.create( text=fauxfactory.gen_alphanumeric(), hover=fauxfactory.gen_alphanumeric(), system="Request", request="InspectMe", ) request.addfinalizer(button.delete_if_exists) # Check for UI and SSUI destinations. for context in [ViaUI, ViaSSUI]: with appliance.context.use(context): nav_to = ssui_nav if context is ViaSSUI else ui_nav # Navigate to VM Details page of service view = nav_to(service, "VMDetails") # Check button group and button displayed or not custom_button_group = Dropdown(view, button_group.text) assert custom_button_group.is_displayed assert custom_button_group.has_item(button.text)
def test_custom_button_quotes(appliance, provider, setup_provider, dialog, request): """ Test custom button and group allows quotes or not Polarion: assignee: ndhandre initialEstimate: 1/6h caseimportance: medium caseposneg: positive testtype: nonfunctional startsin: 5.8 casecomponent: CustomButton tags: custom_button setup: Simple TextInput service dialog testSteps: 1. Create custom button group with single quote in name like "Group's" 2. Create a custom button with quote in name like "button's" 3. Navigate to object Details page 4. Check for button group and button 5. Select/execute button from group dropdown for selected entities 6. Fill dialog and submit Check for the flash message related to button execution Bugzilla: 1646905 """ # ToDo: collect test for 5.9; If developer backport BZ-1646905 collection = appliance.collections.button_groups group = collection.create( text="Group's", hover="Group's Hover", type=getattr(collection, "PROVIDER") ) request.addfinalizer(group.delete_if_exists) button = group.buttons.create( text="Button's", hover="Button's Hover", dialog=dialog, system="Request", request="InspectMe", ) request.addfinalizer(button.delete_if_exists) view = navigate_to(provider, "Details") custom_button_group = Dropdown(view, group.hover) assert custom_button_group.has_item(button.text) custom_button_group.item_select(button.text) dialog_view = view.browser.create_view(TextInputDialogView, wait='60s') dialog_view.service_name.fill("Custom Button Execute") dialog_view.submit.click() view.flash.assert_message("Order Request was Submitted")
def test_custom_button_events_cloud_obj(request, dialog, setup_objs, button_group, btn_dialog): """Test custom button events Polarion: assignee: ndhandre caseimportance: medium initialEstimate: 1/4h caseposneg: positive testtype: functional startsin: 5.10 casecomponent: CustomButton tags: custom_button testSteps: 1. Create a Button Group 2. Create custom button [with dialog/ without dialog] 2. Execute button from respective location 3. Assert event count Bugzilla: 1668023 1702490 1680525 """ group, obj_type = button_group dialog_ = dialog if btn_dialog else None button = group.buttons.create( text="btn_{}".format(fauxfactory.gen_alphanumeric(3)), hover="btn_hover{}".format(fauxfactory.gen_alphanumeric(3)), dialog=dialog_, system="Request", request="InspectMe", ) request.addfinalizer(button.delete_if_exists) for setup_obj in setup_objs: initial_count = len(setup_obj.get_button_events()) view = navigate_to(setup_obj, "Details") custom_button_group = Dropdown(view, group.hover) custom_button_group.item_select(button.text) if btn_dialog: dialog_view = view.browser.create_view(TextInputDialogView, wait="10s") dialog_view.submit.click() view.browser.refresh() current_count = len(setup_obj.get_button_events()) assert current_count == (initial_count + 1)
def test_custom_button_display_service_obj( request, appliance, context, display, objects, button_group ): """ Test custom button display on a targeted page Polarion: assignee: ndhandre initialEstimate: 1/4h caseimportance: critical caseposneg: positive testtype: functional startsin: 5.8 casecomponent: CustomButton tags: custom_button testSteps: 1. Create custom button group with the Object type 2. Create a custom button with specific display 3. Navigate to object type page as per display selected [For service SSUI] 4. Single entity: Details page of the entity 5. List: All page of the entity 6. Single and list: Both All and Details page of the entity 7. Check for button group and button Bugzilla: 1650066 """ group, obj_type = button_group with appliance.context.use(ViaUI): button = group.buttons.create( text=fauxfactory.gen_alphanumeric(), hover=fauxfactory.gen_alphanumeric(), display_for=display, system="Request", request="InspectMe", ) request.addfinalizer(button.delete_if_exists) with appliance.context.use(context): navigate_to = ssui_nav if context is ViaSSUI else ui_nav for destination in DISPLAY_NAV[display]: obj = objects[obj_type][destination][0] dest_name = objects[obj_type][destination][1] view = navigate_to(obj, dest_name) custom_button_group = Dropdown(view, group.text) assert custom_button_group.is_displayed assert custom_button_group.has_item(button.text)
def test_custom_button_display_infra_obj(request, display, setup_obj, button_group): """ Test custom button display on a targeted page Polarion: assignee: ndhandre initialEstimate: 1/4h caseimportance: critical caseposneg: positive testtype: functional startsin: 5.8 casecomponent: CustomButton tags: custom_button testSteps: 1. Create custom button group with the Object type 2. Create a custom button with specific display 3. Navigate to object type page as per display selected 4. Single entity: Details page of the entity 5. List: All page of the entity 6. Single and list: Both All and Details page of the entity 7. Check for button group and button """ group, obj_type = button_group button = group.buttons.create( text=fauxfactory.gen_alphanumeric(), hover=fauxfactory.gen_alphanumeric(), display_for=display, system="Request", request="InspectMe", ) request.addfinalizer(button.delete_if_exists) for destination in DISPLAY_NAV[display]: obj = setup_obj.parent if destination == "All" else setup_obj # Note: For VM, custom button not display on All page but only VM page. if obj_type == "VM_INSTANCE" and destination == "All": destination = "VMsOnly" # Note: For VM Template, custom button not display on All page but only TemplatesOnly. if obj_type == "TEMPLATE_IMAGE" and destination == "All": destination = "TemplatesOnly" view = navigate_to(obj, destination) custom_button_group = Dropdown(view, group.hover) assert custom_button_group.is_displayed assert custom_button_group.has_item(button.text)
def checks(obj_type_conf): for obj_type, conf in obj_type_conf.items(): gp, button, obj = conf obj.browser.refresh() # before start checks refresh browser assert gp.exists assert button.exists view = navigate_to(button, "Details") assert view.text.text == button.text assert view.hover.text == button.hover for destination in ["All", "Details"]: # Note: For VM, custom button not display on All page but only VM page. nav_obj = obj.parent if destination == "All" else obj if obj_type == "VM_INSTANCE" and destination == "All": destination = "VMsOnly" view = navigate_to(nav_obj, destination) custom_button_group = Dropdown(view, gp.hover) assert custom_button_group.is_displayed assert custom_button_group.has_item(button.text)
def test_custom_button_text_display(appliance, context, serv_button_group, service): """ Test custom button text display on option Polarion: assignee: ndhandre initialEstimate: 1/6h caseimportance: medium caseposneg: positive testtype: functional startsin: 5.9 casecomponent: CustomButton tags: custom_button testSteps: 1. Appliance with Service 2. Create custom button `Group` or `Button` without display option 3. Check Group/Button text display or not on UI and SSUI. Bugzilla: 1650066 1659452 """ my_service = MyService(appliance, name=service.name) button, group = serv_button_group with appliance.context.use(context): navigate_to = ssui_nav if context is ViaSSUI else ui_nav destinations = ( ["Details"] if (BZ(1650066).blocks and context is ViaSSUI) else ["All", "Details"] ) for destination in destinations: view = navigate_to(my_service, destination) custom_button_group = Dropdown(view, group.text) if group.display is True: assert "" in custom_button_group.items else: assert custom_button_group.read() == ""
class TenantDetailsToolbar(View): """The toolbar on the tenant details page""" configuration = Dropdown('Configuration') policy = Dropdown('Policy') download = Button('Download summary in PDF format')
class ClusterDetailsToolbar(View): """The toolbar on the detail page""" configuration = Dropdown('Configuration') policy = Dropdown('Policy') monitoring = Dropdown('Monitoring') download = Button('Download summary in PDF format')
class BalancerToolBar(View): """ Represents balancers toolbar and its controls """ policy = Dropdown(text='Policy') download = Dropdown(text='Download') view_selector = View.nested(ItemsToolBarViewSelector)
class ServerCollectLogsToolbar(View): edit = Button(title="Edit the Log Depot settings for the selected Server") collect = Dropdown('Collect Logs')
class PhysicalChassisDetailsToolbar(View): """Represents physical chassis toolbar and its controls.""" identify = Dropdown(text="Identify")
class VolumeBackupToolbar(View): """The toolbar on the Volume Backup page""" configuration = Dropdown('Configuration') policy = Dropdown('Policy') download = Dropdown('Download') view_selector = View.nested(ItemsToolBarViewSelector)
def test_custom_button_dialog_service_archived( request, appliance, provider, setup_provider, service_vm, button_group, dialog ): """ From Service OPS check if archive vms"s dialog invocation via custom button. ref: BZ1439883 Polarion: assignee: ndhandre initialEstimate: 1/8h caseimportance: medium caseposneg: positive testtype: functional startsin: 5.9 casecomponent: CustomButton tags: custom_button testSteps: 1. Create a button at the service level with InspectMe method 2. Create a service that contains 1 VM 3. Remove this VM from the provider, resulting in a VM state of 'Archived' 4. Go to the service and try to execute the button Bugzilla: 1439883 """ service, vm = service_vm group, obj_type = button_group with appliance.context.use(ViaUI): button = group.buttons.create( text=fauxfactory.gen_alphanumeric(start="btn_"), hover=fauxfactory.gen_alphanumeric(start="hover_"), dialog=dialog, system="Request", request="InspectMe", ) request.addfinalizer(button.delete_if_exists) for with_vm in [True, False]: # [vm, archive_vm] if not with_vm: # Make vm archive by deleting vm from provider side vm.mgmt.delete() vm.wait_for_vm_state_change( desired_state="archived", timeout=720, from_details=False, from_any_provider=True ) for context in [ViaUI, ViaSSUI]: # check execution with UI and SSUI with appliance.context.use(context): navigate_to = ssui_nav if context is ViaSSUI else ui_nav view = navigate_to(service, "Details") # execute button custom_button_group = Dropdown(view, group.text) custom_button_group.item_select(button.text) _dialog_view = TextInputDialogView if context is ViaUI else TextInputDialogSSUIView dialog_view = view.browser.create_view(_dialog_view, wait="10s") # start log check request_pattern = "Attributes - Begin" log = LogValidator( "/var/www/miq/vmdb/log/automation.log", matched_patterns=[request_pattern] ) log.start_monitoring() # submit dialog dialog_view.submit.click() # SSUI not support flash messages if context is ViaUI: view.flash.assert_message("Order Request was Submitted") # Check for request in automation log try: wait_for( lambda: log.matches[request_pattern] == 1, timeout=180, message="wait for expected match count", delay=5, ) except TimedOutError: pytest.fail(f"Expected '1' requests; found '{log.matches[request_pattern]}'")
def test_custom_button_dialog_service_obj( appliance, dialog, request, context, objects, button_group ): """ Test custom button with dialog and InspectMe method Polarion: assignee: ndhandre initialEstimate: 1/4h caseimportance: medium caseposneg: positive testtype: functional startsin: 5.9 casecomponent: CustomButton tags: custom_button testSteps: 1. Create custom button group with the Object type 2. Create a custom button with service dialog 3. Navigate to object Details page 4. Check for button group and button 5. Select/execute button from group dropdown for selected entities 6. Fill dialog and submit 7. Check for the proper flash message related to button execution Bugzilla: 1574774 """ group, obj_type = button_group with appliance.context.use(ViaUI): button = group.buttons.create( text="btn_{}".format(fauxfactory.gen_alphanumeric(3)), hover="btn_hover_{}".format(fauxfactory.gen_alphanumeric(3)), dialog=dialog, system="Request", request="InspectMe", ) request.addfinalizer(button.delete_if_exists) with appliance.context.use(context): navigate_to = ssui_nav if context is ViaSSUI else ui_nav obj = objects[obj_type]["Details"][0] dest_name = objects[obj_type]["Details"][1] view = navigate_to(obj, dest_name) custom_button_group = Dropdown(view, group.text) assert custom_button_group.has_item(button.text) # Clear the automation log assert appliance.ssh_client.run_command( 'echo -n "" > /var/www/miq/vmdb/log/automation.log' ) custom_button_group.item_select(button.text) _dialog_view = TextInputDialogView if context is ViaUI else TextInputDialogSSUIView dialog_view = view.browser.create_view(_dialog_view, wait="10s") assert dialog_view.service_name.fill("Custom Button Execute") dialog_view.submit.click() # SSUI not support flash messages if context is ViaUI: view.flash.assert_message("Order Request was Submitted") # check request in log try: wait_for( log_request_check, [appliance, 1], timeout=600, message="Check for expected request count", delay=20, ) except TimedOutError: assert False, "Expected {count} requests not found in automation log".format( count=str(1) )
def test_custom_button_automate_service_obj( request, appliance, context, submit, objects, button_group ): """ Test custom button for automate and requests count as per submit Polarion: assignee: ndhandre initialEstimate: 1/4h caseimportance: high caseposneg: positive testtype: functional startsin: 5.9 casecomponent: CustomButton tags: custom_button testSteps: 1. Create custom button group with the Object type 2. Create a custom button with specific submit option and Single and list display 3. Navigate to object type pages (All and Details) 4. Check for button group and button 5. Select/execute button from group dropdown for selected entities 6. Check for the proper flash message related to button execution 7. Check automation log requests. Submitted as per selected submit option or not. 8. Submit all: single request for all entities execution 9. One by one: separate requests for all entities execution Bugzilla: 1650066 """ group, obj_type = button_group with appliance.context.use(ViaUI): button = group.buttons.create( text=fauxfactory.gen_alphanumeric(), hover=fauxfactory.gen_alphanumeric(), display_for="Single and list", submit=submit, system="Request", request="InspectMe", ) request.addfinalizer(button.delete_if_exists) with appliance.context.use(context): navigate_to = ssui_nav if context is ViaSSUI else ui_nav # BZ-1650066: no custom button on All page destinations = ( ["Details"] if context == ViaSSUI and BZ(1650066, forced_streams=["5.11"]).blocks else ["All", "Details"] ) for destination in destinations: obj = objects[obj_type][destination][0] dest_name = objects[obj_type][destination][1] view = navigate_to(obj, dest_name) custom_button_group = Dropdown(view, group.text) assert custom_button_group.has_item(button.text) # Entity count depends on the destination for `All` available entities and # `Details` means a single entity. if destination == "All": try: paginator = view.paginator except AttributeError: paginator = view.entities.paginator entity_count = min(paginator.items_amount, paginator.items_per_page) view.entities.paginator.check_all() else: entity_count = 1 # Clear the automation log assert appliance.ssh_client.run_command( 'echo -n "" > /var/www/miq/vmdb/log/automation.log' ) custom_button_group.item_select(button.text) # SSUI not support flash messages if context is ViaUI: diff = "executed" if appliance.version < "5.10" else "launched" view.flash.assert_message('"{btn}" was {diff}'.format(btn=button.text, diff=diff)) # Submit all: single request for all entity execution # One by one: separate requests for all entity execution expected_count = 1 if submit == "Submit all" else entity_count try: wait_for( log_request_check, [appliance, expected_count], timeout=600, message="Check for expected request count", delay=20, ) except TimedOutError: assert False, "Expected {count} requests not found in automation log".format( count=str(expected_count) )
def test_custom_button_expression_service_obj( appliance, context, objects, button_group, vis_enb_button ): """ Test custom button as per expression enablement/visibility. Polarion: assignee: ndhandre initialEstimate: 1/4h caseimportance: medium caseposneg: positive testtype: functional casecomponent: CustomButton startsin: 5.9 testSteps: 1. Create custom button group with the Object type 2. Create a custom button with expression (Tag) a. Enablement Expression b. Visibility Expression 3. Navigate to object Detail page 4. Check: button should not enable/visible without tag 5. Check: button should enable/visible with tag Bugzilla: 1509959 1513498 """ # ToDo: Add support for Generic Object by adding tagging ability from All page. group, obj_type = button_group button, expression = vis_enb_button obj = objects[obj_type]["Details"][0] dest_name = objects[obj_type]["Details"][1] navigate_to = ssui_nav if context is ViaSSUI else ui_nav tag_cat = appliance.collections.categories.instantiate( name="department", display_name="Department" ) tag = tag_cat.collections.tags.instantiate(name="engineering", display_name="Engineering") # Check without tag with appliance.context.use(ViaUI): if tag in obj.get_tags(): obj.remove_tag(tag) with appliance.context.use(context): view = navigate_to(obj, dest_name, wait_for_view=15) custom_button_group = ( CustomButtonSSUIDropdwon(view, group.text) if context is ViaSSUI else Dropdown(view, group.text) ) if expression == "enablement": # Note: SSUI still fallow enablement behaviour like 5.9. In latest version dropdown # having single button and button is disabled then dropdown disabled. if appliance.version < "5.10" or (context is ViaSSUI): assert not custom_button_group.item_enabled(button.text) else: assert not custom_button_group.is_enabled elif expression == "visibility": assert not custom_button_group.is_displayed # Check with tag with appliance.context.use(ViaUI): obj.add_tag(tag) # add_tag checks if its there first with appliance.context.use(context): view = navigate_to(obj, dest_name) custom_button_group = ( CustomButtonSSUIDropdwon(view, group.text) if context is ViaSSUI else Dropdown(view, group.text) ) if expression == "enablement": assert custom_button_group.item_enabled(button.text) elif expression == "visibility": assert button.text in custom_button_group.items
class KeyPairDetailsToolbar(View): policy = Dropdown('Policy') configuration = Dropdown('Configuration') download = Button(title='Download summary in PDF format')
class toolbar(View): # noqa configuration = Dropdown("Configuration") download = Button(title="Print or export summary") policy = Dropdown(text='Policy')
class TasksView(BaseLoggedInPage): # Toolbar delete = Dropdown( 'Delete Tasks') # dropdown just has icon, use element title reload = Button(title=VersionPick({ Version.lowest(): 'Reload the current display', '5.9': 'Refresh this page' })) @View.nested class tabs(View): # noqa # Extra Toolbar # Only on 'All' type tabs, but for access it doesn't make sense to access the tab for a # toolbar button cancel = Button(title='Cancel the selected task') # Form Buttons apply = Button('Apply') reset = Button('Reset') default = Button('Default') # Filters zone = BootstrapSelect(id='chosen_zone') period = BootstrapSelect(id='time_period') user = BootstrapSelect(id='user_choice') # This checkbox search_root captures all the filter options # It will break for status if/when there is second checkbox selection field added # It's the lowest level div with an id that captures the status checkboxes status = CheckboxSelect(search_root='tasks_options_div') state = BootstrapSelect(id='state_choice') @View.nested class mytasks(Tab): # noqa TAB_NAME = VersionPick({ Version.lowest(): 'My VM and Container Analysis Tasks', '5.9': 'My Tasks' }) table = Table(table_loc) @View.nested class myothertasks(Tab): # noqa TAB_NAME = VersionPick({ '5.9': 'My Tasks', Version.lowest(): 'My Other UI Tasks' }) table = Table(table_loc) @View.nested class alltasks(Tab): # noqa TAB_NAME = VersionPick({ '5.9': 'All Tasks', Version.lowest(): "All VM and Container Analysis Tasks" }) table = Table(table_loc) @View.nested class allothertasks(Tab): # noqa TAB_NAME = "All Other Tasks" table = Table(table_loc) @property def is_displayed(self): return (self.tabs.mytasks.is_displayed and self.tabs.myothertasks.is_displayed and self.tabs.alltasks.is_displayed and self.tabs.allothertasks.is_displayed)
class toolbar(View): # noqa configuration = Dropdown("Configuration") policy = Dropdown(text='Policy')
def test_custom_button_expression_ansible_service( appliance, context, vis_enb_button_service, order_ansible_service_in_ops_ui ): """ Test custom button on ansible service as per expression enablement/visibility. Polarion: assignee: ndhandre initialEstimate: 1/4h caseimportance: medium casecomponent: CustomButton startsin: 5.9 testSteps: 1. Create custom button group on Service object type 2. Create a custom button with expression (Tag) a. Enablement Expression b. Visibility Expression 3. Navigate to object Detail page 4. Check: button should not enable/visible without tag 5. Check: button should enable/visible with tag Bugzilla: 1628727 1509959 1513498 1755229 """ group, button, expression = vis_enb_button_service service = MyService(appliance, order_ansible_service_in_ops_ui) navigate_to = ssui_nav if context is ViaSSUI else ui_nav # tags tag_cat = appliance.collections.categories.instantiate( name="department", display_name="Department" ) engineering_tag = tag_cat.collections.tags.instantiate( name="engineering", display_name="Engineering" ) # check button expression with tag and without tag for tag in [False, True]: # manage tag with appliance.context.use(ViaUI): current_tag_status = engineering_tag in service.get_tags() if tag != current_tag_status: if tag: service.add_tag(engineering_tag) else: service.remove_tag(engineering_tag) # check expression with appliance.context.use(context): view = navigate_to(service, "Details", wait_for_view=15) custom_button_group = ( CustomButtonSSUIDropdwon(view, group.text) if context is ViaSSUI else Dropdown(view, group.text) ) if tag: if expression == "enablement": assert custom_button_group.item_enabled(button.text) else: # visibility assert button.text in custom_button_group.items else: if expression == "enablement": # Note: SSUI still follow enablement behaviour like 5.9. In latest version # dropdown having single button and button is disabled then dropdown disabled. if context is ViaSSUI: assert not custom_button_group.item_enabled(button.text) else: assert not custom_button_group.is_enabled else: # visibility assert not custom_button_group.is_displayed
class toolbar(View): # noqa refresh = Button(title="Refresh this page") configuration = Dropdown("Configuration") download = Button(title="Download summary in PDF format") policy = Dropdown(text='Policy')
class ObjectStoreContainerToolbar(View): """The toolbar on the Object Store Containers page""" configuration = Dropdown('Configuration') policy = Dropdown('Policy') download = Dropdown('Download') view_selector = View.nested(ItemsToolBarViewSelector)
class PhysicalChassisToolbar(View): """Represents chassis toolbar and its controls.""" identify = Dropdown(text="Identify") view_selector = View.nested(ItemsToolBarViewSelector)
class ObjectStoreContainerDetailsToolbar(View): """The toolbar on the Object Store Containers detail page""" policy = Dropdown('Policy') download = Button(title='Download summary in PDF format')
class VolumeBackupDetailsToolbar(View): """The toolbar on the Volume Backup detail page""" configuration = Dropdown('Configuration') policy = Dropdown('Policy') download = Button('Download summary in PDF format')
class DiagnosticServerWorkersToolbar(View): configuration = Dropdown('Configuration') reload_button = Button(id='refresh_workers')
class CloudNetworkToolBar(View): """ Represents cloud networks toolbar and its controls """ configuration = Dropdown(text='Configuration') policy = Dropdown(text='Policy') download = Dropdown(text='Download') view_selector = View.nested(ItemsToolBarViewSelector)
def test_custom_button_automate_infra_obj(appliance, request, submit, setup_obj, button_group): """ Test custom button for automate and requests count as per submit Polarion: assignee: ndhandre initialEstimate: 1/4h caseimportance: high caseposneg: positive testtype: functional startsin: 5.9 casecomponent: CustomButton tags: custom_button testSteps: 1. Create custom button group with the Object type 2. Create a custom button with specific submit option and Single and list display 3. Navigate to object type pages (All and Details) 4. Check for button group and button 5. Select/execute button from group dropdown for selected entities 6. Check for the proper flash message related to button execution 7. Check automation log requests. Submitted as per selected submit option or not. 8. Submit all: single request for all entities execution 9. One by one: separate requests for all entities execution Bugzilla: 1628224 """ group, obj_type = button_group button = group.buttons.create( text=fauxfactory.gen_alphanumeric(), hover=fauxfactory.gen_alphanumeric(), display_for="Single and list", submit=submit, system="Request", request="InspectMe", ) request.addfinalizer(button.delete_if_exists) for destination in ["All", "Details"]: obj = setup_obj.parent if destination == "All" else setup_obj # Note: For VM, custom button not display on `All page` but only `VM page`. if obj_type == "VM_INSTANCE" and destination == "All": destination = "VMsOnly" # Note: For VM Template, custom button not display on All page but only TemplatesOnly. if obj_type == "TEMPLATE_IMAGE" and destination == "All": destination = "TemplatesOnly" view = navigate_to(obj, destination) custom_button_group = Dropdown(view, group.hover) assert custom_button_group.has_item(button.text) # Entity count depends on the destination for `All` available entities and # `Details` means a single entity. if destination in ["All", "VMsOnly", "TemplatesOnly"]: try: paginator = view.paginator except AttributeError: paginator = view.entities.paginator entity_count = min(paginator.items_amount, paginator.items_per_page) paginator.check_all() else: entity_count = 1 # Clear the automation log assert appliance.ssh_client.run_command( 'echo -n "" > /var/www/miq/vmdb/log/automation.log' ) custom_button_group.item_select(button.text) diff = "executed" if appliance.version < "5.10" else "launched" view.flash.assert_message('"{btn}" was {diff}'.format(btn=button.text, diff=diff)) # Submit all: single request for all entity execution # One by one: separate requests for all entity execution expected_count = 1 if submit == "Submit all" else entity_count try: wait_for( log_request_check, [appliance, expected_count], timeout=600, message="Check for expected request count", delay=20, ) except TimedOutError: assert False, "Expected {} requests not found in automation log".format( str(expected_count) )
class KeyPairToolbar(View): policy = Dropdown('Policy') configuration = Dropdown('Configuration') download = Dropdown('Download') view_selector = View.nested(ItemsToolBarViewSelector)
def test_custom_button_dialog(appliance, dialog, request, setup_objs, button_group): """ Test custom button with dialog and InspectMe method Prerequisites: * Appliance with Infra provider * Simple TextInput service dialog Steps: * Create custom button group with the Object type * Create a custom button with service dialog * Navigate to object Details page * Check for button group and button * Select/execute button from group dropdown for selected entities * Fill dialog and submit * Check for the proper flash message related to button execution Bugzillas: * 1635797, 1555331, 1574403 """ group, obj_type = button_group # Note: No need to set display_for dialog only work with Single entity button = group.buttons.create( text=fauxfactory.gen_alphanumeric(), hover=fauxfactory.gen_alphanumeric(), dialog=dialog, system="Request", request="InspectMe", ) request.addfinalizer(button.delete_if_exists) for setup_obj in setup_objs: view = navigate_to(setup_obj, "Details") custom_button_group = Dropdown(view, group.hover) assert custom_button_group.has_item(button.text) custom_button_group.item_select(button.text) dialog_view = view.browser.create_view(TextInputDialogView) dialog_view.wait_displayed() dialog_view.service_name.fill("Custom Button Execute") # Clear the automation log assert appliance.ssh_client.run_command( 'echo -n "" > /var/www/miq/vmdb/log/automation.log') # Submit order request dialog_view.submit.click() if not (BZ(bug_id=1640592, forced_streams=["5.9", "5.10"]).blocks and obj_type == "TEMPLATE_IMAGE"): view.wait_displayed("60s") view.flash.assert_message("Order Request was Submitted") # Check for request in automation log try: wait_for( log_request_check, [appliance, 1], timeout=300, message="Check for expected request count", delay=20, ) except TimedOutError: assert False, "Expected 1 requests not found in automation log"
class ResourcePoolDetailsToolbar(View): """The toolbar on the details page""" configuration = Dropdown('Configuration') policy = Dropdown('Policy') download = Button(title='Print or export summary')
def test_custom_button_dialog(appliance, dialog, request, setup_objs, button_group): """ Test custom button with dialog and InspectMe method Polarion: assignee: ndhandre initialEstimate: 1/4h caseimportance: high caseposneg: positive testtype: functional startsin: 5.9 casecomponent: CustomButton tags: custom_button testSteps: 1. Simple TextInput service dialog 2. Create custom button group with the Object type 3. Create a custom button with service dialog 4. Navigate to object Details page 5. Check for button group and button 6. Select/execute button from group dropdown for selected entities 7. Fill dialog and submit 8. Check for the proper flash message related to button execution Bugzilla: 1635797, 1555331, 1574403, 1640592 """ group, obj_type = button_group # Note: No need to set display_for dialog only work with Single entity button = group.buttons.create( text=fauxfactory.gen_alphanumeric(), hover=fauxfactory.gen_alphanumeric(), dialog=dialog, system="Request", request="InspectMe", ) request.addfinalizer(button.delete_if_exists) for setup_obj in setup_objs: view = navigate_to(setup_obj, "Details") custom_button_group = Dropdown(view, group.hover) assert custom_button_group.has_item(button.text) custom_button_group.item_select(button.text) dialog_view = view.browser.create_view(TextInputDialogView, wait="10s") dialog_view.service_name.fill("Custom Button Execute") # Clear the automation log assert appliance.ssh_client.run_command( 'echo -n "" > /var/www/miq/vmdb/log/automation.log' ) # Submit order request dialog_view.submit.click() view.flash.assert_message("Order Request was Submitted") # Check for request in automation log try: wait_for( log_request_check, [appliance, 1], timeout=300, message="Check for expected request count", delay=20, ) except TimedOutError: assert False, "Expected 1 requests not found in automation log"
def test_custom_button_expression_cloud_obj(appliance, request, setup_objs, button_group, expression): """ Test custom button as per expression enablement/visibility. Polarion: assignee: ndhandre initialEstimate: 1/4h caseimportance: medium caseposneg: positive testtype: functional startsin: 5.9 casecomponent: CustomButton tags: custom_button testSteps: 1. Create custom button group with the Object type 2. Create a custom button with expression (Tag) a. Enablement Expression b. Visibility Expression 3. Navigate to object Detail page 4. Check: button should not enable/visible without tag 5. Check: button should enable/visible with tag """ group, obj_type = button_group exp = { expression: { "tag": "My Company Tags : Department", "value": "Engineering" } } button = group.buttons.create(text=fauxfactory.gen_alphanumeric(), hover=fauxfactory.gen_alphanumeric(), display_for="Single entity", system="Request", request="InspectMe", **exp) request.addfinalizer(button.delete_if_exists) tag_cat = appliance.collections.categories.instantiate( name="department", display_name="Department") tag = tag_cat.collections.tags.instantiate(name="engineering", display_name="Engineering") for setup_obj in setup_objs: view = navigate_to(setup_obj, "Details") custom_button_group = Dropdown(view, group.hover) # Note: For higher version (5.10+), button group having single button; # If button is disabled then group disabled. if tag.display_name in [ item.display_name for item in setup_obj.get_tags() ]: if expression == "enablement": assert custom_button_group.item_enabled(button.text) setup_obj.remove_tag(tag) if appliance.version < "5.10": assert not custom_button_group.item_enabled(button.text) else: assert not custom_button_group.is_enabled elif expression == "visibility": assert button.text in custom_button_group.items setup_obj.remove_tag(tag) assert not custom_button_group.is_displayed else: if expression == "enablement": if appliance.version < "5.10": assert not custom_button_group.item_enabled(button.text) else: assert not custom_button_group.is_enabled setup_obj.add_tag(tag) assert custom_button_group.item_enabled(button.text) elif expression == "visibility": assert not custom_button_group.is_displayed setup_obj.add_tag(tag) assert button.text in custom_button_group.items
class ProvDiagAllToolbar(View): """Toolbar with singular configuration dropdown""" configuration = Dropdown('Configuration')
class ZoneCollectLogToolbar(View): configuration = Dropdown('Configuration') edit = Button(title="Edit the Log Depot settings for the selected Zone") collect = Dropdown('Collect Logs')
def test_custom_button_automate(request, appliance, context, submit, objects, button_group): """ Test custom button for automate and requests count as per submit Polarion: assignee: ndhandre initialEstimate: 1/4h caseimportance: high caseposneg: positive testtype: functional startsin: 5.9 casecomponent: CustomButton tags: custom_button testSteps: 1. Create custom button group with the Object type 2. Create a custom button with specific submit option and Single and list display 3. Navigate to object type pages (All and Details) 4. Check for button group and button 5. Select/execute button from group dropdown for selected entities 6. Check for the proper flash message related to button execution 7. Check automation log requests. Submitted as per selected submit option or not. 8. Submit all: single request for all entities execution 9. One by one: separate requests for all entities execution Bugzilla: 1650066 """ group, obj_type = button_group with appliance.context.use(ViaUI): button = group.buttons.create( text=fauxfactory.gen_alphanumeric(), hover=fauxfactory.gen_alphanumeric(), display_for="Single and list", submit=submit, system="Request", request="InspectMe", ) request.addfinalizer(button.delete_if_exists) with appliance.context.use(context): navigate_to = ssui_nav if context is ViaSSUI else ui_nav # BZ-1650066: no custom button on All page destinations = ( ["Details"] if context == ViaSSUI and BZ(1650066, forced_streams=["5.9", "5.10"]).blocks else ["All", "Details"] ) for destination in destinations: obj = objects[obj_type][destination][0] dest_name = objects[obj_type][destination][1] view = navigate_to(obj, dest_name) custom_button_group = Dropdown(view, group.text) assert custom_button_group.has_item(button.text) # Entity count depends on the destination for `All` available entities and # `Details` means a single entity. if destination == "All": try: paginator = view.paginator except AttributeError: paginator = view.entities.paginator entity_count = min(paginator.items_amount, paginator.items_per_page) view.entities.paginator.check_all() else: entity_count = 1 # Clear the automation log assert appliance.ssh_client.run_command( 'echo -n "" > /var/www/miq/vmdb/log/automation.log' ) custom_button_group.item_select(button.text) # SSUI not support flash messages if context is ViaUI: view.flash.assert_message('"{button}" was executed'.format(button=button.text)) # Submit all: single request for all entity execution # One by one: separate requests for all entity execution expected_count = 1 if submit == "Submit all" else entity_count try: wait_for( log_request_check, [appliance, expected_count], timeout=600, message="Check for expected request count", delay=20, ) except TimedOutError: assert False, "Expected {count} requests not found in automation log".format( count=str(expected_count) )
class custom_button(ParametrizedView): # noqa PARAMETERS = ('button_group', ) _dropdown = Dropdown(text=Parameter('button_group')) def item_select(self, button, handle_alert=None): self._dropdown.item_select(button, handle_alert=handle_alert)
def test_custom_button_automate(appliance, request, submit, setup_objs, button_group): """ Test custom button for automate and requests count as per submit Polarion: assignee: ndhandre initialEstimate: 1/4h caseimportance: high caseposneg: positive testtype: functional startsin: 5.9 casecomponent: CustomButton tags: custom_button testSteps: 1. Create custom button group with the Object type 2. Create a custom button with specific submit option and Single and list display 3. Navigate to object type pages (All and Details) 4. Check for button group and button 5. Select/execute button from group dropdown for selected entities 6. Check for the proper flash message related to button execution 7. Check automation log requests. Submitted as per selected submit option or not. 8. Submit all: single request for all entities execution 9 One by one: separate requests for all entities execution Bugzilla: 1628224, 1642147 """ group, obj_type = button_group button = group.buttons.create( text=fauxfactory.gen_alphanumeric(), hover=fauxfactory.gen_alphanumeric(), display_for="Single and list", submit=submit, system="Request", request="InspectMe", ) request.addfinalizer(button.delete_if_exists) for setup_obj in setup_objs: for destination in ["All", "Details"]: obj = setup_obj.parent if destination == "All" else setup_obj view = navigate_to(obj, destination) custom_button_group = Dropdown(view, group.hover) assert custom_button_group.has_item(button.text) # Entity count depends on the destination for `All` available entities and # `Details` means a single entity. # To-Do: remove Manager check as BZ-1642147 fix if destination == "All": try: paginator = view.paginator except AttributeError: paginator = view.entities.paginator entity_count = min(paginator.items_amount, paginator.items_per_page) # Work around for BZ-1642147 try: if "Manager" in setup_obj.name: entity_count = 1 except AttributeError: pass paginator.check_all() else: entity_count = 1 # Clear the automation log assert appliance.ssh_client.run_command( 'echo -n "" > ' "/var/www/miq/vmdb/log/automation.log" ) custom_button_group.item_select(button.text) view.flash.assert_message('"{}" was executed'.format(button.text)) # Submit all: single request for all entity execution # One by one: separate requests for all entity execution expected_count = 1 if submit == "Submit all" else entity_count try: wait_for( log_request_check, [appliance, expected_count], timeout=300, message="Check for expected request count", delay=10, ) except TimedOutError: assert False, "Expected {} requests not found in automation log".format( str(expected_count) )
class toolbar(View): # noqa reload = Button(title='Refresh this page') policy = Dropdown(text='Policy') download = Dropdown(text='Download') view_selector = View.nested(ItemsToolBarViewSelector)