class repositories(SatTab): lce_filter = SatSelect(".//select[@ng-model='environmentFilter']") cv_filter = SatSelect(".//select[@ng-model='contentViewFilter']") searchbox = Search() table = SatTable(locator=".//table", column_widgets={ 'Name': Text("./a"), 'Product': Text("./a"), }) def search(self, query, lce=None, cv=None): """Apply available filters before proceeding with searching. :param str query: search query to type into search field. :param str optional lce: filter by lifecycle environment name :param str optional cv: filter by content view name :return: list of dicts representing table rows :rtype: list """ if lce: self.lce_filter.fill(lce) if cv: self.cv_filter.fill(cv) self.searchbox.search(query) return self.table.read()
class ApplyErrataView(BaseLoggedInView): breadcrumb = BreadCrumb() environment_filter = SatSelect(".//select[@ng-model='environmentFilter']") searchbox = Search() next_button = Text(".//button[@ng-click='goToNextStep()']") table = SatTable(locator=".//table", column_widgets={ 0: Checkbox(locator="./input[@type='checkbox']"), 'Name': Text("./a"), }) def search(self, query, environment=None): """Apply environment filter before proceeding with searching. :param str query: search query to type into search field. :param str optional environment: filter by environment name :return: list of dicts representing table rows :rtype: list """ if environment: self.environment_filter.fill(environment) self.searchbox.search(query) return self.table.read() @property def is_displayed(self): breadcrumb_loaded = self.browser.wait_for_element(self.breadcrumb, exception=False) return (breadcrumb_loaded and self.breadcrumb.locations[0] == 'Errata' and self.breadcrumb.read() == 'Select Content Host(s)')
class create_repo(View): """Represent Create Repository page. Depends whether we like create new product or use existing one we use different sets of fields that need to be filled """ product_type = SatSelect( locator="//select[@ng-model='createRepoChoices.newProduct']") product_content = ConditionalSwitchableView(reference='product_type') @product_content.register('Existing Product') class ExistingProductForm(View): product_name = Select(locator="//select[@ng-model=" "'createRepoChoices.existingProductId']") @product_content.register('New Product') class NewProductForm(View): product_name = TextInput(id='productName') label = TextInput(id='productLabel') gpg_key = Select( locator="//select[contains(@ng-model,'gpg_key_id')]") serve_via_http = Checkbox(id='unprotected') verify_ssl = Checkbox(id='verify_ssl') run_procedure = Text( "//button[contains(., 'Run Repository Creation')]") create_repos_table = SatTable('//table') def wait_repo_created(self): wait_for(lambda: self.create_repos_table.row( create_status__contains='Repository created').is_displayed is True, timeout=300, delay=1, logger=self.logger)
class content_hosts(SatTab): TAB_NAME = 'Content Hosts' environment_filter = SatSelect( ".//select[@ng-model='environmentFilter']") searchbox = Search() apply = Text(".//button[@ng-click='goToNextStep()']") table = SatTable( locator=".//table", column_widgets={ 0: Checkbox(locator="./input[@type='checkbox']"), 'Name': Text("./a"), }, ) def search(self, query, environment=None): """Apply environment filter before proceeding with searching. :param str query: search query to type into search field. :param str optional environment: filter by environment name :return: list of dicts representing table rows :rtype: list """ if environment: self.environment_filter.fill(environment) self.searchbox.search(query) return self.table.read()
class CVFRuleVersion(View): """'Version' column for content view filter rule. Depending on type (e.g. 'Equal To', 'Greater Than' etc) can have different set of inputs. """ rule_type = SatSelect(locator=".//select[@ng-model='rule.type']") rule = ConditionalSwitchableView(reference='rule_type') version_text = Text( ".//span[@ng-hide='rule.editMode']//descendant::span[last()]") @rule.register('All Versions') class all_versions(View): pass @rule.register('Equal To') class equal_to(View): version = TextInput(id='version') @rule.register('Greater Than') class greater_than(View): min_version = TextInput(id='minVersion') @rule.register('Less Than') class less_than(View): max_version = TextInput(id='maxVersion') @rule.register('Range') class range(View): min_version = TextInput(id='minVersion') max_version = TextInput(id='maxVersion') def fill(self, values): """Custom fill to support passing values for all inputs in single tuple without the need to specify specific input name. :param tuple values: tuple containing values for specific version type and its inputs, e.g. `('Equal To', '0.5')` or `('Range', '4.1', '4.6')` """ if not isinstance(values, tuple): values = (values, ) was_change = self.rule_type.fill(values[0]) if len(values) == 1: return was_change widgets_list = [ 'rule.{}'.format(name) for name in self.rule.widget_names ] values = dict(zip(widgets_list, values[1:])) return super().fill(values) or was_change def read(self): """Custom `read` to return "summary" text value, not the dict with every included widget separately. """ return self.version_text.read()
class packages(SatTab): cv_filter = SatSelect(".//select[@ng-model='contentView']") repo_filter = SatSelect(".//select[@ng-model='repository']") searchbox = Search() table = SatTable(locator=".//table") def search(self, query, cv=None, repo=None): """Apply available filters before proceeding with searching. :param str query: search query to type into search field. :param str optional cv: filter by content view name :param str optional repo: filter by repository name :return: list of dicts representing table rows :rtype: list """ if cv: self.cv_filter.fill(cv) if repo: self.repo_filter.fill(repo) self.searchbox.search(query) return self.table.read()
class ErratumView(BaseLoggedInView): title = Text("//h1[contains(., 'Errata')]") table = SatTable( locator='.//table', column_widgets={ 0: Checkbox(locator=".//input[@type='checkbox']"), 'Errata ID': Text("./a"), } ) repo_filter = SatSelect(".//select[@ng-model='repository']") applicable_filter = Checkbox( locator=".//input[@ng-model='showApplicable']") installable_filter = Checkbox( locator=".//input[@ng-model='showInstallable']") apply_errata = Text( ".//button[contains(@class, 'btn-primary')]" "[@ng-click='goToNextStep()']" ) searchbox = Search() def search(self, query, applicable=True, installable=False, repo=None): """Apply available filters before proceeding with searching and automatically set proper search mask if errata id instead of errata title was passed. :param str query: search query to type into search field. Both errata id (RHEA-2012:0055) and errata title (Sea_Erratum) are supported. :param bool applicable: filter by only applicable errata :param bool installable: filter by only installable errata :param str optional repo: filter by repository name :return: list of dicts representing table rows :rtype: list """ self.installable_filter.fill(installable) self.applicable_filter.fill(applicable) if repo is not None: self.repo_filter.fill(repo) if re.search(r'\w{4}-\d{4}:\d{4}', query): query = 'id = {}'.format(query) self.searchbox.search(query) return self.table.read() @property def is_displayed(self): return self.browser.wait_for_element( self.title, exception=False) is not None
class EntitySearchView(SatSecondaryTab): repo_filter = SatSelect(".//select[@ng-model='repository']") searchbox = Search() table = Table(".//table") def search(self, query, repo=None): """Apply available filters before proceeding with searching. :param str query: search query to type into search field. :param str optional repo: filter by repository name :return: list of dicts representing table rows :rtype: list """ if repo: self.repo_filter.fill(repo) self.searchbox.search(query) return self.table.read()
class template_input(View): ROOT = "//div[contains(@class, 'template_inputs')]" \ "/following-sibling::div[1]" name = TextInput(locator=".//input[contains(@name, '[name]')]") required = Checkbox(locator=".//input[contains(@id, 'required')]") input_type = SatSelect( locator=".//select[contains(@name, '[input_type]')]") input_content = ConditionalSwitchableView(reference='input_type') @input_content.register('User input') class UserInputForm(View): advanced = Checkbox( locator=".//input[contains(@id, 'advanced')]") options = TextInput( locator=".//textarea[contains(@name, '[options]')]") description = TextInput( locator=".//textarea[contains(@name, '[description]')]") @input_content.register('Fact value') class FactValueForm(View): fact_name = TextInput( locator=".//input[contains(@name, '[fact_name]')]") description = TextInput( locator=".//textarea[contains(@name, '[description]')]") @input_content.register('Variable value') class VariableValueForm(View): variable_name = TextInput( locator=".//input[contains(@name, '[variable_name]')]") description = TextInput( locator=".//textarea[contains(@name, '[description]')]") @input_content.register('Puppet parameter') class PuppetParameterForm(View): puppet_class_name = TextInput( locator=".//input[contains(@name, '[puppet_class_name]')]") puppet_parameter_name = TextInput( locator=".//input[contains(" "@name, '[puppet_parameter_name]')]") description = TextInput( locator=".//textarea[contains(@name, '[description]')]") def before_fill(self, values=None): self.parent.add_template_inputs.click()
class puppet_modules(SatTab): TAB_NAME = 'Puppet Modules' cv_filter = SatSelect(".//select[@ng-model='contentView']") searchbox = Search() table = SatTable(locator=".//table") def search(self, query, cv=None): """Apply available filters before proceeding with searching. :param str query: search query to type into search field. :param str optional cv: filter by content view name :return: list of dicts representing table rows :rtype: list """ if cv: self.cv_filter.fill(cv) self.searchbox.search(query) return self.table.read()
class TemplateInputItem(GenericRemovableWidgetItem): """Template Input item view""" remove_button = Text(".//a[@class='remove_nested_fields']") name = TextInput(locator=".//input[contains(@name, '[name]')]") required = Checkbox(locator=".//input[contains(@id, 'required')]") input_type = SatSelect( locator=".//select[contains(@name, '[input_type]')]") input_content = ConditionalSwitchableView(reference='input_type') @input_content.register('User input') class UserInputForm(View): advanced = Checkbox( locator=".//input[contains(@id, 'advanced')]") options = TextInput( locator=".//textarea[contains(@name, '[options]')]") description = TextInput( locator=".//textarea[contains(@name, '[description]')]") @input_content.register('Fact value') class FactValueForm(View): fact_name = TextInput( locator=".//input[contains(@name, '[fact_name]')]") description = TextInput( locator=".//textarea[contains(@name, '[description]')]") @input_content.register('Variable') class VariableValueForm(View): variable_name = TextInput( locator=".//input[contains(@name, '[variable_name]')]") description = TextInput( locator=".//textarea[contains(@name, '[description]')]") @input_content.register('Puppet parameter') class PuppetParameterForm(View): puppet_class_name = TextInput( locator=".//input[contains(@name, '[puppet_class_name]')]") puppet_parameter_name = TextInput( locator=".//input[contains(" "@name, '[puppet_parameter_name]')]") description = TextInput( locator=".//textarea[contains(@name, '[description]')]")
class NewAnsibleVariableView(BaseLoggedInView): """View while creating a new Ansible Variable""" breadcrumb = BreadCrumb() # 'Ansible Variable Details' section key = TextInput(id='ansible_variable_key') description = TextInput(id='ansible_variable_description') ansible_role = FilteredDropdown(id='ansible_variable_ansible_role_id') # 'Default Behavior' section override = Checkbox(id='ansible_variable_override') # Accessing all widgets except the ones above requires that the `override` checkbox is filled parameter_type = SatSelect(id='ansible_variable_parameter_type') default_value = TextInput(id='ansible_variable_default_value') hidden_value = Checkbox(id='ansible_variable_hidden_value') # 'Optional Input Validator' section expand_optional_input_validator = Text("//h2[@class='expander collapsed']") required = Checkbox(id='ansible_variable_required') validator_type = SatSelect(id='ansible_variable_validator_type') validator_rule = TextInput(id='ansible_variable_validator_rule') # 'Prioritize Attribute Order' section attribute_order = TextInput(id='order') merge_overrides = Checkbox(id='ansible_variable_merge_overrides') merge_default = Checkbox(id='ansible_variable_merge_default') avoid_duplicates = Checkbox(id='ansible_variable_avoid_duplicates') submit = Text('//input[@value="Submit"]') cancel = Text("//a[contains(., text()='Cancel']") @View.nested class matcher_section(View): """'Specify Matchers' section""" add_matcher = Text("//a[contains(@class, 'add_nested_fields')]") params = MatcherTable( locator=".//table[@class='table white-header']", # new_row_bottom is passed to the __init__ method of the # CustomParameter widget, see comment there for additional details new_row_bottom=True, column_widgets={ 'Attribute type': MatcherActions(), 'Value': TextInput(locator=".//textarea[@id='new_lookup_value_value']"), 'Actions': Text(".//a"), }, ) def before_fill(self, values): if not self.params.is_displayed: self.add_matcher.click() @property def expand_button(self): """Return the Optional Input Validator section expander element""" return self.browser.element(self.expand_optional_input_validator, parent=self) @property def expanded(self): """Check whether this section is expanded""" return 'active' in self.browser.get_attribute( 'class', self.expand_optional_input_validator ) def expand(self): """Expand the Optional Input Validator section""" if not self.expanded: self.browser.click(self.expand_optional_input_validator, parent=self) @property def is_displayed(self): return ( self.breadcrumb.locations[0] == 'Ansible Variables' and self.breadcrumb.read() == 'Create Ansible Variable' )