def update_rhsso_settings_in_satellite(revert=False): """Update or Revert the RH-SSO settings in satellite""" rhhso_settings = { 'authorize_login_delegation': True, 'authorize_login_delegation_auth_source_user_autocreate': 'External', 'login_delegation_logout_url': f'https://{settings.server.hostname}/users/extlogout', 'oidc_algorithm': 'RS256', 'oidc_audience': [f'{settings.server.hostname}-foreman-openidc'], 'oidc_issuer': f'{settings.rhsso.host_url}/auth/realms/{settings.rhsso.realm}', 'oidc_jwks_url': f'{settings.rhsso.host_url}/auth/realms' f'/{settings.rhsso.realm}/protocol/openid-connect/certs', } if revert: setting_entity = entities.Setting().search( query={'search': 'name=authorize_login_delegation'})[0] setting_entity.value = False setting_entity.update({'value'}) else: for setting_name, setting_value in rhhso_settings.items(): setting_entity = entities.Setting().search( query={'search': f'name={setting_name}'})[0] setting_entity.value = setting_value setting_entity.update({'value'})
def test_positive_update_hostname_default_prefix(self): """Update the default set prefix of hostname_prefix setting :id: 4969994d-f934-4f0e-9a98-476b87eb0527 :CaseImportance: Critical :expectedresults: Default set prefix should be updated with new value """ hostname_prefix_id = [ ele.id for ele in entities.Setting().search( query={ "per_page": 200, 'search': 'name="discovery_prefix"' }) ][0] prefix = entities.Setting(id=hostname_prefix_id).read() original_value = prefix.value try: for discovery_prefix in generate_strings_list( exclude_types=['alphanumeric', 'numeric']): prefix.value = discovery_prefix prefix = prefix.update(['value']) self.assertEqual(prefix.value, discovery_prefix) finally: setting_cleanup("discovery_prefix", original_value)
def module_discovery_env(module_org, module_location): discovery_loc = entities.Setting().search(query={'search': 'name="discovery_location"'})[0] default_discovery_loc = discovery_loc.value discovery_loc.value = module_location.name discovery_loc.update(['value']) discovery_org = entities.Setting().search(query={'search': 'name="discovery_organization"'})[0] default_discovery_org = discovery_org.value discovery_org.value = module_org.name discovery_org.update(['value']) yield discovery_loc.value = default_discovery_loc discovery_loc.update(['value']) discovery_org.value = default_discovery_org discovery_org.update(['value'])
def test_positive_update_login_page_footer_text_without_value(self): """Updates parameter "login_text" without any string (empty value) :id: 7a56f194-8bde-4dbf-9993-62eb6ab10733 :expectedresults: login_text has empty value after update """ login_text_id = [ele.id for ele in entities.Setting().search(query={ "per_page": 200, 'search': 'name="login_text"' })][0] login = entities.Setting(id=login_text_id).read() login.value = "" login = login.update(['value']) self.assertEqual(login.value, "")
def errata_status_installable(): """Fixture to allow restoring errata_status_installable setting after usage""" errata_status_installable = entities.Setting().search( query={'search': 'name="errata_status_installable"'})[0] original_value = errata_status_installable.value yield errata_status_installable _set_setting_value(errata_status_installable, original_value)
def test_positive_update_login_page_footer_text_with_long_string(session): """Testing to update parameter "Login_page_footer_text with long length string under General tab :id: b1a51594-43e6-49d8-918b-9bc306f3a1a2 :steps: 1. Navigate to Administer -> settings 2. Click on general tab 3. Input long length string into login page footer field 4. Assert value from login page :expectedresults: Parameter is updated :CaseImportance: Medium :CaseLevel: Acceptance """ property_name = 'login_text' property_value = entities.Setting().search( query={'search': f'name={property_name}'})[0] login_text_data = gen_string('alpha', 270) with session: try: session.settings.update(f"name={property_name}", f"{login_text_data}") result = session.login.logout() assert result["login_text"] == login_text_data finally: setting_cleanup(setting_name=property_name, setting_value=property_value.value)
def test_negative_update_hostname_with_empty_fact(session): """Update the Hostname_facts settings without any string(empty values) :id: e0eaab69-4926-4c1e-b111-30c51ede273e :Steps: 1. Goto settings ->Discovered tab -> Hostname_facts 2. Set empty hostname_facts (without any value) :expectedresults: Error should be raised on setting empty value for hostname_facts setting """ default_hostname = entities.Setting().search( query={'search': 'name=discovery_hostname'})[0] default_hostname = {"discovery_hostname": default_hostname} new_hostname = {"discovery_hostname": ""} with session: try: for key, value in new_hostname.items(): response = session.settings.update(key, value) assert response is not None, "Empty string accepted" finally: for key, value in default_hostname.items(): setting_cleanup(setting_name=key, setting_value=value.value)
def test_positive_selectors(session): """"Testing input for selectors: dropdown, text area, input box :id: 529ddd3a-1271-4043-9006-eac436b08b11 :expectedresults: Successfully add value to different selectors :CaseImportance: High """ uuid_input = "[ {} ]".format(gen_string("alpha")) random_input = gen_string('alpha') uuid_duplicate_prop = ('host_dmi_uuid_duplicates', uuid_input) reg_host_prop = ('register_hostname_fact', random_input) dep_solve_prop = ('content_view_solve_dependencies', 'Yes') with session: for setting_attr, value in [ uuid_duplicate_prop, dep_solve_prop, reg_host_prop ]: # Stores original values for each type of selectors original_val = entities.Setting().search( query={'search': 'name={}'.format(setting_attr)})[0] # Update to new value and resets value to back to old state try: session.settings.update('name = {}'.format(setting_attr), value) result = session.settings.read( 'name = {}'.format(setting_attr)) assert result['table'][0]['Value'] == value finally: setting_cleanup(setting_attr, str(original_val.default))
def setUpClass(cls): """Update discovery prefix with some string than default 'mac'""" super(DiscoveryPrefixTestCase, cls).setUpClass() cls.org = entities.Organization(name=gen_string('alpha')).create() cls.org_name = cls.org.name # Update hostname_prefix with some string other than default 'mac' cls.prefix = 'dhost' cls.discovery_prefix = entities.Setting().search( query={'search': 'name="discovery_prefix"'})[0] cls.default_prefix = str(cls.discovery_prefix.value) cls.discovery_prefix.value = cls.prefix cls.discovery_prefix.update(['value']) cls.discovery_org = entities.Setting().search( query={'search': 'name="discovery_organization"'})[0] cls.discovery_org.value = cls.org.name cls.discovery_org.update(['value'])
def test_positive_update_email_delivery_method_sendmail(session): """Updating Sendmail params on Email tab :id: c774e713-9640-402d-8987-c3509e918eb6 :steps: 1. Navigate to Administer > Settings > Email tab 2. Update delivery method select interface to Sendmail 3. Sendmail params configuration: 3.1. Sendmail arguments 3.2. Sendmail location 3.3. Send welcome email 4. Update "Email reply address" and "Email subject prefix" 5. Click "Test Email" button 6. Check success msg "Email was sent successfully" is shown 7. Check sent email has updated values on sender and subject accordingly :expectedresults: Email is sent through Sendmail :CaseImportance: Critical :CaseLevel: Acceptance """ property_name = "Email" mail_config_default_param = { "delivery_method": "", "email_reply_address": "", "email_subject_prefix": "", "sendmail_arguments": "", "sendmail_location": "", "send_welcome_email": "", } mail_config_default_param = { content: entities.Setting().search(query={'search': f'name={content}'})[0] for content in mail_config_default_param } mail_config_new_params = { "delivery_method": "Sendmail", "email_reply_address": f"root@{ssh.settings.server.hostname}", "email_subject_prefix": [gen_string('alpha')], "sendmail_location": "/usr/sbin/sendmail", "send_welcome_email": "Yes", } command = "grep " + f'{mail_config_new_params["email_subject_prefix"]}' + " /var/mail/root" with session: try: for mail_content, mail_content_value in mail_config_new_params.items( ): session.settings.update(mail_content, mail_content_value) test_mail_response = session.settings.send_test_mail( property_name)[0] assert test_mail_response == "Email was sent successfully" assert ssh.command(command).return_code == 0 finally: for key, value in mail_config_default_param.items(): setting_cleanup(setting_name=key, setting_value=value.value)
def rhsso_setting_setup_with_timeout(rhsso_setting_setup, request): """Update the RHSSO setting with timeout setting and revert it in cleanup""" setting_entity = entities.Setting().search(query={'search': f'name=idle_timeout'})[0] setting_entity.value = 1 setting_entity.update({'value'}) yield setting_entity.value = 30 setting_entity.update({'value'})
def test_positive_update_login_page_footer_text(self): """Updates parameter "login_text" in settings :id: 91c5373d-b928-419d-8509-761adf5b94b0 :expectedresults: Parameter is updated successfully """ login_text_id = [ele.id for ele in entities.Setting().search(query={ "per_page": 200, 'search': 'name="login_text"' })][0] login = entities.Setting(id=login_text_id).read() for login_text in valid_data_list(): with self.subTest(login_text): login.value = login_text login = login.update(['value']) self.assertEqual(login.value, login_text)
def test_positive_update_hostname_prefix_without_value(self): """Update the Hostname_prefix settings without any string(empty values) :id: 3867488c-d955-47af-ac0d-71f4016391d1 :expectedresults: Hostname_prefix should be set without any text """ hostname_prefix_id = [ele.id for ele in entities.Setting().search( query={"per_page": 200, 'search': 'name="discovery_prefix"'})][0] prefix = entities.Setting(id=hostname_prefix_id).read() original_value = prefix.value prefix.value = "" try: prefix = prefix.update(['value']) self.assertEqual(prefix.value, "") finally: setting_cleanup("discovery_prefix", original_value)
def post_upgrade_test_tasks(sat_host, cap_host=None): """Run set of tasks for post upgrade tests :param string sat_host: Hostname to run the tasks on :param list cap_host: Capsule hosts to run sync on """ # Execute tasks as post upgrade tests are dependent certificate_url = os.environ.get('FAKE_MANIFEST_CERT_URL') if certificate_url is not None: execute(setup_fake_manifest_certificate, certificate_url, host=sat_host) sat_version = os.environ.get('TO_VERSION') execute(setup_alternate_capsule_ports, host=sat_host) if float(sat_version) > 6.1: # Update the Default Organization name, which was updated in 6.2 logger.info("Update the Default Organization name, which was updated " "in 6.2") org = entities.Organization().search( query={'search': 'label=Default_Organization'})[0] org.name = "Default Organization" org.update(['name']) # Update the Default Location name, which was updated in 6.2 logger.info("Update the Default Location name, which was updated in " "6.2") loc = entities.Location().search( query={'search': 'name="Default Location"'})[0] loc.name = "Default Location" loc.update(['name']) if bz_bug_is_open(1502505): logger.info( "Update the default_location_puppet_content value with " "updated location name.Refer BZ:1502505") puppet_location = entities.Setting().search( query={'search': 'name=default_location_puppet_content'})[0] puppet_location.value = 'Default Location' puppet_location.update(['value']) # Increase log level to DEBUG, to get better logs in foreman_debug execute(lambda: run('sed -i -e \'/:level: / s/: .*/: ' 'debug/\' /etc/foreman/settings.yaml'), host=sat_host) execute(lambda: run('katello-service restart'), host=sat_host) # Execute task for template changes required for discovery feature execute(setup_foreman_discovery, sat_version=sat_version, host=sat_host) # Execute task for creating latest discovery iso required for unattended # test env.disable_known_hosts = True execute(get_discovery_image, host=os.environ.get('LIBVIRT_HOSTNAME')) # Commenting out until GH issue:#135 # Removing the original manifest from Default Organization (Org-id 1), # to allow test-cases to utilize the same manifest. # logger.info("Removing the Original Manifest from Default Organization") # execute(hammer, 'subscription delete-manifest --organization-id 1', # host=sat_host) # Run Avahi Task on upgrade boxes for REX tests to run execute(lambda: run('yum remove -y epel*'), host=sat_host) execute(setup_avahi_discovery, host=sat_host)
def test_positive_update_login_page_footer_text_with_long_string(self): """Attempt to update parameter "Login_page_footer_text" with long length string :id: fb8b0bf1-b475-435a-926b-861aa18d31f1 :expectedresults: Parameter is updated """ login_text_id = [ele.id for ele in entities.Setting().search(query={ "per_page": 200, 'search': 'name="login_text"' })][0] login = entities.Setting(id=login_text_id).read() for login_text in generate_strings_list(1000): with self.subTest(login_text): login.value = login_text login = login.update(['value']) self.assertEqual(login.value, login_text)
def setUpClass(cls): """Display all the discovery rules on the same page""" super(DiscoveryRuleTestCase, cls).setUpClass() cls.per_page = entities.Setting().search( query={'search': 'name="entries_per_page"'})[0] cls.saved_per_page = str(cls.per_page.value) cls.per_page.value = '100000' cls.per_page.update({'value'}) cls.host_group = entities.HostGroup().create()
def setUpClass(cls): """Creates two non-admin users with discovery Manager/Reader roles""" super(DiscoveryRuleRoleTestCase, cls).setUpClass() cls.per_page = entities.Setting().search( query={'search': 'name="entries_per_page"'})[0] cls.saved_per_page = str(cls.per_page.value) cls.per_page.value = '100000' cls.per_page.update({'value'}) cls.org = entities.Organization().create() cls.loc = entities.Location().create() cls.manager_loc = entities.Location().create() cls.host_group = entities.HostGroup( organization=[cls.org]).create() # Create a discovery rule cls.rule_name = gen_string('alpha') entities.DiscoveryRule( name=cls.rule_name, hostgroup=cls.host_group, search_='cpu_count = 1', organization=[cls.org], location=[cls.loc], ).create() # create non-admin reader user with Discovery_Reader role reader_role = entities.Role().search( query={'search': 'name="Discovery Reader"'} )[0] cls.reader_user = gen_string('alpha') cls.reader_user_password = gen_string('alphanumeric') cls.read_user = entities.User( login=cls.reader_user, role=[reader_role], password=cls.reader_user_password, organization=[cls.org], location=[cls.loc], default_organization=cls.org, default_location=cls.loc, ).create() # create non-admin manager user with Discovery_Manager role manager_role = entities.Role().search( query={'search': 'name="Discovery Manager"'} )[0] cls.manager_user = gen_string('alpha') cls.manager_user_password = gen_string('alphanumeric') cls.manage_user = entities.User( login=cls.manager_user, role=[manager_role], password=cls.manager_user_password, organization=[cls.org], location=[cls.loc, cls.manager_loc], default_organization=cls.org, ).create()
def setting_update(request): """ This fixture is used to create an object of the provided settings parameter that we use in each test case to update their attributes and once the test case gets completed it helps to restore their default value """ setting_object = entities.Setting().search(query={'search': f'name={request.param}'})[0] default_setting_value = setting_object.value yield setting_object setting_object.value = default_setting_value setting_object.update({'value'})
def discovery_org(): org = entities.Organization().create() # Update default discovered host organization discovery_org = entities.Setting().search( query={'search': 'name="discovery_organization"'})[0] default_discovery_org = discovery_org.value discovery_org.value = org.name discovery_org.update(['value']) yield org discovery_org.value = default_discovery_org discovery_org.update(['value'])
def setUpClass(cls): """Steps to Configure foreman discovery 1. Build PXE default template 2. Create Organization/Location 3. Update Global parameters to set default org and location for discovered hosts. 4. Enable auto_provision flag to perform discovery via discovery rules. """ super(DiscoveryTestCase, cls).setUpClass() # Build PXE default template to get default PXE file entities.ConfigTemplate().build_pxe_default() # Create Org and location cls.org = entities.Organization(name=gen_string('alpha')).create() cls.org_name = cls.org.name cls.loc = entities.Location( name=gen_string('alpha'), organization=[cls.org], ).create() # Update default org and location params to place discovered host cls.discovery_loc = entities.Setting().search( query={'search': 'name="discovery_location"'})[0] cls.discovery_loc.value = cls.loc.name cls.discovery_loc.update({'value'}) cls.discovery_org = entities.Setting().search( query={'search': 'name="discovery_organization"'})[0] cls.discovery_org.value = cls.org.name cls.discovery_org.update({'value'}) # Enable flag to auto provision discovered hosts via discovery rules cls.discovery_auto = entities.Setting().search( query={'search': 'name="discovery_auto"'})[0] cls.default_discovery_auto = str(cls.discovery_auto.value) cls.discovery_auto.value = 'True' cls.discovery_auto.update({'value'}) cls.config_env = configure_provisioning(org=cls.org, loc=cls.loc)
def discovery_location(discovery_org): loc = entities.Location(name=gen_string('alpha'), organization=[discovery_org]).create() # Update default discovered host location discovery_loc = entities.Setting().search( query={'search': 'name="discovery_location"'})[0] default_discovery_loc = discovery_loc.value discovery_loc.value = loc.name discovery_loc.update(['value']) yield loc discovery_loc.value = default_discovery_loc discovery_loc.update(['value'])
def set_original_property_value(): property_list = {} def _set_original_property_value(property_name): before_test_setting_param = entities.Setting().search( query={'search': 'name="{0}"'.format(property_name)})[0] property_list[property_name] = before_test_setting_param.value return before_test_setting_param.value yield _set_original_property_value for key, value in property_list.items(): after_test_setting_param = entities.Setting().search( query={'search': 'name="{0}"'.format(key)})[0] after_test_setting_param.value = value
def test_negative_update_hostname_with_empty_fact(self): """Update the Hostname_facts settings without any string(empty values) :id: b8e260fc-e263-4292-aa2f-ab37085c7758 :expectedresults: Error should be raised on setting empty value for hostname_facts setting """ hostname_facts_id = [ ele.id for ele in entities.Setting().search( query={ "per_page": 200, 'search': 'name="discovery_hostname"' }) ][0] facts = entities.Setting(id=hostname_facts_id).read() original_value = facts.value facts.value = "" try: facts = facts.update(['value']) self.assertNotEqual(facts.value, "", msg="Empty string") finally: setting_cleanup("discovery_hostname", original_value)
def test_positive_provision_without_auto_provision(self): """Create a discovery rule and execute it when "auto_provisioning" flag set to 'false' :id: 25f5112b-7bbd-4bda-8d75-c43bd6390aa8 :Setup: Host should already be discovered :expectedresults: Host should not be rebooted automatically :CaseLevel: System """ try: # Disable flag to auto provision discovery_auto = entities.Setting().search( query={'search': 'name="discovery_auto"'})[0] default_discovery_auto = discovery_auto.value discovery_auto.value = 'False' discovery_auto.update(['value']) rule_name = gen_string('alpha') with Session(self) as session: session.nav.go_to_select_org(self.org_name) # Define a discovery rule make_discoveryrule( session, name=rule_name, host_limit=1, hostgroup=self.config_env['host_group'], search_rule='cpu_count = 1', locations=[self.loc.name], ) self.assertIsNotNone(self.discoveryrules.search(rule_name)) with LibvirtGuest() as pxe_host: host_name = pxe_host.guest_name self.assertTrue( self.discoveredhosts.waitfordiscoveredhost(host_name) ) self.assertIsNotNone( self.discoveredhosts.search(host_name)) # Check that host shouldn't list under all hosts self.assertIsNone(self.hosts.search( u'{0}.{1}'.format(host_name, self.config_env['domain']) )) # Check that host still listed under discovered hosts self.assertIsNotNone( self.discoveredhosts.search(host_name)) finally: # Revert the discovery_auto flag to default value discovery_auto.value = default_discovery_auto discovery_auto.update(['value'])
def setUpClass(cls): """Steps to Configure foreman discovery 1. Build PXE default template 2. Create Organization/Location 3. Update Global parameters to set default org and location for discovered hosts. 4. Enable auto_provision flag to perform discovery via discovery rules. """ super().setUpClass() # Build PXE default template to get default PXE file entities.ProvisioningTemplate().build_pxe_default() # let's just modify the timeouts to speed things up ssh.command("sed -ie 's/TIMEOUT [[:digit:]]\\+/TIMEOUT 1/g' " "/var/lib/tftpboot/pxelinux.cfg/default") ssh.command( "sed -ie '/APPEND initrd/s/$/ fdi.countdown=1 fdi.ssh=1 fdi.rootpw=changeme/' " "/var/lib/tftpboot/pxelinux.cfg/default") # Create Org and location cls.org = entities.Organization().create() cls.loc = entities.Location().create() # Get default settings values cls.default_disco_settings = { i.name: i for i in entities.Setting().search( query={'search': 'name~discovery'}) } # Update discovery taxonomies settings cls.discovery_loc = copy( cls.default_disco_settings['discovery_location']) cls.discovery_loc.value = cls.loc.name cls.discovery_loc.update(['value']) cls.discovery_org = copy( cls.default_disco_settings['discovery_organization']) cls.discovery_org.value = cls.org.name cls.discovery_org.update(['value']) # Enable flag to auto provision discovered hosts via discovery rules cls.discovery_auto = copy(cls.default_disco_settings['discovery_auto']) cls.discovery_auto.value = 'true' cls.discovery_auto.update(['value']) # Flag which shows whether environment is fully configured for # discovered host provisioning. cls.configured_env = False
def tearDown(self): """Revert the setting to its default value""" if self.original_value is not None: # do nothing for skipped test if self.saved_element != self.original_value: if self.original_value == 'Empty': # we cannot pass value Empty as it's not considered as None # value can not be None a failure is raised # when passing empty string the UI show Empty again # other values like Yes, No and numbers in strings # are handled correctly self.original_value = '' setting_param = entities.Setting().search( query={'search': 'name="{0}"'.format(self.param_name)})[0] setting_param.value = self.original_value setting_param.update({'value'}) super(SettingTestCase, self).tearDown()
def setUpClass(cls): """Display all the bookmarks on the same page, create user and entities for testing. """ super(BookmarkTestCase, cls).setUpClass() cls.per_page = entities.Setting().search( query={'search': 'name="entries_per_page"'})[0] cls.saved_per_page = str(cls.per_page.value) cls.per_page.value = '100000' cls.per_page.update({'value'}) cls.entities = [] # Custom user for bookmark visibility testing role = entities.Role().search(query={'search': 'name="Viewer"'})[0] cls.custom_password = gen_string('alphanumeric') cls.custom_user = entities.User( role=[role], password=cls.custom_password, ).create() for entity in BOOKMARK_ENTITIES: # Skip the entities, which can't be tested ATM (require framework # update) skip = entity.get('skip_for_ui') if skip and (skip is True or bz_bug_is_open(skip)): continue cls.entities.append(entity) # Some pages require at least 1 existing entity for search bar to # appear. Creating 1 entity for such pages if entity.get('setup'): # entities with 1 organization if entity['name'] in ('Hosts',): entity['setup'](organization=cls.session_org).create() # entities with no organizations elif entity['name'] in ( 'Compute_Profile', 'ConfigGroups', 'HardwareModel', 'PuppetClasses', 'UserGroup'): entity['setup']().create() # entities with multiple organizations else: entity['setup'](organization=[cls.session_org]).create()
def discovery_settings(module_org, module_location): """Steps to Configure foreman discovery 1. Build PXE default template 2. Create Organization/Location 3. Update Global parameters to set default org and location for discovered hosts. 4. Enable auto_provision flag to perform discovery via discovery rules. """ # Build PXE default template to get default PXE file entities.ProvisioningTemplate().build_pxe_default() # let's just modify the timeouts to speed things up ssh.command("sed -ie 's/TIMEOUT [[:digit:]]\\+/TIMEOUT 1/g' " "/var/lib/tftpboot/pxelinux.cfg/default") ssh.command( "sed -ie '/APPEND initrd/s/$/ fdi.countdown=1 fdi.ssh=1 fdi.rootpw=changeme/' " "/var/lib/tftpboot/pxelinux.cfg/default") # Get default settings values default_disco_settings = { i.name: i for i in entities.Setting().search(query={'search': 'name~discovery'}) } # Update discovery taxonomies settings discovery_loc = copy(default_disco_settings['discovery_location']) discovery_loc.value = module_location.name discovery_loc.update(['value']) discovery_org = copy(default_disco_settings['discovery_organization']) discovery_org.value = module_org.name discovery_org.update(['value']) # Enable flag to auto provision discovered hosts via discovery rules discovery_auto = copy(default_disco_settings['discovery_auto']) discovery_auto.value = 'true' discovery_auto.update(['value']) yield # Restore default global setting's values default_disco_settings['discovery_location'].update(['value']) default_disco_settings['discovery_organization'].update(['value']) default_disco_settings['discovery_auto'].update(['value'])
def satellite_setting(key_val: str): """Context Manager to update the satellite setting and revert on exit :param key_val: The setting name and value in format `setting_name=new_value` """ try: name, value = key_val.split('=') try: setting = entities.Setting().search(query={'search': f'name={name.strip()}'})[0] except IndexError: raise KeyError(f'The setting {name} in not available in satellite.') old_value = setting.value setting.value = value.strip() setting.update({'value'}) yield except Exception: raise finally: setting.value = old_value setting.update({'value'})
def test_positive_entries_per_page(session): """ Update the per page entry in the settings. :id: 009026b6-7550-40aa-9f78-5eb7f7e3800f :Steps: 1. Navigate to Administer > Settings > General tab 2. Update the entries per page value 3. GoTo Monitor > Tasks Table > Pagination 4. Check the new per page entry is updated in pagination list 5. Check the page count on the basis of the new updated entries per page. :expectedresults: New set entry-per-page should be available in the pagination list and page count should match according to the new setting :BZ: 1746221 :CaseImportance: Medium :CaseLevel: Acceptance """ property_name = "entries_per_page" property_value = 19 default_property_value = entities.Setting().search( query={'search': f'name={property_name}'})[0] with session: try: session.settings.update(f"name={property_name}", property_value) page_content = session.task.read_all(widget_names="Pagination") assert str( property_value) in page_content["Pagination"]["per_page"] total_pages = math.ceil( int(page_content["Pagination"]["total_items"]) / property_value) assert str(total_pages) == page_content["Pagination"]["pages"] finally: setting_cleanup(setting_name=property_name, setting_value=default_property_value.value)