class fields(ParametrizedView): # noqa PARAMETERS = ("key", ) input = Input(id=Parameter("key")) param_input = Input(id=ParametrizedString("param_{key}")) dropdown = VersionPick({ Version.lowest(): BootstrapSelect(Parameter("key")), "5.9": DialogFieldDropDownList( ParametrizedLocator(".//div[@input-id={key|quote}]")) }) param_dropdown = VersionPick({ Version.lowest(): BootstrapSelect(ParametrizedString("param_{key}")), "5.9": DialogFieldDropDownList( ParametrizedLocator(".//div[@input-id='param_{key}']")) }) @property def visible_widget(self): if self.input.is_displayed: return self.input elif self.dropdown.is_displayed: return self.dropdown elif self.param_input.is_displayed: return self.param_input elif self.param_dropdown.is_displayed: return self.param_dropdown def read(self): return self.visible_widget.read() def fill(self, value): return self.visible_widget.fill(value)
class ButtonDetailView(AutomateCustomizationView): title = Text('#explorer_title_text') text = SummaryFormItem( 'Basic Information', VersionPick({Version.lowest(): 'Button Text', '5.9': 'Text'}), text_filter=lambda text: re.sub(r'\s+Display on Button\s*$', '', text)) hover = SummaryFormItem( 'Basic Information', VersionPick({Version.lowest(): 'Button Hover Text', '5.9': 'Hover Text'})) dialog = SummaryFormItem('Basic Information', 'Dialog') system = SummaryFormItem('Object Details', 'System/Process/') message = SummaryFormItem('Object Details', 'Message') request = SummaryFormItem('Object Details', 'Request') type = SummaryFormItem('Object Attribute', 'Type') show = SummaryFormItem('Visibility', 'Show') @property def is_displayed(self): return ( self.in_customization and self.title.text == 'Button "{}"'.format(self.context['object'].text) and not self.buttons.is_dimmed and self.buttons.is_opened and self.buttons.tree.currently_selected == [ 'Object Types', self.context['object'].group.type, self.context['object'].group.text, self.context['object'].text])
class options(PotentiallyInvisibleTab): # noqa form = ConditionalSwitchableView(reference="type") type = VersionPick({ Version.lowest(): FakeWidget(read_value='Default'), '5.9': BootstrapSelect('button_type') }) @form.register('Default') class ButtonFormDefaultView(View): # noqa dialog = BootstrapSelect('dialog_id') @form.register('Ansible Playbook') class ButtonFormAnsibleView(View): # noqa playbook_cat_item = BootstrapSelect('service_template_id') inventory = AutomateRadioGroup( locator=".//input[@name='inventory']/..") hosts = Input(name='hosts') text = Input(name='name') display = Checkbox(name='display') hover = Input(name='description') image = VersionPick({ Version.lowest(): BootstrapSelect('button_image'), '5.9': FonticonPicker('button_icon') }) open_url = Checkbox('open_url')
class ButtonGroupDetailView(AutomateCustomizationView): title = Text('#explorer_title_text') text = SummaryFormItem( 'Basic Information', VersionPick({ Version.lowest(): 'Button Group Text', '5.9': 'Text' }), text_filter=lambda text: re.sub(r'\s+Display on Button\s*$', '', text)) hover = SummaryFormItem( 'Basic Information', VersionPick({ Version.lowest(): 'Button Group Hover Text', '5.9': 'Hover Text' })) @property def is_displayed(self): return (self.in_customization and self.title.text == 'Button Group "{}"'.format(self.context['object'].text) and self.buttons.is_opened and not self.buttons.is_dimmed and self.buttons.tree.currently_selected == [ 'Object Types', self.context['object'].type, self.context['object'].text ])
class grid_tile_icons(View): # noqa infra_provider_quad = BootstrapSwitch(VersionPicker({Version.lowest(): 'quadicons_ems', '5.10': 'quadicons_infra_manager'})) cloud_provider_quad = BootstrapSwitch(VersionPicker( {Version.lowest(): 'quadicons_ems_cloud', '5.10': 'quadicons_cloud_manager'})) containers_provider_quad = BootstrapSwitch('quadicons_container_manager') host_quad = BootstrapSwitch('quadicons_host') datastore_quad = BootstrapSwitch('quadicons_storage') vm_quad = BootstrapSwitch('quadicons_vm') template_quad = BootstrapSwitch('quadicons_miq_template') long_text = BootstrapSelect('quad_truncate')
class VolumeAddForm(View): storage_manager = BootstrapSelect(name='storage_manager_id') tenant = BootstrapSelect(name='cloud_tenant_id') # is for openstack block storage only volume_name = TextInput(name='name') volume_type = BootstrapSelect(name=VersionPicker({Version.lowest(): 'aws_volume_type', '5.10': 'volume_type'})) volume_size = TextInput(name='size') # az is for ec2 block storage only az = BootstrapSelect( name=VersionPicker( {Version.lowest(): 'aws_availability_zone_id', '5.11': 'availability_zone_id'})) iops = TextInput(name='aws_iops') # is for ec2 block storage only encryption = BootstrapSwitch(name="aws_encryption") # is for ec2 block storage only add = Button('Add') cancel = Button('Cancel')
class GenericObjectButtonGroupAddView(GenericObjectDefinitionView): title = Text('#explorer_title_text') name = Input(name='name') display = BootstrapSwitch(name='display') description = Input(name='description') image = VersionPick({ Version.lowest(): BootstrapSelect('button_image'), '5.9': FonticonPicker('button_icon')}) add = Button('Add') cancel = Button('Cancel') @property def is_displayed(self): return ( self.title.text == 'GenericObjectButtonGroupAddView' and self.name.is_displayed and self.in_generic_object_definition ) def after_fill(self, was_change): # we need to click somewhere out side the form to get add button active, # after icon is filled if was_change: self.browser.element('//body').click()
class ActionFormCommon(ControlExplorerView): description = Input("description") action_type = BootstrapSelect("miq_action_type") snapshot_name = Input("snapshot_name") analysis_profile = BootstrapSelect("analysis_profile") alerts_to_evaluate = MultiBoxSelect() snapshot_age = BootstrapSelect("snapshot_age") parent_type = BootstrapSelect("parent_type") cpu_number = BootstrapSelect("cpu_value") memory_amount = Input("memory_value") email_sender = Input("from") email_recipient = Input("to") vcenter_attr_name = Input("attribute") vcenter_attr_value = Input("value") tag = VersionPicker({ Version.lowest(): ManageIQTree("action_tags_treebox"), "5.11": SectionedBootstrapSelect("tag") }) remove_tag = CheckboxSelect("action_options_div") run_ansible_playbook = View.nested(RunAnsiblePlaybookFromView) automation_message = Input("object_message") automation_request = Input("object_request") attribute_value_pair = AttributeValueForm('attribute_', 'value_') cancel_button = Button("Cancel")
def infra_mapping_default_data(source_provider, provider): """ Default data for infrastructure mapping form. It is used in other methods to recursive update the data according to parameters in tests. Args: source_provider: Vmware provider provider: Target rhev/OSP provider """ plan_type = VersionPicker({Version.lowest(): None, "5.10": "rhv" if provider.one_of(RHEVMProvider) else "osp"}).pick() infra_mapping_data = { "name": "infra_map_{}".format(fauxfactory.gen_alphanumeric()), "description": "Single Datastore migration of VM from {ds_type1} to {ds_type2}".format( ds_type1="nfs", ds_type2="nfs" ), "plan_type": plan_type, "clusters": [component_generator("clusters", source_provider, provider)], "datastores": [component_generator( "datastores", source_provider, provider, get_data(source_provider, "datastores", "nfs").type, get_data(provider, "datastores", "nfs").type)], "networks": [ component_generator("vlans", source_provider, provider, get_data(source_provider, "vlans", "VM Network"), get_data(provider, "vlans", "ovirtmgmt")) ], } return infra_mapping_data
def infra_mapping_default_data(source_provider, provider): """ Default data for infrastructure mapping form. It is used in other methods to recursive update the data according to parameters in tests. Args: source_provider: Vmware provider provider: Target rhev/OSP provider """ plan_type = VersionPicker({Version.lowest(): None, "5.10": "rhv" if provider.one_of(RHEVMProvider) else "osp"}).pick() infra_mapping_data = { "name": fauxfactory.gen_alphanumeric(15, start="infra_map_"), "description": f"migration with vmware to {plan_type}", "plan_type": plan_type, "clusters": [component_generator("clusters", source_provider, provider)], "datastores": [component_generator( "datastores", source_provider, provider, get_data(source_provider, "datastores", "nfs").type, get_data(provider, "datastores", "nfs").type)], "networks": [ component_generator("vlans", source_provider, provider, get_data(source_provider, "vlans", "VM Network"), get_data(provider, "vlans", "ovirtmgmt")) ], } return infra_mapping_data
def is_displayed(self): return ( self.in_tower_explorer and self.title.text == VersionPicker({Version.lowest(): 'All Ansible Tower Job Templates', '5.10': 'All Ansible Tower Templates'}).pick(self.browser.product_version) and self.sidebar.job_templates.is_opened )
def test_rhsm_registration_check_repo_names( temp_appliance_preconfig_funcscope, soft_assert, appliance): """ Checks default rpm repos on a fresh appliance Polarion: assignee: jhenner caseimportance: high initialEstimate: 1/4h """ ver = temp_appliance_preconfig_funcscope.version.series() repos = cfme_data.redhat_updates.repos # TODO We need the context manager here as RedHatUpdates doesn't yet support Collections. with temp_appliance_preconfig_funcscope: repo_names = VersionPicker({ Version.lowest(): repos.pre_592, Version('5.9.3'): repos.post_592, Version('5.10.0'): repos.post_510 }).pick(temp_appliance_preconfig_funcscope.version) view = navigate_to(RedHatUpdates, 'Edit') soft_assert( view.repo_name.read() == 'cf-me-{}-for-rhel-7-rpms {}'.format(ver, repo_names)) """checks current repo names""" view.repo_default_name.click() """resets repos with default button and checks they are also correct""" soft_assert( view.repo_name.read() == 'cf-me-{}-for-rhel-7-rpms {}'.format(ver, repo_names))
class OrderForm(ServicesCatalogView): title = Text('#explorer_title_text') dialog_title = Text( VersionPick({ Version.lowest(): ".//div[@id='main_div']//h3", "5.9": ".//div[@id='main_div']//h2" })) timeout = Input(name='stack_timeout') db_user = Input(name="param_DBUser__protected") db_root_password = Input(name='param_DBRootPassword__protected') select_instance_type = BootstrapSelect("param_InstanceType") stack_name = Input(name='stack_name') stack_timeout = Input(name='stack_timeout') resource_group = BootstrapSelect("resource_group") mode = BootstrapSelect('deploy_mode') vm_name = Input(name="param_virtualMachineName") vm_user = Input(name='param_adminUserName') vm_password = Input(name="param_adminPassword__protected") vm_size = BootstrapSelect('param_virtualMachineSize') user_image = BootstrapSelect("param_userImageName") os_type = BootstrapSelect('param_operatingSystemType') key_name = Input(name="param_KeyName") ssh_location = Input(name="param_SSHLocation") flavor = Input(name='param_flavor') image = Input(name="param_image") key = Input(name='param_key') private_network = Input(name="param_private_network") default_select_value = BootstrapSelect('service_level') machine_credential = BootstrapSelect("credential") hosts = Input(name="hosts")
def is_displayed(self): return (self.in_tower_explorer and self.title.text == VersionPicker( { Version.lowest(): 'All Ansible Tower Job Templates', '5.10': 'All Ansible Tower Templates' }).pick(self.browser.product_version) and self.sidebar.job_templates.is_opened)
def is_displayed(self): form_title_text = VersionPicker({ Version.lowest(): 'Migration Plan Wizard', '5.10': 'Create Migration Plan' }) return self.title.text == form_title_text.pick()
def is_displayed(self): location = VersionPicker({ Version.lowest(): 'Cloud Providers', '5.11': self.context['object'].name }).pick() return (self.breadcrumb.locations[-2] == location and self.entities.title.text == self.breadcrumb.active_location)
class AddInfrastructureMappingView(InfrastructureMappingForm): form_title_text = VersionPicker( { Version.lowest(): "Infrastructure Mapping Wizard", "5.10": "Create Infrastructure Mapping", } )
def is_displayed(self): form_title_text = VersionPicker({ Version.lowest(): 'Infrastructure Mapping Wizard', '5.10': 'Create Infrastructure Mapping' }) return (self.form.title.text == form_title_text.pick())
class fields(ParametrizedView): # noqa PARAMETERS = ("key", ) input = Input(id=Parameter("key")) select = Select(id=Parameter("key")) param_input = Input(id=ParametrizedString("param_{key}")) dropdown = VersionPick({ Version.lowest(): BootstrapSelect(Parameter("key")), "5.9": BootstrapSelect(locator=ParametrizedLocator( './/div[contains(@class, "bootstrap-select")]/select[@id={key|quote}]/..' )) }) param_dropdown = VersionPick({ Version.lowest(): BootstrapSelect(ParametrizedString("param_{key}")), "5.9": BootstrapSelect(locator=ParametrizedLocator( ".//div[contains(@class, 'bootstrap-select')]/select[@id='param_{key}']/.." )) }) @property def visible_widget(self): if self.browser.wait_for_element(self.input.locator, exception=False): return self.input elif self.browser.wait_for_element(self.dropdown.locator, exception=False): return self.dropdown elif self.browser.wait_for_element(self.param_input.locator, exception=False): return self.param_input elif self.browser.wait_for_element(self.param_dropdown.locator, exception=False): return self.param_dropdown elif self.browser.wait_for_element(self.select.locator, exception=False): return self.select else: raise ItemNotFound("Visible widget is not found") def read(self): return self.visible_widget.read() def fill(self, value): return self.visible_widget.fill(value)
class filters(Accordion): # noqa ACCORDION_NAME = VersionPicker({ Version.lowest(): 'Filters', '5.11': 'Global Filters' }) navigation = BootstrapNav('.//div/ul') tree = ManageIQTree()
class form(View): # noqa tags = VersionPicker({ Version.lowest(): Table("//div[@id='assignments_div']//table"), "5.11": ParametrizedView.nested(AssignedTags) }) tag_category = VersionPicker({ Version.lowest(): BootstrapSelect(id='tag_cat'), "5.11": ReactSelect(locator='.//div[@id="tag_cat"]') }) tag_name = VersionPicker({ Version.lowest(): BootstrapSelect(id='tag_add'), "5.11": ReactSelect(locator='.//div[@id="cat_tags_div"]') }) entities = View.nested(BaseNonInteractiveEntitiesView) save = Button('Save') reset = Button('Reset') cancel = Button('Cancel')
class BalancerDetailsToolBar(BalancerToolBar): """ Represents details toolbar of balancer summary """ download = VersionPicker({ Version.lowest(): Button(title='Download summary in PDF format'), "5.10": Button(title='Print or export summary') })
class CloudNetworkDetailsToolBar(View): """ Represents provider details toolbar """ policy = Dropdown(text='Policy') download = VersionPicker({ Version.lowest(): Button(title='Download summary in PDF format'), "5.10": Button(title='Print or export summary') })
class NetworkProviderDetailsToolBar(NetworkProviderToolBar): """ Represents provider details toolbar """ monitoring = Dropdown(text='Monitoring') download = VersionPicker({ Version.lowest(): Button(title='Download summary in PDF format'), "5.10": Button(title='Print or export summary') })
class ButtonGroupFormCommon(AutomateCustomizationView): text = Input(name='name') display = Checkbox(name='display') hover = Input(name='description') image = VersionPick({ Version.lowest(): BootstrapSelect('button_image'), '5.9': FonticonPicker('button_icon')}) cancel_button = Button('Cancel')
class EC2AzoneUtilizationView(AzoneCloudUtilizationView): """Availability zone Utilization view for AWS providers""" azone_disk = LineChart(id='miq_chart_parent_candu_1') azone_network = LineChart(id='miq_chart_parent_candu_2') azone_network_avg = LineChart(id='miq_chart_parent_candu_2_2') azone_instance = VersionPicker({ Version.lowest(): LineChart(id='miq_chart_parent_candu_4'), '5.10': LineChart(id='miq_chart_parent_candu_3') })
class FloatingIpDetailsToolBar(View): """ Represents toolbar of summary of port """ policy = Dropdown(text='Policy') download = VersionPicker({ Version.lowest(): Button(title='Download summary in PDF format'), "5.10": Button(title='Print or export summary') })
def test_retire_vm_future(appliance, vm, from_collection): """Test retirement of vm Prerequisities: * An appliance with ``/api`` available. * VM Steps: * POST /api/vms/<id> (method ``retire``) with the ``retire_date`` OR * POST /api/vms (method ``retire``) with the ``retire_date`` and ``href`` of the vm or vms Metadata: test_flag: rest Bugzilla: 1805119 1827787 Polarion: assignee: pvala casecomponent: Infra caseimportance: high initialEstimate: 1/3h """ retire_action = VersionPicker({ Version.lowest(): 'retire', '5.11': 'request_retire' }).pick() retire_vm = appliance.rest_api.collections.vms.get(name=vm) date = (datetime.datetime.now() + datetime.timedelta(days=5)).strftime("%Y/%m/%d") future = {"date": date, "warn": "4"} if from_collection: future.update(retire_vm._ref_repr()) getattr(appliance.rest_api.collections.vms.action, retire_action)(future) else: getattr(retire_vm.action, retire_action)(**future) assert_response(appliance) def _finished(): retire_vm.reload() if not hasattr(retire_vm, "retires_on"): return False if not hasattr(retire_vm, "retirement_warn"): return False if not hasattr(retire_vm, "retirement_state"): return False return True wait_for(_finished, num_sec=1500, delay=10, message="REST vm retire future")
class TenantAddForm(View): """The form on the Add page""" cloud_provider = BootstrapSelect(id='ems_id') name = Input('name') save_button = VersionPick({ Version.lowest(): Button('Save'), '5.9': Button('Add') }) reset_button = Button('Reset') cancel_button = Button('Cancel')
class AddInfrastructureMappingView(View): form = InfraMappingWizard() form_title_text = VersionPicker({ Version.lowest(): 'Infrastructure Mapping Wizard', '5.10': 'Create Infrastructure Mapping' }) @property def is_displayed(self): return (self.form.title.text == self.form_title_text)
class SecurityGroupDetailsToolBar(View): """ Represents provider details toolbar """ policy = Dropdown(text='Policy') download = VersionPicker({ Version.lowest(): Button(title='Download summary in PDF format'), "5.10": Button(title='Print or export summary') }) view_selector = View.nested(ItemsToolBarViewSelector)
class SubnetDetailsToolBar(View): """ Represents provider details toolbar """ configuration = Dropdown(text='Configuration') policy = Dropdown(text='Policy') download = VersionPicker({ Version.lowest(): Button(title='Download summary in PDF format'), "5.10": Button(title='Print or export summary') })
def setup_ha_env(cfme_version, provider_type, provider, lease, desc): lease_time = tot_time(lease) provider_type = None if provider else provider_type """multi appliance setup consisting of dedicated primary and standy databases with a single UI appliance.""" print("Provisioning and configuring HA environment") apps, request_id = provision_appliances(count=3, cfme_version=cfme_version, provider_type=provider_type, provider=provider, lease_time=lease_time) sprout_client = SproutClient.from_config() sprout_client.set_pool_description(request_id, desc) ip0 = apps[0].hostname ip1 = apps[1].hostname ip2 = apps[2].hostname opt = '5' if cfme_version >= "5.8" else '8' rep = '6' if cfme_version >= "5.8" else '9' mon = VersionPicker({ Version.lowest(): '12', '5.8': '9', '5.9.3': '8' }).pick(cfme_version) port = (ip0, '') if cfme_version >= "5.8" else (ip0,) command_set0 = ('ap', '', opt, '1', '1', '1', 'y', pwd, TimedCommand(pwd, 360), '') apps[0].appliance_console.run_commands(command_set0) wait_for(lambda: apps[0].db.is_dedicated_active) print("Dedicated database provisioned and configured {}".format(ip0)) command_set1 = ('ap', '', opt, '1', '2', '1', 'y') + port + ('', '', pwd, TimedCommand(pwd, 360), '') apps[1].appliance_console.run_commands(command_set1) apps[1].evmserverd.wait_for_running() apps[1].wait_for_web_ui() print("Non-VMDB appliance provisioned and region created {}".format(ip1)) command_set2 = ('ap', '', rep, '1', '1', '', '', pwd, pwd, ip0, 'y', '') apps[0].appliance_console.run_commands(command_set2) print("Primary HA node configured {}".format(ip0)) command_set3 = ('ap', '', rep, '2', '1', '2', '', '', pwd, pwd, ip0, ip2, 'y', TimedCommand('y', 300), '') apps[2].appliance_console.run_commands(command_set3) print("Secondary HA node provision and configured {}".format(ip2)) command_set4 = ('ap', '', mon, '1', '') apps[1].appliance_console.run_commands(command_set4) print("HA configuration complete") print("Appliance pool lease time is {}".format(lease))
def get_dialog_service_name(appliance, service_request, *item_names): """Helper to DRY this VersionPicker when tests need to determine a dialog service name In gaprindashvili+ its available in the service_request options In earlier versions it has to be parsed from the message """ def _regex_parse_name(items, message): for item in items: match = re.search(r'\[({}[0-9-]*)\] '.format(item), message) if match: return match.group(1) else: continue else: raise ValueError('Could not match name from items in given service request message') return VersionPicker({ Version.lowest(): lambda: _regex_parse_name(item_names, service_request.message), '5.10': lambda: service_request.options.get('dialog', {}).get('dialog_service_name', '') }).pick(appliance.version)() # run lambda after picking
def pytest_generate_tests(metafunc): """ Build a list of tuples containing (group_name, context) Returns: tuple containing (group_name, context) where group_name is a string and context is ViaUI/SSUI """ appliance = find_appliance(metafunc) parameter_list = [] id_list = [] # TODO: Include SSUI role_access dict and VIASSUI context role_access_ui = VersionPicker({ Version.lowest(): role_access_ui_59z, '5.10': role_access_ui_510z }).pick(appliance.version) logger.info('Using the role access dict: %s', role_access_ui) roles_and_context = [( role_access_ui, ViaUI) ] for role_access, context in roles_and_context: for group in role_access.keys(): parameter_list.append((group, role_access, context)) id_list.append('{}-{}'.format(group, context)) metafunc.parametrize('group_name, role_access, context', parameter_list)
def step(self, *args, **kwargs): self.view.sidebar.job_templates.tree.click_path(VersionPicker({Version.lowest(): 'All Ansible Tower Job Templates', '5.10': 'All Ansible Tower Templates'}).pick( self.view.browser.product_version))