From 845ef03f9e55d75bd751f2f3646c66b2c33b9e00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hellebrandt?= Date: Thu, 25 Apr 2024 09:58:39 +0200 Subject: [PATCH 01/20] Fix omitting credentials when CLI has already been instantiated (#14449) * Fix omitting credentials when CLI has already been instantiated * Rework based on comments * Set to False after yield --- robottelo/hosts.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/robottelo/hosts.py b/robottelo/hosts.py index 5c9d5bc239..f4a6b7fd33 100644 --- a/robottelo/hosts.py +++ b/robottelo/hosts.py @@ -1870,9 +1870,27 @@ def cli(self): @contextmanager def omit_credentials(self): - self.omitting_credentials = True + change = not self.omitting_credentials # if not already set to omit + if change: + self.omitting_credentials = True + # if CLI is already created + if self._cli._configured: + for name, obj in self._cli.__dict__.items(): + with contextlib.suppress( + AttributeError + ): # not everything has an mro method, we don't care about them + if Base in obj.mro(): + getattr(self._cli, name).omitting_credentials = True yield - self.omitting_credentials = False + if change: + self.omitting_credentials = False + if self._cli._configured: + for name, obj in self._cli.__dict__.items(): + with contextlib.suppress( + AttributeError + ): # not everything has an mro method, we don't care about them + if Base in obj.mro(): + getattr(self._cli, name).omitting_credentials = False @contextmanager def ui_session(self, testname=None, user=None, password=None, url=None, login=True): From 320ff990cd0c0c9ab923ac5ec4244382a4b09b1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hellebrandt?= Date: Thu, 25 Apr 2024 13:33:50 +0200 Subject: [PATCH 02/20] Fix expected user name (#14303) Co-authored-by: Jameer Pathan <21165044+jameerpathan111@users.noreply.github.com> --- tests/foreman/ui/test_ldap_authentication.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/foreman/ui/test_ldap_authentication.py b/tests/foreman/ui/test_ldap_authentication.py index a6e3af6d61..554244957f 100644 --- a/tests/foreman/ui/test_ldap_authentication.py +++ b/tests/foreman/ui/test_ldap_authentication.py @@ -275,7 +275,7 @@ def test_positive_add_katello_role( session.activationkey.create({'name': ak_name}) assert session.activationkey.search(ak_name)[0]['Name'] == ak_name current_user = session.activationkey.read(ak_name, 'current_user')['current_user'] - assert ldap_data['ldap_user_name'] in current_user + assert f"{auth_source.attr_firstname} {auth_source.attr_lastname}" in current_user @pytest.mark.parametrize('ldap_auth_source', ['AD', 'IPA'], indirect=True) From 7be34b05d0a35de85cc18f11726ac4dfa2a2f4e1 Mon Sep 17 00:00:00 2001 From: Gaurav Talreja Date: Thu, 25 Apr 2024 21:07:17 +0530 Subject: [PATCH 03/20] Extend search in *_default_os fixtures for EL9 as default OS (#14851) * Extend search in *_default_os fixtures for EL9 as default OS Signed-off-by: Gaurav Talreja * Move default os search query to constants and delete unused session_default_os fixture Signed-off-by: Gaurav Talreja --------- Signed-off-by: Gaurav Talreja --- pytest_fixtures/component/os.py | 4 +++- pytest_fixtures/component/provision_azure.py | 6 ++++-- pytest_fixtures/component/provision_gce.py | 13 ++----------- pytest_fixtures/component/puppet.py | 13 +++++++------ robottelo/constants/__init__.py | 1 + robottelo/host_helpers/api_factory.py | 3 ++- tests/foreman/ui/test_contentview_old.py | 5 ++--- 7 files changed, 21 insertions(+), 24 deletions(-) diff --git a/pytest_fixtures/component/os.py b/pytest_fixtures/component/os.py index 0c94baa09c..af64b0b088 100644 --- a/pytest_fixtures/component/os.py +++ b/pytest_fixtures/component/os.py @@ -2,6 +2,8 @@ from nailgun import entities import pytest +from robottelo import constants + @pytest.fixture(scope='session') def default_os( @@ -17,7 +19,7 @@ def default_os( """ os = getattr(request, 'param', None) if os is None: - search_string = 'name="RedHat" AND (major="6" OR major="7" OR major="8")' + search_string = constants.DEFAULT_OS_SEARCH_QUERY else: version = os.split(' ')[1].split('.') search_string = f'family="Redhat" AND major="{version[0]}" AND minor="{version[1]}"' diff --git a/pytest_fixtures/component/provision_azure.py b/pytest_fixtures/component/provision_azure.py index 7e2a05f070..645676d744 100644 --- a/pytest_fixtures/component/provision_azure.py +++ b/pytest_fixtures/component/provision_azure.py @@ -11,6 +11,7 @@ AZURERM_RHEL7_FT_IMG_URN, AZURERM_RHEL7_UD_IMG_URN, DEFAULT_ARCHITECTURE, + DEFAULT_OS_SEARCH_QUERY, ) @@ -38,8 +39,9 @@ def sat_azure_domain(sat_azure, sat_azure_loc, sat_azure_org): @pytest.fixture(scope='module') def sat_azure_default_os(sat_azure): """Default OS on the Satellite""" - search_string = 'name="RedHat" AND (major="6" OR major="7" OR major="8" OR major="9")' - return sat_azure.api.OperatingSystem().search(query={'search': search_string})[0].read() + return ( + sat_azure.api.OperatingSystem().search(query={'search': DEFAULT_OS_SEARCH_QUERY})[0].read() + ) @pytest.fixture(scope='module') diff --git a/pytest_fixtures/component/provision_gce.py b/pytest_fixtures/component/provision_gce.py index 64b706d772..c259b6c7c8 100644 --- a/pytest_fixtures/component/provision_gce.py +++ b/pytest_fixtures/component/provision_gce.py @@ -9,6 +9,7 @@ from robottelo.config import settings from robottelo.constants import ( DEFAULT_ARCHITECTURE, + DEFAULT_OS_SEARCH_QUERY, DEFAULT_PTABLE, FOREMAN_PROVIDERS, GCE_RHEL_CLOUD_PROJECTS, @@ -41,8 +42,7 @@ def sat_gce_domain(sat_gce, sat_gce_loc, sat_gce_org): @pytest.fixture(scope='module') def sat_gce_default_os(sat_gce): """Default OS on the Satellite""" - search_string = 'name="RedHat" AND (major="6" OR major="7" OR major="8" OR major="9")' - return sat_gce.api.OperatingSystem().search(query={'search': search_string})[0].read() + return sat_gce.api.OperatingSystem().search(query={'search': DEFAULT_OS_SEARCH_QUERY})[0].read() @pytest.fixture(scope='session') @@ -103,15 +103,6 @@ def gce_custom_cloudinit_uuid(googleclient, gce_cert): return googleclient.get_template('customcinit', project=gce_cert['project_id']).uuid -@pytest.fixture(scope='session') -def session_default_os(session_target_sat): - """Default OS on the Satellite""" - search_string = 'name="RedHat" AND (major="6" OR major="7" OR major="8")' - return ( - session_target_sat.api.OperatingSystem().search(query={'search': search_string})[0].read() - ) - - @pytest.fixture(scope='module') def module_gce_compute(sat_gce, sat_gce_org, sat_gce_loc, gce_cert): return sat_gce.api.GCEComputeResource( diff --git a/pytest_fixtures/component/puppet.py b/pytest_fixtures/component/puppet.py index c531c7888a..fe438aac6a 100644 --- a/pytest_fixtures/component/puppet.py +++ b/pytest_fixtures/component/puppet.py @@ -1,7 +1,7 @@ # Puppet Environment fixtures import pytest -from robottelo.constants import ENVIRONMENT +from robottelo import constants @pytest.fixture(scope='session') @@ -119,10 +119,9 @@ def session_puppet_enabled_proxy(session_puppet_enabled_sat): @pytest.fixture(scope='session') def session_puppet_default_os(session_puppet_enabled_sat): """Default OS on the puppet-enabled Satellite""" - search_string = 'name="RedHat" AND (major="6" OR major="7" OR major="8")' return ( session_puppet_enabled_sat.api.OperatingSystem() - .search(query={'search': search_string})[0] + .search(query={'search': constants.DEFAULT_OS_SEARCH_QUERY})[0] .read() ) @@ -141,9 +140,11 @@ def module_puppet_lce_library(session_puppet_enabled_sat, module_puppet_org): """Returns the Library lifecycle environment from chosen organization""" return ( session_puppet_enabled_sat.api.LifecycleEnvironment() - .search(query={'search': f'name={ENVIRONMENT} and organization_id={module_puppet_org.id}'})[ - 0 - ] + .search( + query={ + 'search': f'name={constants.ENVIRONMENT} and organization_id={module_puppet_org.id}' + } + )[0] .read() ) diff --git a/robottelo/constants/__init__.py b/robottelo/constants/__init__.py index b3cfbf8962..78d32535ef 100644 --- a/robottelo/constants/__init__.py +++ b/robottelo/constants/__init__.py @@ -680,6 +680,7 @@ class Colored(Box): DEFAULT_ARCHITECTURE = 'x86_64' DEFAULT_RELEASE_VERSION = '6Server' DEFAULT_ROLE = 'Default role' +DEFAULT_OS_SEARCH_QUERY = 'name="RedHat" AND (major="6" OR major="7" OR major="8" OR major="9")' VDC_SUBSCRIPTION_NAME = 'Red Hat Enterprise Linux for Virtual Datacenters, Premium' diff --git a/robottelo/host_helpers/api_factory.py b/robottelo/host_helpers/api_factory.py index 1316bca907..df7085e0d0 100644 --- a/robottelo/host_helpers/api_factory.py +++ b/robottelo/host_helpers/api_factory.py @@ -15,6 +15,7 @@ from robottelo.config import settings from robottelo.constants import ( DEFAULT_ARCHITECTURE, + DEFAULT_OS_SEARCH_QUERY, DEFAULT_PTABLE, DEFAULT_PXE_TEMPLATE, DEFAULT_TEMPLATE, @@ -336,7 +337,7 @@ def configure_provisioning(self, org=None, loc=None, compute=False, os=None): if os is None: os = ( self._satellite.api.OperatingSystem() - .search(query={'search': 'name="RedHat" AND (major="6" OR major="7")'})[0] + .search(query={'search': DEFAULT_OS_SEARCH_QUERY})[0] .read() ) else: diff --git a/tests/foreman/ui/test_contentview_old.py b/tests/foreman/ui/test_contentview_old.py index 0b84677125..0bff1edfb8 100644 --- a/tests/foreman/ui/test_contentview_old.py +++ b/tests/foreman/ui/test_contentview_old.py @@ -31,6 +31,7 @@ CONTAINER_UPSTREAM_NAME, DEFAULT_ARCHITECTURE, DEFAULT_CV, + DEFAULT_OS_SEARCH_QUERY, DEFAULT_PTABLE, ENVIRONMENT, FAKE_0_CUSTOM_PACKAGE, @@ -2675,9 +2676,7 @@ def test_positive_delete_with_kickstart_repo_and_host_group( .read() ) # Get the OS ID - os = target_sat.api.OperatingSystem().search( - query={'search': 'name="RedHat" AND (major="6" OR major="7")'} - )[0] + os = target_sat.api.OperatingSystem().search(query={'search': DEFAULT_OS_SEARCH_QUERY})[0] # Update the OS to associate arch and ptable os.architecture = [arch] os.ptable = [ptable] From db9b85805abbd4e64c1ba65c665796a9c55129f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Gajdu=C5=A1ek?= Date: Thu, 25 Apr 2024 17:39:28 +0200 Subject: [PATCH 04/20] Preparations for ruff 0.4.1 (#14885) --- pyproject.toml | 10 ++++++---- robottelo/exceptions.py | 4 +--- robottelo/host_helpers/cli_factory.py | 8 ++------ robottelo/hosts.py | 6 +----- robottelo/utils/decorators/func_locker.py | 8 ++------ robottelo/utils/decorators/func_shared/shared.py | 8 ++------ robottelo/utils/virtwho.py | 12 +++--------- tests/foreman/ui/test_audit.py | 4 ++-- tests/foreman/ui/test_computeprofiles.py | 12 ++++++------ tests/foreman/ui/test_dashboard.py | 4 +--- tests/foreman/ui/test_hostcollection.py | 4 ++-- tests/foreman/ui/test_repository.py | 10 ++++++---- 12 files changed, 34 insertions(+), 56 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 72a8e2b8f3..71e77065d0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,6 +17,8 @@ exclude = ''' [tool.ruff] target-version = "py311" + +[tool.ruff.lint] fixable = ["ALL"] select = [ @@ -40,21 +42,21 @@ ignore = [ "PT005", # pytest no underscrore prefix for return fixtures ] -[tool.ruff.isort] +[tool.ruff.lint.isort] force-sort-within-sections = true known-first-party = [ "robottelo", ] combine-as-imports = true -[tool.ruff.flake8-pytest-style] +[tool.ruff.lint.flake8-pytest-style] fixture-parentheses = false mark-parentheses = false -[tool.ruff.flake8-quotes] +[tool.ruff.lint.flake8-quotes] inline-quotes = "single" -[tool.ruff.mccabe] +[tool.ruff.lint.mccabe] max-complexity = 20 [tool.pytest.ini_options] diff --git a/robottelo/exceptions.py b/robottelo/exceptions.py index a610056487..057e0891cf 100644 --- a/robottelo/exceptions.py +++ b/robottelo/exceptions.py @@ -107,9 +107,7 @@ def __str__(self): def __repr__(self): """Include class name status, stderr and msg to improve logging""" - return '{}(status={!r}, stderr={!r}, msg={!r}'.format( - type(self).__name__, self.status, self.stderr, self.msg - ) + return f'{type(self).__name__}(status={self.status!r}, stderr={self.stderr!r}, msg={self.msg!r}' class CLIReturnCodeError(CLIBaseError): diff --git a/robottelo/host_helpers/cli_factory.py b/robottelo/host_helpers/cli_factory.py index 13eaf2242e..cc32500222 100644 --- a/robottelo/host_helpers/cli_factory.py +++ b/robottelo/host_helpers/cli_factory.py @@ -56,9 +56,7 @@ def create_object(cli_object, options, values=None, credentials=None, timeout=No except CLIReturnCodeError as err: # If the object is not created, raise exception, stop the show. raise CLIFactoryError( - 'Failed to create {} with data:\n{}\n{}'.format( - cli_object.__name__, pprint.pformat(options, indent=2), err.msg - ) + f'Failed to create {cli_object.__name__} with data:\n{pprint.pformat(options, indent=2)}\n{err.msg}' ) from err # Sometimes we get a list with a dictionary and not a dictionary. if isinstance(result, list) and len(result) > 0: @@ -999,9 +997,7 @@ def add_role_permissions(self, role_id, resource_permissions): missing_permissions = set(permission_names).difference(set(available_permission_names)) if missing_permissions: raise CLIFactoryError( - 'Permissions "{}" are not available in Resource "{}"'.format( - list(missing_permissions), resource_type - ) + f'Permissions "{list(missing_permissions)}" are not available in Resource "{resource_type}"' ) # Create the current resource type role permissions options = {'role-id': role_id} diff --git a/robottelo/hosts.py b/robottelo/hosts.py index f4a6b7fd33..445cafc82b 100644 --- a/robottelo/hosts.py +++ b/robottelo/hosts.py @@ -932,11 +932,7 @@ def add_authorized_key(self, pub_key): # ensure ssh directory exists self.execute(f'mkdir -p {ssh_path}') # append the key if doesn't exists - self.execute( - "grep -q '{key}' {dest} || echo '{key}' >> {dest}".format( - key=key_content, dest=auth_file - ) - ) + self.execute(f"grep -q '{key_content}' {auth_file} || echo '{key_content}' >> {auth_file}") # set proper permissions self.execute(f'chmod 700 {ssh_path}') self.execute(f'chmod 600 {auth_file}') diff --git a/robottelo/utils/decorators/func_locker.py b/robottelo/utils/decorators/func_locker.py index 08f4073c61..e4feaa46f2 100644 --- a/robottelo/utils/decorators/func_locker.py +++ b/robottelo/utils/decorators/func_locker.py @@ -240,9 +240,7 @@ def function_wrapper(*args, **kwargs): with file_lock(lock_file_path, remove=False, timeout=timeout) as handler: logger.info( - 'process id: {} lock function using file path: {}'.format( - process_id, lock_file_path - ) + f'process id: {process_id} lock function using file path: {lock_file_path}' ) # write the process id that locked this function _write_content(handler, process_id) @@ -303,9 +301,7 @@ def locking_function( with file_lock(lock_file_path, remove=False, timeout=timeout) as handler: logger.info( - 'process id: {} - lock function name:{} - using file path: {}'.format( - process_id, function_name, lock_file_path - ) + f'process id: {process_id} - lock function name:{function_name} - using file path: {lock_file_path}' ) # write the process id that locked this function _write_content(handler, process_id) diff --git a/robottelo/utils/decorators/func_shared/shared.py b/robottelo/utils/decorators/func_shared/shared.py index 73961df50b..4c325084c4 100644 --- a/robottelo/utils/decorators/func_shared/shared.py +++ b/robottelo/utils/decorators/func_shared/shared.py @@ -271,9 +271,7 @@ def _call_function(self): traceback_text = None try: logger.info( - 'calling shared function: {} - retry index: {}'.format( - self._function_key, retry_index - ) + f'calling shared function: {self._function_key} - retry index: {retry_index}' ) result = self._function(*self._function_args, **self._function_kwargs) break @@ -334,9 +332,7 @@ def __call__(self): creation_datetime = datetime.datetime.utcnow().strftime(_DATETIME_FORMAT) if exp: error = str(exp) or 'error occurred' - error_class_name = '{}.{}'.format( - exp.__class__.__module__, exp.__class__.__name__ - ) + error_class_name = f'{exp.__class__.__module__}.{exp.__class__.__name__}' value = dict( state=_STATE_FAILED, id=self.transaction, diff --git a/robottelo/utils/virtwho.py b/robottelo/utils/virtwho.py index b1cac0012c..9d2b033d6e 100644 --- a/robottelo/utils/virtwho.py +++ b/robottelo/utils/virtwho.py @@ -99,18 +99,14 @@ def register_system(system, activation_key=None, org='Default_Organization', env runcmd('subscription-manager clean', system) runcmd('rpm -qa | grep katello-ca-consumer | xargs rpm -e |sort', system) runcmd( - 'rpm -ihv http://{}/pub/katello-ca-consumer-latest.noarch.rpm'.format( - settings.server.hostname - ), + f'rpm -ihv http://{settings.server.hostname}/pub/katello-ca-consumer-latest.noarch.rpm', system, ) cmd = f'subscription-manager register --org={org} --environment={env} ' if activation_key is not None: cmd += f'--activationkey={activation_key}' else: - cmd += '--username={} --password={}'.format( - settings.server.admin_username, settings.server.admin_password - ) + cmd += f'--username={settings.server.admin_username} --password={settings.server.admin_password}' ret, stdout = runcmd(cmd, system) if ret == 0 or "system has been registered" in stdout: return True @@ -170,9 +166,7 @@ def get_configure_command(config_id, org=DEFAULT_ORG): :param str org: the satellite organization name. """ username, password = Base._get_username_password() - return "hammer -u {} -p {} virt-who-config deploy --id {} --organization '{}' ".format( - username, password, config_id, org - ) + return f"hammer -u {username} -p {password} virt-who-config deploy --id {config_id} --organization '{org}' " def get_configure_file(config_id): diff --git a/tests/foreman/ui/test_audit.py b/tests/foreman/ui/test_audit.py index 24829094da..b7d0ce6344 100644 --- a/tests/foreman/ui/test_audit.py +++ b/tests/foreman/ui/test_audit.py @@ -181,6 +181,6 @@ def test_positive_add_event(session, module_org, module_target_sat): assert values['resource_type'] == 'KATELLO/CONTENT VIEW ENVIRONMENT' assert values['resource_name'] == f'{ENVIRONMENT}/{cv.name} / {cv.name}' assert len(values['action_summary']) == 1 - assert values['action_summary'][0]['column0'] == 'Added {}/{} to {}'.format( - ENVIRONMENT, cv.name, cv.name + assert ( + values['action_summary'][0]['column0'] == f'Added {ENVIRONMENT}/{cv.name} to {cv.name}' ) diff --git a/tests/foreman/ui/test_computeprofiles.py b/tests/foreman/ui/test_computeprofiles.py index 035e09a993..dfe73935f3 100644 --- a/tests/foreman/ui/test_computeprofiles.py +++ b/tests/foreman/ui/test_computeprofiles.py @@ -35,8 +35,8 @@ def test_positive_end_to_end(session, module_location, module_org, module_target session.computeprofile.create({'name': name}) assert module_target_sat.api.ComputeProfile().search(query={'search': f'name={name}'}), ( - 'Compute profile {} expected to exist, but is not included in the search ' - 'results'.format(name) + f'Compute profile {name} expected to exist, but is not included in the search ' + 'results' ) compute_resource_list = session.computeprofile.list_resources(name) assert f'{compute_resource.name} (Libvirt)' in [ @@ -46,13 +46,13 @@ def test_positive_end_to_end(session, module_location, module_org, module_target assert module_target_sat.api.ComputeProfile().search( query={'search': f'name={new_name}'} ), ( - 'Compute profile {} expected to exist, but is not included in the search ' - 'results'.format(new_name) + f'Compute profile {new_name} expected to exist, but is not included in the search ' + 'results' ) session.computeprofile.delete(new_name) assert not module_target_sat.api.ComputeProfile().search( query={'search': f'name={new_name}'} ), ( - 'Compute profile {} expected to be deleted, but is included in the search ' - 'results'.format(new_name) + f'Compute profile {new_name} expected to be deleted, but is included in the search ' + 'results' ) diff --git a/tests/foreman/ui/test_dashboard.py b/tests/foreman/ui/test_dashboard.py index 5cc044e1e5..9788e1c6f3 100644 --- a/tests/foreman/ui/test_dashboard.py +++ b/tests/foreman/ui/test_dashboard.py @@ -159,9 +159,7 @@ def test_positive_task_status(session, target_sat): tasks = session.task.read_all() total_items = session.task.total_items() assert total_items == int(tasks['StoppedChart']['table'][1]['Total']) - task_name = "Synchronize repository '{}'; product '{}'; organization '{}'".format( - repo.name, product.name, org.name - ) + task_name = f"Synchronize repository '{repo.name}'; product '{product.name}'; organization '{org.name}'" assert tasks['table'][0]['Action'] == task_name assert tasks['table'][0]['State'] == 'stopped' assert tasks['table'][0]['Result'] == 'warning' diff --git a/tests/foreman/ui/test_hostcollection.py b/tests/foreman/ui/test_hostcollection.py index b6c90d685e..91c76c5536 100644 --- a/tests/foreman/ui/test_hostcollection.py +++ b/tests/foreman/ui/test_hostcollection.py @@ -756,8 +756,8 @@ def test_positive_install_modular_errata( """ stream = "0" version = "20180704111719" - _module_install_command = 'dnf -y module install {}:{}:{}'.format( - constants.FAKE_4_CUSTOM_PACKAGE_NAME, stream, version + _module_install_command = ( + f'dnf -y module install {constants.FAKE_4_CUSTOM_PACKAGE_NAME}:{stream}:{version}' ) _run_remote_command_on_content_hosts(_module_install_command, vm_content_hosts_module_stream) _run_remote_command_on_content_hosts('dnf -y upload-profile', vm_content_hosts_module_stream) diff --git a/tests/foreman/ui/test_repository.py b/tests/foreman/ui/test_repository.py index b8ac36f644..8522e03a4d 100644 --- a/tests/foreman/ui/test_repository.py +++ b/tests/foreman/ui/test_repository.py @@ -583,8 +583,9 @@ def test_positive_upstream_with_credentials(session, module_prod): ) assert session.repository.search(module_prod.name, repo_name)[0]['Name'] == repo_name repo_values = session.repository.read(module_prod.name, repo_name) - assert repo_values['repo_content']['upstream_authorization'] == '{} / {}'.format( - upstream_username, hidden_password + assert ( + repo_values['repo_content']['upstream_authorization'] + == f'{upstream_username} / {hidden_password}' ) session.repository.update( module_prod.name, @@ -596,8 +597,9 @@ def test_positive_upstream_with_credentials(session, module_prod): }, ) repo_values = session.repository.read(module_prod.name, repo_name) - assert repo_values['repo_content']['upstream_authorization'] == '{} / {}'.format( - new_upstream_username, hidden_password + assert ( + repo_values['repo_content']['upstream_authorization'] + == f'{new_upstream_username} / {hidden_password}' ) session.repository.update( module_prod.name, repo_name, {'repo_content.upstream_authorization': {}} From 63fd51dea7a3152b3cb9182f5299aaba83912f3f Mon Sep 17 00:00:00 2001 From: Peter Ondrejka Date: Fri, 26 Apr 2024 11:49:03 +0200 Subject: [PATCH 05/20] fixes in rex infrahost tests (#14874) --- tests/foreman/cli/test_remoteexecution.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/tests/foreman/cli/test_remoteexecution.py b/tests/foreman/cli/test_remoteexecution.py index c5a353395b..8667b6aae3 100644 --- a/tests/foreman/cli/test_remoteexecution.py +++ b/tests/foreman/cli/test_remoteexecution.py @@ -635,12 +635,17 @@ class TestRexUsers: """Tests related to remote execution users""" @pytest.fixture(scope='class') - def class_rexmanager_user(self, module_org, class_target_sat): + def class_rexmanager_user(self, module_org, default_location, class_target_sat): """Creates a user with Remote Execution Manager role""" password = gen_string('alpha') rexmanager = gen_string('alpha') class_target_sat.cli_factory.user( - {'login': rexmanager, 'password': password, 'organization-ids': module_org.id} + { + 'login': rexmanager, + 'password': password, + 'organization-ids': module_org.id, + 'location-ids': default_location.id, + } ) class_target_sat.cli.User.add_role( {'login': rexmanager, 'role': 'Remote Execution Manager'} @@ -648,12 +653,17 @@ def class_rexmanager_user(self, module_org, class_target_sat): return (rexmanager, password) @pytest.fixture(scope='class') - def class_rexinfra_user(self, module_org, class_target_sat): + def class_rexinfra_user(self, module_org, default_location, class_target_sat): """Creates a user with all Remote Execution related permissions""" password = gen_string('alpha') rexinfra = gen_string('alpha') class_target_sat.cli_factory.user( - {'login': rexinfra, 'password': password, 'organization-ids': module_org.id} + { + 'login': rexinfra, + 'password': password, + 'organization-ids': module_org.id, + 'location-ids': default_location.id, + } ) role = class_target_sat.cli_factory.make_role({'organization-ids': module_org.id}) invocation_permissions = [ From 93500d4594bfe0d7d26d84d0a8097a556f464e2d Mon Sep 17 00:00:00 2001 From: Peter Ondrejka Date: Fri, 26 Apr 2024 12:48:58 +0200 Subject: [PATCH 06/20] version selection for some host tests (#14872) --- tests/foreman/cli/test_host.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/foreman/cli/test_host.py b/tests/foreman/cli/test_host.py index fe01b0bc97..d053d7d513 100644 --- a/tests/foreman/cli/test_host.py +++ b/tests/foreman/cli/test_host.py @@ -1552,6 +1552,7 @@ def yum_security_plugin(katello_host_tools_host): @pytest.mark.e2e @pytest.mark.cli_katello_host_tools +@pytest.mark.rhel_ver_match('[^6].*') @pytest.mark.tier3 def test_positive_report_package_installed_removed( katello_host_tools_host, setup_custom_repo, target_sat @@ -1597,6 +1598,7 @@ def test_positive_report_package_installed_removed( @pytest.mark.cli_katello_host_tools +@pytest.mark.rhel_ver_match('[^6].*') @pytest.mark.tier3 def test_positive_package_applicability(katello_host_tools_host, setup_custom_repo, target_sat): """Ensure packages applicability is functioning properly @@ -1658,6 +1660,7 @@ def test_positive_package_applicability(katello_host_tools_host, setup_custom_re @pytest.mark.e2e @pytest.mark.cli_katello_host_tools +@pytest.mark.rhel_ver_match('[^6].*') @pytest.mark.pit_client @pytest.mark.pit_server @pytest.mark.tier3 @@ -1727,6 +1730,7 @@ def test_positive_erratum_applicability( @pytest.mark.cli_katello_host_tools +@pytest.mark.rhel_ver_match('[^6].*') @pytest.mark.tier3 def test_positive_apply_security_erratum(katello_host_tools_host, setup_custom_repo, target_sat): """Apply security erratum to a host From c9af98b7d98a8cfe2331e278094b13d0289e9f59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hellebrandt?= Date: Fri, 26 Apr 2024 17:48:06 +0200 Subject: [PATCH 07/20] Assert commands results. Remove CA download, machines already have it. Do not install a library through pip. (#14511) --- pytest_fixtures/component/satellite_auth.py | 52 ++++++++++--------- .../destructive/test_ldap_authentication.py | 4 +- 2 files changed, 30 insertions(+), 26 deletions(-) diff --git a/pytest_fixtures/component/satellite_auth.py b/pytest_fixtures/component/satellite_auth.py index 9af5a98287..d729559d19 100644 --- a/pytest_fixtures/component/satellite_auth.py +++ b/pytest_fixtures/component/satellite_auth.py @@ -18,7 +18,6 @@ from robottelo.hosts import IPAHost, SSOHost from robottelo.utils.datafactory import gen_string from robottelo.utils.installer import InstallerCommand -from robottelo.utils.issue_handlers import is_open LOGGEDOUT = 'Logged out.' @@ -282,42 +281,45 @@ def auth_data(request, ad_data, ipa_data): @pytest.fixture(scope='module') def enroll_configure_rhsso_external_auth(module_target_sat): """Enroll the Satellite6 Server to an RHSSO Server.""" - module_target_sat.execute( - 'yum -y --disableplugin=foreman-protector install ' - 'mod_auth_openidc keycloak-httpd-client-install' + module_target_sat.register_to_cdn() + # keycloak-httpd-client-install needs lxml but it's not an rpm dependency + is not documented + assert ( + module_target_sat.execute( + 'yum -y --disableplugin=foreman-protector install ' + 'mod_auth_openidc keycloak-httpd-client-install python3-lxml ' + ).status + == 0 ) # if target directory not given it is installing in /usr/local/lib64 - module_target_sat.execute('python3 -m pip install lxml -t /usr/lib64/python3.6/site-packages') - module_target_sat.execute( - f'openssl s_client -connect {settings.rhsso.host_name} -showcerts /dev/null| ' - f'sed "/BEGIN CERTIFICATE/,/END CERTIFICATE/!d" > {CERT_PATH}/rh-sso.crt' - ) - module_target_sat.execute( - f'sshpass -p "{settings.rhsso.rhsso_password}" scp -o "StrictHostKeyChecking no" ' - f'root@{settings.rhsso.host_name}:/root/ca_certs/*.crt {CERT_PATH}' + assert ( + module_target_sat.execute( + f'openssl s_client -connect {settings.rhsso.host_name}:443 -showcerts /dev/null| ' + f'sed "/BEGIN CERTIFICATE/,/END CERTIFICATE/!d" > {CERT_PATH}/rh-sso.crt' + ).status + == 0 ) - module_target_sat.execute('update-ca-trust') - module_target_sat.execute( - f'echo {settings.rhsso.rhsso_password} | keycloak-httpd-client-install \ + assert ( + module_target_sat.execute( + f'echo {settings.rhsso.rhsso_password} | keycloak-httpd-client-install \ --app-name foreman-openidc \ --keycloak-server-url {settings.rhsso.host_url} \ --keycloak-admin-username "admin" \ --keycloak-realm "{settings.rhsso.realm}" \ --keycloak-admin-realm master \ --keycloak-auth-role root-admin -t openidc -l /users/extlogin --force' + ).status + == 0 ) - if is_open('BZ:2113905'): + assert ( module_target_sat.execute( - r"sed -i -e '$aapache::default_mods:\n - authn_core' " - "/etc/foreman-installer/custom-hiera.yaml" - ) - module_target_sat.execute( - f'satellite-installer --foreman-keycloak true ' - f"--foreman-keycloak-app-name 'foreman-openidc' " - f"--foreman-keycloak-realm '{settings.rhsso.realm}' ", - timeout=1000000, + f'satellite-installer --foreman-keycloak true ' + f"--foreman-keycloak-app-name 'foreman-openidc' " + f"--foreman-keycloak-realm '{settings.rhsso.realm}' ", + timeout=1000000, + ).status + == 0 ) - module_target_sat.execute('systemctl restart httpd') + assert module_target_sat.execute('systemctl restart httpd').status == 0 @pytest.fixture(scope='module') diff --git a/tests/foreman/destructive/test_ldap_authentication.py b/tests/foreman/destructive/test_ldap_authentication.py index 33539fff89..3a8468de3d 100644 --- a/tests/foreman/destructive/test_ldap_authentication.py +++ b/tests/foreman/destructive/test_ldap_authentication.py @@ -327,7 +327,9 @@ def test_session_expire_rhsso_idle_timeout( session.rhsso_login.login( {'username': settings.rhsso.rhsso_user, 'password': settings.rhsso.rhsso_password} ) - sleep(60) + sleep( + 150 + ) # give the browser some time to actually logout, even though Satellite should terminate session after one minute with pytest.raises(NavigationTriesExceeded) as error: session.task.read_all(widget_names='current_user')['current_user'] assert error.typename == 'NavigationTriesExceeded' From eef3b2d7a40838faf915ca0c1e55438b6d434535 Mon Sep 17 00:00:00 2001 From: Jameer Pathan <21165044+jameerpathan111@users.noreply.github.com> Date: Fri, 26 Apr 2024 21:33:48 +0200 Subject: [PATCH 08/20] Fix CaseAutomation for tests and delete Certificates related tests as part of component audit. (#14873) Delete Certificates related tests as part of component refactor task --- tests/foreman/api/test_discoveredhost.py | 2 +- tests/foreman/api/test_operatingsystem.py | 2 +- tests/foreman/api/test_provisioning.py | 4 +- tests/foreman/sys/test_katello_certs_check.py | 41 +------------------ tests/upgrades/test_role.py | 10 +++-- 5 files changed, 13 insertions(+), 46 deletions(-) diff --git a/tests/foreman/api/test_discoveredhost.py b/tests/foreman/api/test_discoveredhost.py index 59783b9a8b..976c1812e4 100644 --- a/tests/foreman/api/test_discoveredhost.py +++ b/tests/foreman/api/test_discoveredhost.py @@ -313,7 +313,7 @@ def test_positive_auto_provision_all( :expectedresults: All discovered hosts should be auto-provisioned successfully - :CaseAutomation: NotAutomated + :CaseAutomation: Automated :CaseImportance: High """ diff --git a/tests/foreman/api/test_operatingsystem.py b/tests/foreman/api/test_operatingsystem.py index 9e25a92e16..9263ca6b30 100644 --- a/tests/foreman/api/test_operatingsystem.py +++ b/tests/foreman/api/test_operatingsystem.py @@ -2,7 +2,7 @@ :Requirement: Provisioning -:CaseAutomation: NotAutomated +:CaseAutomation: Automated :CaseComponent: Provisioning diff --git a/tests/foreman/api/test_provisioning.py b/tests/foreman/api/test_provisioning.py index 7d67db042c..64e65487f1 100644 --- a/tests/foreman/api/test_provisioning.py +++ b/tests/foreman/api/test_provisioning.py @@ -2,7 +2,7 @@ :Requirement: Provisioning -:CaseAutomation: NotAutomated +:CaseAutomation: Automated :CaseComponent: Provisioning @@ -733,4 +733,6 @@ def test_rhel_provisioning_using_realm(): 3. Host installs right version of RHEL 4. Satellite is able to run REX job on the host 5. Host is registered to Satellite and subscription status is 'Success' + + :CaseAutomation: NotAutomated """ diff --git a/tests/foreman/sys/test_katello_certs_check.py b/tests/foreman/sys/test_katello_certs_check.py index 820501f371..4c4906e392 100644 --- a/tests/foreman/sys/test_katello_certs_check.py +++ b/tests/foreman/sys/test_katello_certs_check.py @@ -157,28 +157,6 @@ def test_positive_validate_katello_certs_check_output(self, cert_setup_teardown) result = target_sat.execute(command) self.validate_output(result, cert_data) - @pytest.mark.tier1 - def test_katello_certs_check_output_wildcard_inputs(self, cert_setup_teardown): - """Validate that katello-certs-check generates correct output with wildcard certs. - - :id: 7f9da806-5b23-11eb-b7ea-d46d6dd3b5b2 - - :steps: - - 1. Get valid wildcard certs from generate_certs - 2. Run katello-certs-check with the required valid arguments - katello-certs-check -c CERT_FILE -k KEY_FILE -r REQ_FILE - -b CA_BUNDLE_FILE - 3. Assert the output has correct commands with options - - :expectedresults: katello-certs-check should generate correct commands - with options. - """ - cert_data, target_sat = cert_setup_teardown - command = 'katello-certs-check -c certs/wildcard.crt -k certs/wildcard.key -b certs/ca.crt' - result = target_sat.execute(command) - self.validate_output(result, cert_data) - @pytest.mark.parametrize(('error', 'cert_file', 'key_file', 'ca_file'), invalid_inputs) @pytest.mark.tier1 def test_katello_certs_check_output_invalid_input( @@ -234,7 +212,7 @@ def test_negative_check_expiration_of_certificate(self, cert_setup_teardown): :expectedresults: Checking expiration of certificate check should fail. - :CaseAutomation: NotAutomated + :CaseAutomation: Automated """ cert_data, target_sat = cert_setup_teardown hostname = target_sat.hostname @@ -275,20 +253,3 @@ def test_negative_validate_certificate_subject(self): :CaseAutomation: NotAutomated """ - - @pytest.mark.stubbed - @pytest.mark.tier1 - def test_negative_check_private_key_match(self): - """Validate private key match with certificate. - - :id: 358edbb3-08b0-47d7-856b-ce0d5ea95979 - - :steps: - - 1. Have KEY_FILE with invalid private key - 2. Run katello-certs-check with the required arguments - - :expectedresults: Private key match with the certificate should fail. - - :CaseAutomation: NotAutomated - """ diff --git a/tests/upgrades/test_role.py b/tests/upgrades/test_role.py index c2ee4b25d2..25c0ab411c 100644 --- a/tests/upgrades/test_role.py +++ b/tests/upgrades/test_role.py @@ -2,7 +2,7 @@ :Requirement: UpgradedSatellite -:CaseAutomation: NotAutomated +:CaseAutomation: Automated :CaseComponent: UsersRoles @@ -31,6 +31,8 @@ class TestOverriddenFilter: 1. The Filter should be have set override flag postupgrade 2. The locations and organizations of filter should be unchanged postupgrade + + :CaseAutomation: NotAutomated """ @pytest.mark.pre_upgrade @@ -82,6 +84,8 @@ class TestBuiltInRolesLocked: 1. Builtin roles of satellite should be locked and non-editable 2. Built in roles of satellite should be allowed to clone + + :CaseAutomation: NotAutomated """ @pytest.mark.post_upgrade @@ -117,6 +121,8 @@ class TestNewOrganizationAdminRole: non-editable 4. Organization Admin role of satellite should be allowed to clone 5. Taxonomies should be assigned to cloned org admin role + + :CaseAutomation: NotAutomated """ @pytest.mark.post_upgrade @@ -164,7 +170,6 @@ def test_pre_default_role_added_permission(self, target_sat): :steps: New permission is added to existing 'Default role' :expectedresults: Permission is added to existing 'Default role'. - """ default_role = target_sat.api.Role().search(query={'search': 'name="Default role"'})[0] subnet_filter = target_sat.api.Filter( @@ -219,7 +224,6 @@ def test_pre_default_role_added_permission_with_filter(self, target_sat): :expectedresults: Permission with filter is added to existing 'Default role' - """ default_role = target_sat.api.Role().search(query={'search': 'name="Default role"'})[0] domain_filter = target_sat.api.Filter( From e8eb38d95df6552e8c6592b307fffe5d88de7c90 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Apr 2024 00:08:35 -0400 Subject: [PATCH 09/20] Bump pytest from 8.1.1 to 8.2.0 (#14905) --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 2adc13eb18..8c521b30b9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,7 +13,7 @@ navmazing==1.2.2 productmd==1.38 pyotp==2.9.0 python-box==7.1.1 -pytest==8.1.1 +pytest==8.2.0 pytest-order==1.2.1 pytest-services==2.2.1 pytest-mock==3.14.0 From de93ea2c21b4a480358d75fbaab9dd0607473811 Mon Sep 17 00:00:00 2001 From: Pavel Novotny Date: Mon, 29 Apr 2024 14:39:55 +0200 Subject: [PATCH 10/20] host edit: test correct page redirection (#14844) hosts: test correct page redirect after host edit Component evaluation - SAT-21625 https://bugzilla.redhat.com/2166303 Check that after editing a host without making any changes(*), the page is correctly redirected to the host details page. (*) Making or not making any changes in the edit dialog actually does not matter. --- tests/foreman/ui/test_host.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/foreman/ui/test_host.py b/tests/foreman/ui/test_host.py index 7fec6db1f7..0869a68290 100644 --- a/tests/foreman/ui/test_host.py +++ b/tests/foreman/ui/test_host.py @@ -1944,3 +1944,29 @@ def test_change_content_source(session, change_content_source_prep, rhel_content rhel_contenthost_post_values['lifecycle_environment']['name'] == rhel_contenthost_post_values['lifecycle_environment']['name'] ) + + +@pytest.mark.tier3 +@pytest.mark.rhel_ver_match('8') +def test_positive_page_redirect_after_update(target_sat, current_sat_location): + """Check that page redirects correctly after editing a host without making any changes. + + :id: 29c3397e-0010-11ef-bca4-000c2989e153 + + :steps: + 1. Go to All Hosts page. + 2. Edit a host. Using the Sat. host is sufficient, no other host needs to be created or registered, + because we need just a host with FQDN. + 3. Submit the host edit dialog without making any changes. + + :expectedresults: The page should be redirected to the host details page. + + :BZ: 2166303 + """ + client = target_sat + with target_sat.ui_session() as session: + session.location.select(loc_name=current_sat_location.name) + session.host_new.update(client.hostname, {}) + + assert 'page-not-found' not in session.browser.url + assert client.hostname in session.browser.url From 15101cf283fe85e078208dbb108345b6c5a66d68 Mon Sep 17 00:00:00 2001 From: David Moore <109112035+damoore044@users.noreply.github.com> Date: Tue, 30 Apr 2024 05:13:47 -0400 Subject: [PATCH 11/20] Quick fix- CI failure- for number of found CV publish tasks (#14890) CI fix for CV publish tasks --- tests/foreman/api/test_contentview.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/foreman/api/test_contentview.py b/tests/foreman/api/test_contentview.py index 2cbeaf5086..d898c2604b 100644 --- a/tests/foreman/api/test_contentview.py +++ b/tests/foreman/api/test_contentview.py @@ -552,6 +552,7 @@ def test_negative_publish_during_repo_sync(self, content_view, module_target_sat 2. HTTP exception raised, assert publish task failed for expected reason, repo sync task_id found in humanized error, content-view versions unchanged. """ + org = content_view.organization.read() # add repository to content-view content_view.repository = [self.yum_repo] content_view.update(['repository']) @@ -565,15 +566,14 @@ def test_negative_publish_during_repo_sync(self, content_view, module_target_sat with pytest.raises(HTTPError) as InternalServerError: content_view.publish() assert str(content_view.id) in str(InternalServerError) - # search for failed publish task - task_action = 'Actions::Katello::ContentView::Publish' + task_action = f"Publish content view '{content_view.name}', organization '{org.name}'" task_search = module_target_sat.api.ForemanTask().search( query={'search': f'{task_action} and started_at >= "{timestamp}"'} ) - assert len(task_search) == 1 + assert len(task_search) > 0 task_id = task_search[0].id - # task failed for expected reason + # publish task failed for expected reason task = module_target_sat.api.ForemanTask(id=task_id).poll(must_succeed=False) assert task['result'] == 'error' assert len(task['humanized']['errors']) == 1 From 4c00785383e3a0e2c71de44ce9411b41a6956f39 Mon Sep 17 00:00:00 2001 From: Peter Ondrejka Date: Tue, 30 Apr 2024 14:22:22 +0200 Subject: [PATCH 12/20] added scap constant (#14921) --- robottelo/constants/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/robottelo/constants/__init__.py b/robottelo/constants/__init__.py index 78d32535ef..4851a6d34d 100644 --- a/robottelo/constants/__init__.py +++ b/robottelo/constants/__init__.py @@ -1607,6 +1607,7 @@ class Colored(Box): 'cbrhel6': 'PCI-DSS v3.2.1 Control Baseline for Red Hat Enterprise Linux 6', 'cbrhel7': 'PCI-DSS v3.2.1 Control Baseline for Red Hat Enterprise Linux 7', 'cbrhel8': 'PCI-DSS v3.2.1 Control Baseline for Red Hat Enterprise Linux 8', + 'cbrhel9': 'PCI-DSS v3.2.1 Control Baseline for Red Hat Enterprise Linux 9', 'ppgpo': 'Protection Profile for General Purpose Operating Systems', 'acscee': 'Australian Cyber Security Centre (ACSC) Essential Eight', 'ospp7': 'OSPP - Protection Profile for General Purpose Operating Systems v4.2.1', From 3f1b9e419c906275b739a03019c094960afed68f Mon Sep 17 00:00:00 2001 From: Samuel Bible Date: Tue, 30 Apr 2024 14:58:22 -0500 Subject: [PATCH 13/20] CC Automation/Comp Eval coverage - promote CCV with specific registry_name (#14451) * CC Automation/Comp Eval coverage * change to non-sca org * CC Automation/Comp Eval coverage * change to non-sca org * Fix formatting issues * Adjust assert statement, and fix docstring issue * Adjust assert statement, and fix docstring issue --- tests/foreman/api/test_contentview.py | 58 +++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/tests/foreman/api/test_contentview.py b/tests/foreman/api/test_contentview.py index d898c2604b..eda0c9ec6b 100644 --- a/tests/foreman/api/test_contentview.py +++ b/tests/foreman/api/test_contentview.py @@ -22,6 +22,7 @@ from robottelo.constants import ( CONTAINER_REGISTRY_HUB, CUSTOM_RPM_SHA_512_FEED_COUNT, + DEFAULT_ARCHITECTURE, FILTER_ERRATA_TYPE, PERMISSIONS, PRDS, @@ -279,6 +280,63 @@ def test_positive_add_sha512_rpm(self, content_view, module_org, module_target_s content_view_version.errata_counts['total'] == CUSTOM_RPM_SHA_512_FEED_COUNT['errata'] ) + @pytest.mark.tier2 + def test_ccv_promote_registry_name_change(self, module_target_sat, module_sca_manifest_org): + """Testing CCV promotion scenarios where the registry_name has been changed to some + specific value. + + :id: 41641d4a-d144-4833-869a-284624df2410 + + :steps: + + 1) Sync a RH Repo + 2) Create a CV, add the repo and publish it + 3) Create a CCV and add the CV version to it, then publish it + 4) Create LCEs with the specific value for registry_name + 5) Promote the CCV to both LCEs + + :expectedresults: CCV can be promoted to both LCEs without issue. + + :CaseImportance: High + + :customerscenario: true + + :BZ: 2153523 + """ + rh_repo_id = module_target_sat.api_factory.enable_rhrepo_and_fetchid( + basearch=DEFAULT_ARCHITECTURE, + org_id=module_sca_manifest_org.id, + product=REPOS['kickstart']['rhel8_aps']['product'], + repo=REPOS['kickstart']['rhel8_aps']['name'], + reposet=REPOS['kickstart']['rhel8_aps']['reposet'], + releasever=REPOS['kickstart']['rhel8_aps']['version'], + ) + repo = module_target_sat.api.Repository(id=rh_repo_id).read() + repo.sync(timeout=600) + cv = module_target_sat.api.ContentView(organization=module_sca_manifest_org).create() + cv = module_target_sat.api.ContentView(id=cv.id, repository=[repo]).update(["repository"]) + cv.publish() + cv = cv.read() + composite_cv = module_target_sat.api.ContentView( + organization=module_sca_manifest_org, composite=True + ).create() + composite_cv.component = [cv.version[0]] + composite_cv = composite_cv.update(['component']) + composite_cv.publish() + composite_cv = composite_cv.read() + # Create LCEs with the specific registry value + lce1 = module_target_sat.api.LifecycleEnvironment( + organization=module_sca_manifest_org, + registry_name_pattern='<%= repository.name %>', + ).create() + lce2 = module_target_sat.api.LifecycleEnvironment( + organization=module_sca_manifest_org, + registry_name_pattern='<%= lifecycle_environment.label %>/<%= repository.name %>', + ).create() + version = composite_cv.version[0].read() + assert 'success' in version.promote(data={'environment_ids': lce1.id})['result'] + assert 'success' in version.promote(data={'environment_ids': lce2.id})['result'] + class TestContentViewCreate: """Create tests for content views.""" From 9448d4be9cfbe661103f1ff9382016a581bc5c88 Mon Sep 17 00:00:00 2001 From: David Moore <109112035+damoore044@users.noreply.github.com> Date: Wed, 1 May 2024 12:11:17 -0400 Subject: [PATCH 14/20] [stream] fixes for combined session failures, Errata UI (#14822) * Refactor and fix of some Errata UI tests * UI fixture and other updates for combined sessions --------- Co-authored-by: Ladislav Vasina --- tests/foreman/ui/test_errata.py | 235 +++++++++++++++++--------------- 1 file changed, 125 insertions(+), 110 deletions(-) diff --git a/tests/foreman/ui/test_errata.py b/tests/foreman/ui/test_errata.py index dadcaf6bef..becd3e6dcf 100644 --- a/tests/foreman/ui/test_errata.py +++ b/tests/foreman/ui/test_errata.py @@ -11,7 +11,7 @@ :CaseImportance: High """ -from datetime import datetime +from datetime import datetime, timedelta from broker import Broker from dateutil.parser import parse @@ -209,10 +209,10 @@ def _publish_and_wait(sat, org, cv): @pytest.fixture -def errata_host_ak(module_target_sat, module_org, module_lce): - """New activation key created in module_org and module_lce""" +def errata_host_ak(module_target_sat, module_sca_manifest_org, module_lce): + """New activation key created in module SCA org and module lce""" ak = module_target_sat.api.ActivationKey( - organization=module_org, + organization=module_sca_manifest_org, environment=module_lce, ).create() return ak.read() @@ -220,10 +220,10 @@ def errata_host_ak(module_target_sat, module_org, module_lce): @pytest.fixture def registered_contenthost( + module_sca_manifest_org, module_target_sat, rhel_contenthost, errata_host_ak, - module_org, module_lce, module_cv, request, @@ -260,7 +260,7 @@ def registered_contenthost( custom_repo_info = module_target_sat.cli_factory.setup_org_for_a_custom_repo( { 'url': repo_url, - 'organization-id': module_org.id, + 'organization-id': module_sca_manifest_org.id, 'lifecycle-environment-id': module_lce.id, 'activationkey-id': errata_host_ak.id, 'content-view-id': module_cv.id, @@ -270,17 +270,22 @@ def registered_contenthost( custom_repos.append(custom_repo_info['repository-id']) # Publish new version and promote with all content - cv_publish_promote(module_target_sat, module_org, module_cv, module_lce) + cv_publish_promote(module_target_sat, module_sca_manifest_org, module_cv, module_lce) result = rhel_contenthost.register( activation_keys=errata_host_ak.name, target=module_target_sat, - org=module_org, + org=module_sca_manifest_org, loc=None, ) assert result.status == 0, f'Failed to register host:\n{result.stderr}' - assert rhel_contenthost.subscribed + assert rhel_contenthost.subscribed, ( + f'Failed to subscribe host to content, host: {rhel_contenthost.hostname}' + f' Attempting to subscribe to content-view id: {module_cv.id}' + f' Using activation-key id: {errata_host_ak.id}' + ) for custom_repo_id in custom_repos: + # custom repos setup and successfully sync custom_repo = module_target_sat.api.Repository(id=custom_repo_id).read() assert custom_repo result = custom_repo.sync()['humanized'] @@ -291,23 +296,30 @@ def registered_contenthost( yield rhel_contenthost @request.addfinalizer - # Cleanup for in between parameterized runs + # Cleanup for in-between parameterized sessions def cleanup(): - nonlocal rhel_contenthost, module_cv, custom_repos, custom_products, errata_host_ak + nonlocal rhel_contenthost, module_cv, module_lce, custom_repos, custom_products, errata_host_ak, module_sca_manifest_org rhel_contenthost.unregister() errata_host_ak.delete() + # find any other aks and delete them + other_aks = module_target_sat.api.ActivationKey( + organization=module_sca_manifest_org, + environment=module_lce, + ).search() + for ak in other_aks: + ak.read().delete() # Remove CV from all lifecycle-environments module_target_sat.cli.ContentView.remove_from_environment( { 'id': module_cv.id, - 'organization-id': module_org.id, + 'organization-id': module_sca_manifest_org.id, 'lifecycle-environment-id': module_lce.id, } ) module_target_sat.cli.ContentView.remove_from_environment( { 'id': module_cv.id, - 'organization-id': module_org.id, + 'organization-id': module_sca_manifest_org.id, 'lifecycle-environment': 'Library', } ) @@ -326,9 +338,6 @@ def cleanup(): module_target_sat.api.Repository(id=repo_id).delete() for product_id in custom_products: module_target_sat.api.Product(id=product_id).delete() - # Publish a new CV version with no content - module_cv = module_cv.read() - module_cv.publish() @pytest.mark.e2e @@ -498,7 +507,6 @@ def test_host_content_errata_tab_pagination( module_target_sat, registered_contenthost, module_sca_manifest_org, - errata_host_ak, module_lce, module_cv, ): @@ -724,12 +732,12 @@ def test_host_content_errata_tab_pagination( @pytest.mark.skipif((not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url') def test_positive_list( module_sca_manifest_org, + errata_host_ak, function_org, function_lce, target_sat, module_lce, module_cv, - module_ak, session, ): """View all errata in an Org @@ -756,7 +764,7 @@ def test_positive_list( 'url': CUSTOM_REPO_URL, 'organization-id': _org_module.id, 'lifecycle-environment-id': module_lce.id, - 'activationkey-id': module_ak.id, + 'activationkey-id': errata_host_ak.id, 'content-view-id': module_cv.id, }, ) @@ -1081,112 +1089,99 @@ def test_positive_content_host_previous_env( @pytest.mark.tier3 +@pytest.mark.rhel_ver_match('8') @pytest.mark.parametrize( - 'module_repos_collection_with_setup', - [ - { - 'distro': 'rhel7', - 'SatelliteToolsRepository': {}, - 'RHELAnsibleEngineRepository': {'cdn': True}, - 'YumRepository': {'url': CUSTOM_REPO_URL}, - } - ], + 'registered_contenthost', + [[CUSTOM_REPO_URL]], indirect=True, ) -def test_positive_content_host_library(session, module_org_with_parameter, vm): - """Check if the applicable errata are available from the content - host's Library +def test_positive_check_errata(session, module_org_with_parameter, registered_contenthost): + """Check if the applicable errata is available from the host page - :id: 4e627410-b7b8-471b-b9b4-a18e77fdd3f8 + :id: a0694930-4bf7-4a97-b275-2be7d5f1b311 - :Setup: - - 1. Make sure multiple environments are present. - 2. Content host's Library environment has additional errata. - - :steps: Go to Content Hosts -> Select content host -> Errata Tab -> Select 'Library'. + :steps: + 1. Go to All hosts + 2. Select the host + 3. Content Tab -> Errata Tab + 4. Check the errata - :expectedresults: The errata from Library are displayed. + :expectedresults: The errata is displayed on the host page Content-Errata tab :parametrized: yes """ + + vm = registered_contenthost hostname = vm.hostname assert vm.execute(f'yum install -y {FAKE_1_CUSTOM_PACKAGE}').status == 0 with session: session.location.select(loc_name=DEFAULT_LOC) - content_host_erratum = session.contenthost.search_errata( - hostname, CUSTOM_REPO_ERRATA_ID, environment='Library Synced Content' - ) - assert content_host_erratum[0]['Id'] == CUSTOM_REPO_ERRATA_ID + read_errata = session.host_new.get_details(hostname, 'Content.Errata') + assert read_errata['Content']['Errata']['table'][0]['Errata'] == CUSTOM_REPO_ERRATA_ID @pytest.mark.tier3 +@pytest.mark.rhel_ver_match('8') @pytest.mark.parametrize( - 'module_repos_collection_with_setup', - [ - { - 'distro': 'rhel7', - 'SatelliteToolsRepository': {}, - 'RHELAnsibleEngineRepository': {'cdn': True}, - 'YumRepository': {'url': settings.repos.yum_9.url}, - } - ], + 'registered_contenthost', + [[CUSTOM_REPO_URL]], indirect=True, ) -def test_positive_content_host_search_type(session, erratatype_vm): - """Search for errata on a content host's errata tab by type. - - :id: 59e5d6e5-2537-4387-a7d3-637cc4b52d0e +def test_positive_errata_search_type(session, module_sca_manifest_org, registered_contenthost): + """Search for errata on a host's page content-errata tab by type. - :Setup: Content Host with applicable errata + :id: f278f0e8-3b64-4dbf-a0c8-b9b289474a76 :customerscenario: true - :steps: Search for errata on content host by type (e.g. 'type = security') - Step 1 Search for "type = security", assert expected amount and IDs found - Step 2 Search for "type = bugfix", assert expected amount and IDs found - Step 3 Search for "type = enhancement", assert expected amount and IDs found + :steps: Search for errata on the host Content-Errata tab by type (e.g. 'type = Security') + 1. Search for "type = Security", assert expected amount and IDs found + 2. Search for "type = Bugfix", assert expected amount and IDs found + 3. Search for "type = Enhancement", assert expected amount and IDs found :BZ: 1653293 """ - + vm = registered_contenthost pkgs = ' '.join(FAKE_9_YUM_OUTDATED_PACKAGES) - assert erratatype_vm.execute(f'yum install -y {pkgs}').status == 0 + assert vm.execute(f'yum install -y {pkgs}').status == 0 with session: session.location.select(loc_name=DEFAULT_LOC) - # Search for RHSA security errata - ch_erratum = session.contenthost.search_errata( - erratatype_vm.hostname, "type = security", environment='Library Synced Content' - ) + # Search for RHSA Security errata + security_erratas = session.host_new.get_errata_by_type( + entity_name=vm.hostname, + type='Security', + )['content']['errata']['table'] # Assert length matches known amount of RHSA errata - assert len(ch_erratum) == FAKE_9_YUM_SECURITY_ERRATUM_COUNT + assert len(security_erratas) == FAKE_9_YUM_SECURITY_ERRATUM_COUNT # Assert IDs are that of RHSA errata - errata_ids = sorted(erratum['Id'] for erratum in ch_erratum) + errata_ids = sorted(erratum['Errata'] for erratum in security_erratas) assert errata_ids == sorted(FAKE_9_YUM_SECURITY_ERRATUM) - # Search for RHBA buxfix errata - ch_erratum = session.contenthost.search_errata( - erratatype_vm.hostname, "type = bugfix", environment='Library Synced Content' - ) + # Search for RHBA Buxfix errata + bugfix_erratas = session.host_new.get_errata_by_type( + entity_name=vm.hostname, + type='Bugfix', + )['content']['errata']['table'] # Assert length matches known amount of RHBA errata - assert len(ch_erratum) == FAKE_10_YUM_BUGFIX_ERRATUM_COUNT + assert len(bugfix_erratas) == FAKE_10_YUM_BUGFIX_ERRATUM_COUNT # Assert IDs are that of RHBA errata - errata_ids = sorted(erratum['Id'] for erratum in ch_erratum) + errata_ids = sorted(erratum['Errata'] for erratum in bugfix_erratas) assert errata_ids == sorted(FAKE_10_YUM_BUGFIX_ERRATUM) - # Search for RHEA enhancement errata - ch_erratum = session.contenthost.search_errata( - erratatype_vm.hostname, "type = enhancement", environment='Library Synced Content' - ) + # Search for RHEA Enhancement errata + enhancement_erratas = session.host_new.get_errata_by_type( + entity_name=vm.hostname, + type='Enhancement', + )['content']['errata']['table'] # Assert length matches known amount of RHEA errata - assert len(ch_erratum) == FAKE_11_YUM_ENHANCEMENT_ERRATUM_COUNT + assert len(enhancement_erratas) == FAKE_11_YUM_ENHANCEMENT_ERRATUM_COUNT # Assert IDs are that of RHEA errata - errata_ids = sorted(erratum['Id'] for erratum in ch_erratum) + errata_ids = sorted(erratum['Errata'] for erratum in enhancement_erratas) assert errata_ids == sorted(FAKE_11_YUM_ENHANCEMENT_ERRATUM) @@ -1297,54 +1292,74 @@ def test_positive_show_count_on_host_pages(session, module_org, registered_conte @pytest.mark.tier3 +@pytest.mark.rhel_ver_match('8') @pytest.mark.parametrize( - 'module_repos_collection_with_setup', - [ - { - 'distro': 'rhel7', - 'SatelliteToolsRepository': {}, - 'RHELAnsibleEngineRepository': {'cdn': True}, - 'YumRepository': {'url': settings.repos.yum_9.url}, - } - ], + 'registered_contenthost', + [[CUSTOM_REPO_URL]], indirect=True, ) -def test_positive_show_count_on_content_host_details_page( - session, module_org_with_parameter, erratatype_vm +def test_positive_check_errata_counts_by_type_on_host_details_page( + session, + module_target_sat, + module_sca_manifest_org, + registered_contenthost, ): - """Errata count on Content host Details page + """Errata count on host page - :id: 388229da-2b0b-41aa-a457-9b5ecbf3df4b + :id: 89676641-2614-4abb-afed-5c37be396fad :Setup: - 1. Errata synced on satellite server. - 2. Some content hosts are present. + 2. Some registered host with errata and packages is present. + 3. Install list of outdated packages (FAKE_YUM_9), to the registered host. - :steps: Go to Hosts -> Content Hosts -> Select Content Host -> Details page. + :steps: + 1. Go to All hosts + 2. Select the host + 3. Content Tab -> Errata Tab + 4. Check the counts of the errata types - :expectedresults: The errata section should be displayed with Security, Bug fix, Enhancement. + :expectedresults: + 1. Packages install succeeds, errata applicability updates automatically. + 2. Correct number of each errata type shown for host. - :BZ: 1484044 """ - vm = erratatype_vm + vm = registered_contenthost hostname = vm.hostname with session: session.location.select(loc_name=DEFAULT_LOC) - content_host_values = session.contenthost.read(hostname, 'details') - for errata_type in ('security', 'bug_fix', 'enhancement'): - assert int(content_host_values['details'][errata_type]) == 0 + # from details: no errata to start + read_errata = session.host_new.get_details(hostname, 'Content.Errata') + assert int(len(read_errata['Content']['Errata']['pagination'])) == 0 pkgs = ' '.join(FAKE_9_YUM_OUTDATED_PACKAGES) + install_timestamp = datetime.utcnow().replace(microsecond=0) - timedelta(seconds=1) assert vm.execute(f'yum install -y {pkgs}').status == 0 - # navigate to content host main page by making a search, to refresh the details page - session.contenthost.search(hostname) - content_host_values = session.contenthost.read(hostname, 'details') - assert int(content_host_values['details']['security']) == FAKE_9_YUM_SECURITY_ERRATUM_COUNT - - for errata_type in ('bug_fix', 'enhancement'): - assert int(content_host_values['details'][errata_type]) == 1 + # applicability task(s) found and succeed + applicability_tasks = module_target_sat.wait_for_tasks( + search_query=( + f'Bulk generate applicability for host {hostname}' + f' and started_at >= "{install_timestamp}"' + ), + search_rate=2, + max_tries=60, + ) + assert len(applicability_tasks) > 0, ( + 'No Errata applicability task(s) found after successful yum install.' + ' Expected at least one task invoked automatically,' + f' for registered host: {hostname}' + ) + for task in applicability_tasks: + assert task.result == 'success' + assert module_target_sat.api.ForemanTask(id=task.id).poll() + + # find newly applicable errata counts by type + session.browser.refresh() + errata_type_counts = session.host_new.get_errata_type_counts(entity_name=hostname) + assert errata_type_counts['Security'] == FAKE_9_YUM_SECURITY_ERRATUM_COUNT + assert errata_type_counts['Bugfix'] == 1 + assert errata_type_counts['Enhancement'] == 1 @pytest.mark.tier3 From ddd6cca145afdb5a5d3da07b28638e6729469311 Mon Sep 17 00:00:00 2001 From: David Moore <109112035+damoore044@users.noreply.github.com> Date: Wed, 1 May 2024 15:00:35 -0400 Subject: [PATCH 15/20] [Stream] Errata-UI: Fix test_positive_host_content_library (#14926) Updates for new host, and legacy chost pages Fix conflict with new UI test case. --- tests/foreman/ui/test_errata.py | 70 ++++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 2 deletions(-) diff --git a/tests/foreman/ui/test_errata.py b/tests/foreman/ui/test_errata.py index becd3e6dcf..612f92786a 100644 --- a/tests/foreman/ui/test_errata.py +++ b/tests/foreman/ui/test_errata.py @@ -1088,7 +1088,7 @@ def test_positive_content_host_previous_env( assert content_host_erratum[0]['Id'] == CUSTOM_REPO_ERRATA_ID -@pytest.mark.tier3 +@pytest.mark.tier2 @pytest.mark.rhel_ver_match('8') @pytest.mark.parametrize( 'registered_contenthost', @@ -1098,7 +1098,7 @@ def test_positive_content_host_previous_env( def test_positive_check_errata(session, module_org_with_parameter, registered_contenthost): """Check if the applicable errata is available from the host page - :id: a0694930-4bf7-4a97-b275-2be7d5f1b311 + :id: 81f3c5bf-5317-40d6-ab3a-2b1a2c5fcbdd :steps: 1. Go to All hosts @@ -1120,6 +1120,72 @@ def test_positive_check_errata(session, module_org_with_parameter, registered_co assert read_errata['Content']['Errata']['table'][0]['Errata'] == CUSTOM_REPO_ERRATA_ID +@pytest.mark.tier3 +@pytest.mark.rhel_ver_match('[8, 9]') +def test_positive_host_content_library( + registered_contenthost, + function_lce, + module_lce, + session, +): + """Check if the applicable errata are available from the content host's Library. + View errata table from within All Hosts, and legacy Contenthosts pages. + + :id: a0694930-4bf7-4a97-b275-2be7d5f1b311 + + :Setup: + 1. Multiple environments are present, we will use 'Library'. + 2. A registered host's Library environment has some additional errata. + + :steps: + 1. Install the outdated package to registered host, making an errata applicable. + 2. Go to new All Hosts -> Select the host -> Content -> Errata Tab. + 3. Go to Legacy Content Hosts -> Select the host -> Errata Tab -> 'Library' env. + 4. Search for the errata by id. Then, check the entire table without filtering. + + :expectedresults: The expected errata id present in Library is displayed. + Only a single errata is present, the tables match between the two pages. + + :parametrized: yes + """ + client = registered_contenthost + hostname = client.hostname + + assert client.applicable_errata_count == 0 + assert client.execute(f'yum install -y {FAKE_1_CUSTOM_PACKAGE}').status == 0 + assert client.applicable_errata_count == 1 + assert client.applicable_package_count == 1 + + with session: + session.location.select(loc_name=DEFAULT_LOC) + # check new host > host > content > errata tab: + host_tab_search = session.host_new.get_errata_table( + entity_name=hostname, + search=f'errata_id="{CUSTOM_REPO_ERRATA_ID}"', + ) + # found desired errata_id by search + assert len(host_tab_search) == 1 + assert host_tab_search[0]['Errata'] == CUSTOM_REPO_ERRATA_ID + # no filters passed, checking all errata present + host_tab_erratum = session.host_new.get_errata_table(hostname) + # only the expected errata_id is found + assert len(host_tab_erratum) == 1 + assert host_tab_erratum[0]['Errata'] == CUSTOM_REPO_ERRATA_ID + # check legacy chost > chost > errata tab -- search: + single_chost_search = session.contenthost.search_errata( + hostname, CUSTOM_REPO_ERRATA_ID, environment='Library Synced Content' + ) + # found desired errata_id by search + assert len(single_chost_search) == 1 + assert single_chost_search[0]['Id'] == CUSTOM_REPO_ERRATA_ID + # display all entries in chost table, only the expected one is present + all_chost_erratum = session.contenthost.search_errata( + hostname, errata_id=' ', environment='Library Synced Content' + ) + assert len(all_chost_erratum) == 1 + assert all_chost_erratum[0]['Id'] == CUSTOM_REPO_ERRATA_ID + + @pytest.mark.tier3 @pytest.mark.rhel_ver_match('8') @pytest.mark.parametrize( From b37a3c7c13bc88cb96cedbc5628883aaf4806209 Mon Sep 17 00:00:00 2001 From: Shubham Ganar <67952129+shubhamsg199@users.noreply.github.com> Date: Thu, 2 May 2024 14:08:20 +0530 Subject: [PATCH 16/20] Add test coverage for BZ#2250397 (#14465) Add closed loop BZ#2250397 Signed-off-by: Shubham Ganar --- tests/foreman/cli/test_registration.py | 55 +++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/tests/foreman/cli/test_registration.py b/tests/foreman/cli/test_registration.py index 34f3fb7f7b..0d2c648831 100644 --- a/tests/foreman/cli/test_registration.py +++ b/tests/foreman/cli/test_registration.py @@ -11,9 +11,11 @@ :Team: Rocket """ +import json import re +from tempfile import mkstemp -from fauxfactory import gen_string +from fauxfactory import gen_mac, gen_string import pytest from robottelo.config import settings @@ -224,3 +226,54 @@ def test_negative_global_registration_without_ak(module_target_sat): 'Failed to generate registration command:\n Missing activation key!' in context.value.message ) + + +@pytest.mark.rhel_ver_match('8') +def test_positive_custom_facts_for_host_registration( + module_sca_manifest_org, + module_location, + module_target_sat, + rhel_contenthost, + module_activation_key, +): + """Attempt to register a host and check all the interfaces are created from the custom facts + + :id: db73c146-4557-4bf4-a8e2-950ecba31620 + + :steps: + 1. Register the host. + 2. Check the host is registered and all the interfaces are created successfully. + + :expectedresults: Host registered successfully with all interfaces created from the custom facts. + + :BZ: 2250397 + + :customerscenario: true + """ + interfaces = [ + {'name': gen_string('alphanumeric')}, + {'name': 'enp98s0f0', 'mac': gen_mac(multicast=False)}, + {'name': 'Datos', 'vlan_id': gen_string('numeric', 4)}, + {'name': 'bondBk', 'vlan_id': gen_string('numeric', 4)}, + ] + facts = { + f'net.interface.{interfaces[0]["name"]}.mac_address': gen_mac(), + f'net.interface.{interfaces[1]["name"]}.mac_address': interfaces[1]["mac"], + f'net.interface.{interfaces[2]["name"]}.{interfaces[2]["vlan_id"]}.mac_address': gen_mac(), + f'net.interface.{interfaces[3]["name"]}.{interfaces[3]["vlan_id"]}.mac_address': gen_mac(), + } + _, facts_file = mkstemp(suffix='.facts') + with open(facts_file, 'w') as f: + json.dump(facts, f, indent=4) + rhel_contenthost.put(facts_file, '/etc/rhsm/facts/') + result = rhel_contenthost.register( + module_sca_manifest_org, module_location, [module_activation_key.name], module_target_sat + ) + assert result.status == 0, f'Failed to register host: {result.stderr}' + host_info = module_target_sat.cli.Host.info( + {'name': rhel_contenthost.hostname}, output_format='json' + ) + assert len(host_info['network-interfaces']) == len(interfaces) + 1 # facts + default interface + for interface in interfaces: + for interface_name in interface.values(): + assert interface_name in str(host_info['network-interfaces']) From ba2c8ce684f62ebe92669d82392dcb1d1ce8e8f3 Mon Sep 17 00:00:00 2001 From: Shweta Singh Date: Thu, 2 May 2024 15:10:14 +0530 Subject: [PATCH 17/20] Test leapp upgrade with non-admin user BZ#2257302 (#14086) --- robottelo/hosts.py | 5 +- tests/foreman/cli/test_leapp_client.py | 110 +++++++++++++++++++++++-- 2 files changed, 107 insertions(+), 8 deletions(-) diff --git a/robottelo/hosts.py b/robottelo/hosts.py index 445cafc82b..fb5a51099a 100644 --- a/robottelo/hosts.py +++ b/robottelo/hosts.py @@ -438,7 +438,10 @@ def power_control(self, state=VmState.RUNNING, ensure=True): if ensure and state in [VmState.RUNNING, 'reboot']: try: wait_for( - self.connect, fail_condition=lambda res: res is not None, handle_exception=True + self.connect, + fail_condition=lambda res: res is not None, + timeout=300, + handle_exception=True, ) # really broad diaper here, but connection exceptions could be a ton of types except TimedOutError as toe: diff --git a/tests/foreman/cli/test_leapp_client.py b/tests/foreman/cli/test_leapp_client.py index 4ea36bbf37..83c577de58 100644 --- a/tests/foreman/cli/test_leapp_client.py +++ b/tests/foreman/cli/test_leapp_client.py @@ -12,6 +12,7 @@ """ from broker import Broker +from fauxfactory import gen_string import pytest from robottelo.config import settings @@ -190,7 +191,7 @@ def custom_leapp_host(upgrade_path, module_target_sat, module_sca_manifest_org, @pytest.fixture def precondition_check_upgrade_and_install_leapp_tool(custom_leapp_host): """Clean-up directory if in-place upgrade already performed, - set rhel release version, update system and install leapp-upgrade""" + set rhel release version, update system and install leapp-upgrade and fix known inhibitors before upgrade""" source_rhel = custom_leapp_host.os_version.base_version custom_leapp_host.run('rm -rf /root/tmp_leapp_py3') custom_leapp_host.run('yum repolist') @@ -200,7 +201,24 @@ def precondition_check_upgrade_and_install_leapp_tool(custom_leapp_host): if custom_leapp_host.run('needs-restarting -r').status == 1: custom_leapp_host.power_control(state='reboot', ensure=True) + # Fixing known inhibitors for source rhel version 8 + if custom_leapp_host.os_version.major == 8: + # Inhibitor - Firewalld Configuration AllowZoneDrifting Is Unsupported + assert ( + custom_leapp_host.run( + 'sed -i "s/^AllowZoneDrifting=.*/AllowZoneDrifting=no/" /etc/firewalld/firewalld.conf' + ).status + == 0 + ) + assert ( + custom_leapp_host.run( + 'echo -e "\nPermitRootLogin yes" >> /etc/ssh/sshd_config; systemctl restart sshd' + ).status + == 0 + ) + +@pytest.mark.skip_if_open('SAT-24023') @pytest.mark.parametrize( 'upgrade_path', [ @@ -233,12 +251,6 @@ def test_leapp_upgrade_rhel( :expectedresults: 1. Update RHEL OS major version to another major version """ - # Fixing known inhibitors for source rhel version 8 - if custom_leapp_host.os_version.major == 8: - # Inhibitor - Firewalld Configuration AllowZoneDrifting Is Unsupported - custom_leapp_host.run( - 'sed -i "s/^AllowZoneDrifting=.*/AllowZoneDrifting=no/" /etc/firewalld/firewalld.conf' - ) # Run LEAPP-PREUPGRADE Job Template- template_id = ( module_target_sat.api.JobTemplate() @@ -285,3 +297,87 @@ def test_leapp_upgrade_rhel( custom_leapp_host.clean_cached_properties() new_ver = str(custom_leapp_host.os_version) assert new_ver == upgrade_path['target_version'] + + +@pytest.mark.skip_if_open('SAT-24023') +@pytest.mark.parametrize( + 'upgrade_path', + [ + {'source_version': RHEL8_VER, 'target_version': RHEL9_VER}, + ], + ids=lambda upgrade_path: f'{upgrade_path["source_version"]}' + f'_to_{upgrade_path["target_version"]}', +) +def test_leapp_upgrade_rhel_non_admin( + module_target_sat, + module_sca_manifest_org, + default_location, + custom_leapp_host, + upgrade_path, + verify_target_repo_on_satellite, + precondition_check_upgrade_and_install_leapp_tool, +): + """Test to upgrade RHEL host to next major RHEL release using leapp preupgrade and leapp upgrade + job templates + + :id: afd295ca-4b0e-439f-b880-ae92c300fd9f + + :BZ: 2257302 + + :customerscenario: true + + :steps: + 1. Import a subscription manifest and enable, sync source & target repositories + 2. Create LCE, Create CV, add repositories to it, publish and promote CV, Create AK, etc. + 3. Register content host with AK + 4. Verify that target rhel repositories are enabled on Satellite + 5. Update all packages, install leapp tool and fix inhibitors + 6. Create a non-admin user with "Organization admin", "Remote Execution Manager" and "Remote Execution User" role assigned to it. + 7. Run Leapp Preupgrade and Leapp Upgrade job template from the user created in step 6. + + :expectedresults: + 1. Update RHEL OS major version to another major version from non-admin user role. + """ + login = gen_string('alpha') + password = gen_string('alpha') + roles = ['Organization admin', 'Remote Execution Manager', 'Remote Execution User'] + org = module_sca_manifest_org + user = module_target_sat.cli_factory.user( + { + 'admin': False, + 'login': login, + 'password': password, + 'organization-ids': org.id, + 'location-ids': default_location.id, + } + ) + for role in roles: + module_target_sat.cli.User.add_role({'id': user['id'], 'login': login, 'role': role}) + + # Run leapp preupgrade job + invocation_command = module_target_sat.cli_factory.job_invocation_with_credentials( + { + 'job-template': 'Run preupgrade via Leapp', + 'search-query': f'name = {custom_leapp_host.hostname}', + 'organization-id': org.id, + 'location-id': default_location.id, + }, + (login, password), + ) + result = module_target_sat.cli.JobInvocation.info({'id': invocation_command['id']}) + assert result['success'] == '1' + + # Run leapp upgrade job + invocation_command = module_target_sat.cli_factory.job_invocation_with_credentials( + { + 'job-template': 'Run upgrade via Leapp', + 'search-query': f'name = {custom_leapp_host.hostname}', + 'organization-id': org.id, + 'location-id': default_location.id, + 'inputs': 'Reboot=false', + }, + (login, password), + ) + custom_leapp_host.power_control(state='reboot') + result = module_target_sat.cli.JobInvocation.info({'id': invocation_command['id']}) + assert result['success'] == '1' From 3f11c65dfd5ddb880c526e04a97f1430f17ce2d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Gajdu=C5=A1ek?= Date: Thu, 2 May 2024 17:09:49 +0200 Subject: [PATCH 18/20] Lint: Black -> Ruff formatter (#14896) * Lint: Black -> Ruff formatter * Address review comments --- .pre-commit-config.yaml | 7 +-- conftest.py | 1 + docs/conf.py | 1 + pyproject.toml | 24 +++------- pytest_fixtures/component/virtwho_config.py | 6 +-- pytest_fixtures/core/contenthosts.py | 1 + pytest_fixtures/core/xdist.py | 5 +- pytest_plugins/capsule_n-minus.py | 1 - pytest_plugins/requirements/req_updater.py | 1 - .../requirements/update_requirements.py | 1 + pytest_plugins/sanity_plugin.py | 2 +- robottelo/cli/acs.py | 1 + robottelo/cli/activationkey.py | 1 + robottelo/cli/admin.py | 1 + robottelo/cli/ansible.py | 1 + robottelo/cli/architecture.py | 1 + robottelo/cli/arfreport.py | 1 + robottelo/cli/auth.py | 1 + robottelo/cli/base.py | 1 + robottelo/cli/bootdisk.py | 1 + robottelo/cli/capsule.py | 1 + robottelo/cli/computeprofile.py | 1 + robottelo/cli/computeresource.py | 1 + robottelo/cli/content_credentials.py | 1 + robottelo/cli/content_export.py | 1 + robottelo/cli/content_import.py | 1 + robottelo/cli/contentview.py | 1 + robottelo/cli/defaults.py | 1 + robottelo/cli/discoveredhost.py | 1 + robottelo/cli/discoveryrule.py | 1 + robottelo/cli/docker.py | 1 + robottelo/cli/domain.py | 1 + robottelo/cli/environment.py | 1 + robottelo/cli/erratum.py | 1 + robottelo/cli/fact.py | 1 + robottelo/cli/file.py | 1 + robottelo/cli/filter.py | 1 + robottelo/cli/globalparam.py | 1 + robottelo/cli/gpgkey.py | 1 + robottelo/cli/hammer.py | 1 + robottelo/cli/host.py | 1 + robottelo/cli/host_registration.py | 1 + robottelo/cli/hostcollection.py | 1 + robottelo/cli/hostgroup.py | 1 + robottelo/cli/http_proxy.py | 1 + robottelo/cli/job_invocation.py | 1 + robottelo/cli/job_template.py | 1 + robottelo/cli/ldapauthsource.py | 1 + robottelo/cli/lifecycleenvironment.py | 1 + robottelo/cli/location.py | 1 + robottelo/cli/medium.py | 1 + robottelo/cli/model.py | 1 + robottelo/cli/module_stream.py | 1 + robottelo/cli/operatingsys.py | 1 + robottelo/cli/org.py | 1 + robottelo/cli/ostreebranch.py | 1 + robottelo/cli/package.py | 1 + robottelo/cli/partitiontable.py | 1 + robottelo/cli/product.py | 1 + robottelo/cli/proxy.py | 1 + robottelo/cli/puppet.py | 1 + robottelo/cli/realm.py | 1 + robottelo/cli/recurring_logic.py | 1 + robottelo/cli/report.py | 1 + robottelo/cli/report_template.py | 1 + robottelo/cli/repository.py | 1 + robottelo/cli/repository_set.py | 1 + robottelo/cli/rex_feature.py | 1 + robottelo/cli/role.py | 1 + robottelo/cli/scap_policy.py | 1 + robottelo/cli/scap_tailoring_files.py | 1 + robottelo/cli/scapcontent.py | 1 + robottelo/cli/scparams.py | 1 + robottelo/cli/settings.py | 1 + robottelo/cli/simple_content_access.py | 1 + robottelo/cli/sm_advanced.py | 1 + robottelo/cli/sm_advanced_by_tag.py | 1 + robottelo/cli/sm_backup.py | 1 + robottelo/cli/sm_health.py | 1 + robottelo/cli/sm_maintenance_mode.py | 1 + robottelo/cli/sm_packages.py | 1 + robottelo/cli/sm_restore.py | 1 + robottelo/cli/sm_service.py | 1 + robottelo/cli/sm_upgrade.py | 1 + robottelo/cli/srpm.py | 1 + robottelo/cli/subnet.py | 1 + robottelo/cli/subscription.py | 1 + robottelo/cli/syncplan.py | 1 + robottelo/cli/task.py | 1 + robottelo/cli/template.py | 1 + robottelo/cli/template_input.py | 1 + robottelo/cli/template_sync.py | 1 + robottelo/cli/user.py | 1 + robottelo/cli/usergroup.py | 1 + robottelo/cli/virt_who_config.py | 1 + robottelo/cli/webhook.py | 2 +- robottelo/constants/__init__.py | 2 + robottelo/content_info.py | 1 + robottelo/host_helpers/api_factory.py | 1 + robottelo/host_helpers/cli_factory.py | 1 + robottelo/host_helpers/contenthost_mixins.py | 1 + robottelo/host_helpers/repository_mixins.py | 2 +- robottelo/host_helpers/satellite_mixins.py | 2 +- robottelo/host_helpers/ui_factory.py | 1 + robottelo/hosts.py | 7 +-- robottelo/ssh.py | 1 + robottelo/utils/datafactory.py | 1 + robottelo/utils/decorators/__init__.py | 1 + robottelo/utils/decorators/func_locker.py | 2 +- .../decorators/func_shared/file_storage.py | 1 - .../decorators/func_shared/redis_storage.py | 1 - .../utils/decorators/func_shared/shared.py | 9 +--- robottelo/utils/manifest.py | 6 +-- robottelo/utils/ohsnap.py | 1 + robottelo/utils/shared_resource.py | 1 + robottelo/utils/ssh.py | 1 + robottelo/utils/vault.py | 1 + robottelo/utils/virtwho.py | 1 + scripts/config_helpers.py | 1 + scripts/graph_entities.py | 1 + scripts/hammer_command_tree.py | 1 + scripts/token_editor.py | 3 +- scripts/tokenize_customer_scenario.py | 1 + scripts/validate_config.py | 1 + tests/foreman/api/test_acs.py | 1 + tests/foreman/api/test_activationkey.py | 1 + tests/foreman/api/test_ansible.py | 1 + tests/foreman/api/test_architecture.py | 1 + tests/foreman/api/test_audit.py | 1 + tests/foreman/api/test_bookmarks.py | 1 + tests/foreman/api/test_capsule.py | 1 + tests/foreman/api/test_classparameters.py | 1 + tests/foreman/api/test_computeprofile.py | 1 + .../api/test_computeresource_azurerm.py | 1 + tests/foreman/api/test_computeresource_gce.py | 1 + .../api/test_computeresource_libvirt.py | 1 + tests/foreman/api/test_contentcredentials.py | 1 + tests/foreman/api/test_contentview.py | 1 + tests/foreman/api/test_contentviewfilter.py | 1 + tests/foreman/api/test_contentviewversion.py | 1 + tests/foreman/api/test_convert2rhel.py | 1 + tests/foreman/api/test_discoveredhost.py | 1 + tests/foreman/api/test_discoveryrule.py | 1 + tests/foreman/api/test_docker.py | 1 + tests/foreman/api/test_environment.py | 1 + tests/foreman/api/test_errata.py | 47 ++++++++++--------- tests/foreman/api/test_filter.py | 1 + tests/foreman/api/test_foremantask.py | 1 + tests/foreman/api/test_host.py | 1 + tests/foreman/api/test_hostcollection.py | 1 + tests/foreman/api/test_hostgroup.py | 1 + tests/foreman/api/test_http_proxy.py | 1 + tests/foreman/api/test_ldapauthsource.py | 1 + .../foreman/api/test_lifecycleenvironment.py | 1 + tests/foreman/api/test_location.py | 1 + tests/foreman/api/test_media.py | 3 +- tests/foreman/api/test_multiple_paths.py | 1 + tests/foreman/api/test_notifications.py | 5 +- tests/foreman/api/test_operatingsystem.py | 1 + tests/foreman/api/test_organization.py | 1 + .../foreman/api/test_oscap_tailoringfiles.py | 1 + tests/foreman/api/test_oscappolicy.py | 1 + tests/foreman/api/test_parameters.py | 1 + tests/foreman/api/test_partitiontable.py | 1 + tests/foreman/api/test_permission.py | 1 + tests/foreman/api/test_ping.py | 1 + tests/foreman/api/test_product.py | 1 + tests/foreman/api/test_provisioning.py | 1 + tests/foreman/api/test_provisioning_puppet.py | 1 + .../foreman/api/test_provisioningtemplate.py | 1 + tests/foreman/api/test_registration.py | 1 + tests/foreman/api/test_remoteexecution.py | 1 + tests/foreman/api/test_reporttemplates.py | 1 + tests/foreman/api/test_repositories.py | 1 + tests/foreman/api/test_repository.py | 3 +- tests/foreman/api/test_repository_set.py | 1 + tests/foreman/api/test_rhc.py | 1 + tests/foreman/api/test_rhcloud_inventory.py | 1 + tests/foreman/api/test_rhsm.py | 1 + tests/foreman/api/test_role.py | 3 +- tests/foreman/api/test_settings.py | 1 + tests/foreman/api/test_subnet.py | 1 + tests/foreman/api/test_subscription.py | 1 + tests/foreman/api/test_syncplan.py | 1 + .../foreman/api/test_template_combination.py | 1 + tests/foreman/api/test_templatesync.py | 1 + tests/foreman/api/test_user.py | 3 +- tests/foreman/api/test_usergroup.py | 1 + tests/foreman/api/test_webhook.py | 1 + tests/foreman/cli/test_abrt.py | 1 + tests/foreman/cli/test_acs.py | 1 + tests/foreman/cli/test_activationkey.py | 1 + tests/foreman/cli/test_ansible.py | 1 + tests/foreman/cli/test_architecture.py | 1 + tests/foreman/cli/test_auth.py | 5 +- tests/foreman/cli/test_bootdisk.py | 1 + tests/foreman/cli/test_bootstrap_script.py | 1 + tests/foreman/cli/test_capsule.py | 1 + tests/foreman/cli/test_capsulecontent.py | 1 + tests/foreman/cli/test_classparameters.py | 1 + .../cli/test_computeresource_azurerm.py | 11 +++-- tests/foreman/cli/test_computeresource_ec2.py | 1 + .../cli/test_computeresource_libvirt.py | 1 + tests/foreman/cli/test_computeresource_osp.py | 1 + .../foreman/cli/test_computeresource_rhev.py | 1 + .../cli/test_computeresource_vmware.py | 1 + .../foreman/cli/test_container_management.py | 1 + tests/foreman/cli/test_contentaccess.py | 1 + tests/foreman/cli/test_contentcredentials.py | 1 + tests/foreman/cli/test_contentview.py | 1 + tests/foreman/cli/test_contentviewfilter.py | 1 + tests/foreman/cli/test_discoveredhost.py | 1 + tests/foreman/cli/test_discoveryrule.py | 1 + tests/foreman/cli/test_docker.py | 1 + tests/foreman/cli/test_domain.py | 1 + tests/foreman/cli/test_environment.py | 1 + tests/foreman/cli/test_errata.py | 1 + tests/foreman/cli/test_fact.py | 1 + tests/foreman/cli/test_filter.py | 1 + tests/foreman/cli/test_foremantask.py | 1 + tests/foreman/cli/test_globalparam.py | 1 + tests/foreman/cli/test_hammer.py | 1 + tests/foreman/cli/test_host.py | 1 + tests/foreman/cli/test_hostcollection.py | 1 + tests/foreman/cli/test_hostgroup.py | 1 + tests/foreman/cli/test_http_proxy.py | 1 + tests/foreman/cli/test_installer.py | 1 + tests/foreman/cli/test_jobtemplate.py | 1 + tests/foreman/cli/test_ldapauthsource.py | 3 +- tests/foreman/cli/test_leapp_client.py | 1 + .../foreman/cli/test_lifecycleenvironment.py | 1 + tests/foreman/cli/test_location.py | 1 + tests/foreman/cli/test_logging.py | 3 +- tests/foreman/cli/test_medium.py | 1 + tests/foreman/cli/test_model.py | 3 +- tests/foreman/cli/test_operatingsystem.py | 1 + tests/foreman/cli/test_organization.py | 1 + tests/foreman/cli/test_oscap.py | 1 + .../foreman/cli/test_oscap_tailoringfiles.py | 2 +- tests/foreman/cli/test_ostreebranch.py | 1 + tests/foreman/cli/test_partitiontable.py | 1 + tests/foreman/cli/test_ping.py | 1 + tests/foreman/cli/test_product.py | 1 + tests/foreman/cli/test_provisioning.py | 1 + .../foreman/cli/test_provisioningtemplate.py | 1 + tests/foreman/cli/test_puppetclass.py | 1 + tests/foreman/cli/test_realm.py | 1 + tests/foreman/cli/test_registration.py | 1 + tests/foreman/cli/test_remoteexecution.py | 1 + tests/foreman/cli/test_report.py | 1 + tests/foreman/cli/test_reporttemplates.py | 1 + tests/foreman/cli/test_repositories.py | 1 + tests/foreman/cli/test_repository.py | 1 + tests/foreman/cli/test_repository_set.py | 1 + tests/foreman/cli/test_rhcloud_inventory.py | 1 + tests/foreman/cli/test_role.py | 1 + tests/foreman/cli/test_satellitesync.py | 1 + tests/foreman/cli/test_settings.py | 1 + tests/foreman/cli/test_sso.py | 1 + tests/foreman/cli/test_subnet.py | 1 + tests/foreman/cli/test_subscription.py | 1 + tests/foreman/cli/test_syncplan.py | 1 + tests/foreman/cli/test_templatesync.py | 1 + tests/foreman/cli/test_user.py | 1 + tests/foreman/cli/test_usergroup.py | 1 + .../cli/test_vm_install_products_package.py | 1 + tests/foreman/cli/test_webhook.py | 1 + tests/foreman/destructive/test_ansible.py | 1 + tests/foreman/destructive/test_auth.py | 1 + tests/foreman/destructive/test_capsule.py | 1 + .../destructive/test_capsule_loadbalancer.py | 1 + .../destructive/test_capsulecontent.py | 1 + tests/foreman/destructive/test_clone.py | 1 + tests/foreman/destructive/test_contenthost.py | 1 + tests/foreman/destructive/test_contentview.py | 1 + .../destructive/test_discoveredhost.py | 1 + .../foreman/destructive/test_foreman_rake.py | 1 + .../destructive/test_foreman_service.py | 1 + tests/foreman/destructive/test_host.py | 1 + tests/foreman/destructive/test_infoblox.py | 1 + tests/foreman/destructive/test_installer.py | 1 + .../destructive/test_katello_certs_check.py | 1 + .../destructive/test_ldap_authentication.py | 10 ++-- .../destructive/test_ldapauthsource.py | 1 + .../destructive/test_leapp_satellite.py | 1 + tests/foreman/destructive/test_packages.py | 1 + tests/foreman/destructive/test_ping.py | 1 + .../foreman/destructive/test_puppetplugin.py | 1 + tests/foreman/destructive/test_realm.py | 1 + .../foreman/destructive/test_registration.py | 1 + .../destructive/test_remoteexecution.py | 1 + tests/foreman/destructive/test_rename.py | 1 + tests/foreman/destructive/test_repository.py | 1 + tests/foreman/endtoend/test_api_endtoend.py | 1 + tests/foreman/endtoend/test_cli_endtoend.py | 1 + tests/foreman/installer/test_infoblox.py | 1 + tests/foreman/installer/test_installer.py | 1 + tests/foreman/longrun/test_inc_updates.py | 1 + tests/foreman/longrun/test_oscap.py | 1 + tests/foreman/longrun/test_remoteexecution.py | 1 + tests/foreman/maintain/test_advanced.py | 1 + tests/foreman/maintain/test_backup_restore.py | 17 +++---- tests/foreman/maintain/test_health.py | 1 + .../foreman/maintain/test_maintenance_mode.py | 1 + tests/foreman/maintain/test_offload_DB.py | 1 + tests/foreman/maintain/test_packages.py | 1 + tests/foreman/maintain/test_service.py | 1 + tests/foreman/maintain/test_upgrade.py | 1 + tests/foreman/sanity/test_bvt.py | 1 + tests/foreman/sys/test_dynflow.py | 1 + tests/foreman/sys/test_fam.py | 1 + tests/foreman/sys/test_katello_certs_check.py | 1 + tests/foreman/sys/test_pulp3_filesystem.py | 1 + tests/foreman/sys/test_webpack.py | 1 + tests/foreman/ui/test_acs.py | 1 + tests/foreman/ui/test_activationkey.py | 1 + tests/foreman/ui/test_ansible.py | 3 +- tests/foreman/ui/test_architecture.py | 1 + tests/foreman/ui/test_audit.py | 1 + tests/foreman/ui/test_bookmarks.py | 1 + tests/foreman/ui/test_branding.py | 1 + tests/foreman/ui/test_capsulecontent.py | 1 + tests/foreman/ui/test_computeprofiles.py | 1 + tests/foreman/ui/test_computeresource.py | 2 +- .../ui/test_computeresource_azurerm.py | 1 + tests/foreman/ui/test_computeresource_ec2.py | 1 + tests/foreman/ui/test_computeresource_gce.py | 1 + .../ui/test_computeresource_libvirt.py | 1 + .../foreman/ui/test_computeresource_vmware.py | 1 + tests/foreman/ui/test_config_group.py | 1 + tests/foreman/ui/test_containerimagetag.py | 1 + tests/foreman/ui/test_contentcredentials.py | 1 + tests/foreman/ui/test_contenthost.py | 7 +-- tests/foreman/ui/test_contentview.py | 1 + tests/foreman/ui/test_contentview_old.py | 1 + tests/foreman/ui/test_dashboard.py | 11 +++-- tests/foreman/ui/test_discoveredhost.py | 1 + tests/foreman/ui/test_discoveryrule.py | 1 + tests/foreman/ui/test_domain.py | 1 + tests/foreman/ui/test_eol_banner.py | 1 + tests/foreman/ui/test_errata.py | 32 ++++++++----- tests/foreman/ui/test_hardwaremodel.py | 1 + tests/foreman/ui/test_host.py | 1 + tests/foreman/ui/test_hostcollection.py | 1 + tests/foreman/ui/test_hostgroup.py | 1 + tests/foreman/ui/test_http_proxy.py | 1 + tests/foreman/ui/test_jobtemplate.py | 1 + tests/foreman/ui/test_ldap_authentication.py | 41 ++++++++++------ tests/foreman/ui/test_lifecycleenvironment.py | 1 + tests/foreman/ui/test_location.py | 1 + tests/foreman/ui/test_media.py | 1 + tests/foreman/ui/test_modulestreams.py | 1 + tests/foreman/ui/test_operatingsystem.py | 1 + tests/foreman/ui/test_organization.py | 1 + tests/foreman/ui/test_oscappolicy.py | 1 + tests/foreman/ui/test_oscaptailoringfile.py | 1 + tests/foreman/ui/test_package.py | 1 + tests/foreman/ui/test_partitiontable.py | 1 + tests/foreman/ui/test_product.py | 1 + tests/foreman/ui/test_provisioningtemplate.py | 1 + tests/foreman/ui/test_puppetclass.py | 1 + tests/foreman/ui/test_puppetenvironment.py | 1 + tests/foreman/ui/test_registration.py | 2 +- tests/foreman/ui/test_remoteexecution.py | 1 + tests/foreman/ui/test_reporttemplates.py | 1 + tests/foreman/ui/test_repositories.py | 1 + tests/foreman/ui/test_repository.py | 1 + tests/foreman/ui/test_rhc.py | 1 + tests/foreman/ui/test_rhcloud_insights.py | 1 + tests/foreman/ui/test_rhcloud_inventory.py | 1 + tests/foreman/ui/test_role.py | 1 + tests/foreman/ui/test_search.py | 1 + tests/foreman/ui/test_settings.py | 1 + tests/foreman/ui/test_smartclassparameter.py | 1 + tests/foreman/ui/test_subnet.py | 1 + tests/foreman/ui/test_subscription.py | 1 + tests/foreman/ui/test_sync.py | 1 + tests/foreman/ui/test_syncplan.py | 1 + tests/foreman/ui/test_templatesync.py | 1 + tests/foreman/ui/test_user.py | 1 + tests/foreman/ui/test_usergroup.py | 1 + tests/foreman/ui/test_webhook.py | 1 + tests/foreman/virtwho/api/test_esx.py | 5 +- tests/foreman/virtwho/api/test_esx_sca.py | 5 +- tests/foreman/virtwho/api/test_hyperv.py | 1 + tests/foreman/virtwho/api/test_hyperv_sca.py | 1 + tests/foreman/virtwho/api/test_kubevirt.py | 1 + .../foreman/virtwho/api/test_kubevirt_sca.py | 1 + tests/foreman/virtwho/api/test_libvirt.py | 1 + tests/foreman/virtwho/api/test_libvirt_sca.py | 1 + tests/foreman/virtwho/api/test_nutanix.py | 1 + tests/foreman/virtwho/api/test_nutanix_sca.py | 1 + tests/foreman/virtwho/cli/test_esx.py | 5 +- tests/foreman/virtwho/cli/test_esx_sca.py | 5 +- tests/foreman/virtwho/cli/test_hyperv.py | 1 + tests/foreman/virtwho/cli/test_hyperv_sca.py | 1 + tests/foreman/virtwho/cli/test_kubevirt.py | 1 + .../foreman/virtwho/cli/test_kubevirt_sca.py | 1 + tests/foreman/virtwho/cli/test_libvirt.py | 1 + tests/foreman/virtwho/cli/test_libvirt_sca.py | 1 + tests/foreman/virtwho/cli/test_nutanix.py | 1 + tests/foreman/virtwho/cli/test_nutanix_sca.py | 1 + tests/foreman/virtwho/ui/test_esx.py | 5 +- tests/foreman/virtwho/ui/test_esx_sca.py | 5 +- tests/foreman/virtwho/ui/test_hyperv.py | 1 + tests/foreman/virtwho/ui/test_hyperv_sca.py | 1 + tests/foreman/virtwho/ui/test_kubevirt.py | 1 + tests/foreman/virtwho/ui/test_kubevirt_sca.py | 1 + tests/foreman/virtwho/ui/test_libvirt.py | 1 + tests/foreman/virtwho/ui/test_libvirt_sca.py | 1 + tests/foreman/virtwho/ui/test_nutanix.py | 1 + tests/foreman/virtwho/ui/test_nutanix_sca.py | 1 + tests/robottelo/test_datafactory.py | 1 + tests/robottelo/test_decorators.py | 1 + tests/robottelo/test_dependencies.py | 1 + tests/robottelo/test_func_locker.py | 40 +++++++++------- tests/robottelo/test_hammer.py | 1 + tests/robottelo/test_helpers.py | 1 + tests/robottelo/test_issue_handlers.py | 7 ++- tests/robottelo/test_ssh.py | 1 + tests/upgrades/conftest.py | 1 + tests/upgrades/test_activation_key.py | 1 + tests/upgrades/test_bookmarks.py | 1 + tests/upgrades/test_capsule.py | 1 + tests/upgrades/test_classparameter.py | 1 + tests/upgrades/test_client.py | 1 + tests/upgrades/test_contentview.py | 1 + tests/upgrades/test_discovery.py | 1 + tests/upgrades/test_errata.py | 1 + tests/upgrades/test_host.py | 1 + tests/upgrades/test_hostcontent.py | 1 + tests/upgrades/test_hostgroup.py | 1 + tests/upgrades/test_performance_tuning.py | 1 + tests/upgrades/test_provisioningtemplate.py | 1 + tests/upgrades/test_puppet.py | 1 + tests/upgrades/test_remoteexecution.py | 1 + tests/upgrades/test_repository.py | 1 + tests/upgrades/test_role.py | 1 + tests/upgrades/test_satellite_maintain.py | 1 + tests/upgrades/test_satellitesync.py | 1 + tests/upgrades/test_subnet.py | 1 + tests/upgrades/test_subscription.py | 1 + tests/upgrades/test_syncplan.py | 1 + tests/upgrades/test_user.py | 1 + tests/upgrades/test_usergroup.py | 1 + tests/upgrades/test_virtwho.py | 3 +- 446 files changed, 597 insertions(+), 180 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c93c0b5020..dd6543a0af 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,15 +11,12 @@ repos: exclude: tests/foreman/data/ - id: check-yaml - id: debug-statements - - repo: https://github.com/psf/black - rev: 22.10.0 - hooks: - - id: black - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.3.0 + rev: v0.4.1 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] + - id: ruff-format - repo: local hooks: - id: fix-uuids diff --git a/conftest.py b/conftest.py index 7645728a06..f50f81e297 100644 --- a/conftest.py +++ b/conftest.py @@ -1,4 +1,5 @@ """Global Configurations for py.test runner""" + import pytest pytest_plugins = [ diff --git a/docs/conf.py b/docs/conf.py index b143f7ac6f..02ef4d4298 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -4,6 +4,7 @@ http://sphinx-doc.org/config.html """ + import builtins import os import sys diff --git a/pyproject.toml b/pyproject.toml index 71e77065d0..ff201b018e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,22 +1,12 @@ -[tool.black] -line-length = 100 -skip-string-normalization = true -include = '\.pyi?$' -exclude = ''' -/( - \.git - | \.hg - | \.mypy_cache - | \.venv - | _build - | buck-out - | build - | dist -)/ -''' - [tool.ruff] target-version = "py311" +# Allow lines to be as long as 100. +line-length = 100 +exclude = [".git", ".hg", ".mypy_cache", ".venv", "_build", "buck-out", "build", "dist"] + +[tool.ruff.format] +# Preserve quotes +quote-style = "preserve" # TODO: change to "single" when flake8-quotes is enabled [tool.ruff.lint] fixable = ["ALL"] diff --git a/pytest_fixtures/component/virtwho_config.py b/pytest_fixtures/component/virtwho_config.py index b897023213..d46b115349 100644 --- a/pytest_fixtures/component/virtwho_config.py +++ b/pytest_fixtures/component/virtwho_config.py @@ -24,11 +24,7 @@ def org_module(request, default_org, module_sca_manifest_org): @pytest.fixture def org_session(request, session, session_sca): - if 'sca' in request.module.__name__.split('.')[-1]: - org_session = session_sca - else: - org_session = session - return org_session + return session_sca if 'sca' in request.module.__name__.split('.')[-1] else session @pytest.fixture diff --git a/pytest_fixtures/core/contenthosts.py b/pytest_fixtures/core/contenthosts.py index d2bbb4cce3..89dcbb2dfa 100644 --- a/pytest_fixtures/core/contenthosts.py +++ b/pytest_fixtures/core/contenthosts.py @@ -4,6 +4,7 @@ The functions in this module are read in the pytest_plugins/fixture_markers.py module All functions in this module will be treated as fixtures that apply the contenthost mark """ + from broker import Broker import pytest diff --git a/pytest_fixtures/core/xdist.py b/pytest_fixtures/core/xdist.py index 2495e4fa1c..855cd2b1cf 100644 --- a/pytest_fixtures/core/xdist.py +++ b/pytest_fixtures/core/xdist.py @@ -25,10 +25,7 @@ def align_to_satellite(request, worker_id, satellite_factory): settings.set("server.hostname", None) on_demand_sat = None - if worker_id in ['master', 'local']: - worker_pos = 0 - else: - worker_pos = int(worker_id.replace('gw', '')) + worker_pos = 0 if worker_id in ["master", "local"] else int(worker_id.replace("gw", "")) # attempt to add potential satellites from the broker inventory file if settings.server.inventory_filter: diff --git a/pytest_plugins/capsule_n-minus.py b/pytest_plugins/capsule_n-minus.py index f903e23975..9a7edf76b5 100644 --- a/pytest_plugins/capsule_n-minus.py +++ b/pytest_plugins/capsule_n-minus.py @@ -19,7 +19,6 @@ def pytest_addoption(parser): def pytest_collection_modifyitems(items, config): - if not config.getoption('n_minus', False): return diff --git a/pytest_plugins/requirements/req_updater.py b/pytest_plugins/requirements/req_updater.py index 664a9bb92a..37d1aabc57 100644 --- a/pytest_plugins/requirements/req_updater.py +++ b/pytest_plugins/requirements/req_updater.py @@ -3,7 +3,6 @@ class ReqUpdater: - # Installed package name as key and its counterpart in requirements file as value package_deviates = { 'Betelgeuse': 'betelgeuse', diff --git a/pytest_plugins/requirements/update_requirements.py b/pytest_plugins/requirements/update_requirements.py index e2ad884018..74494427ce 100644 --- a/pytest_plugins/requirements/update_requirements.py +++ b/pytest_plugins/requirements/update_requirements.py @@ -1,4 +1,5 @@ """Plugin enables pytest to notify and update the requirements""" + from .req_updater import ReqUpdater updater = ReqUpdater() diff --git a/pytest_plugins/sanity_plugin.py b/pytest_plugins/sanity_plugin.py index 1d93a4b45f..14d89b87d5 100644 --- a/pytest_plugins/sanity_plugin.py +++ b/pytest_plugins/sanity_plugin.py @@ -1,4 +1,4 @@ -""" A sanity testing plugin to assist in executing robottelo tests as sanity tests smartly +"""A sanity testing plugin to assist in executing robottelo tests as sanity tests smartly 1. Make installer test to run first which should set the hostname and all other tests then should run after that diff --git a/robottelo/cli/acs.py b/robottelo/cli/acs.py index 0368bc8d8d..f610a5e983 100644 --- a/robottelo/cli/acs.py +++ b/robottelo/cli/acs.py @@ -21,6 +21,7 @@ update Update an alternate content source. """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/activationkey.py b/robottelo/cli/activationkey.py index 415a682c44..8a58b2f7bb 100644 --- a/robottelo/cli/activationkey.py +++ b/robottelo/cli/activationkey.py @@ -25,6 +25,7 @@ subscriptions List associated subscriptions update Update an activation key """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/admin.py b/robottelo/cli/admin.py index ccae4bf47d..e6a3229640 100644 --- a/robottelo/cli/admin.py +++ b/robottelo/cli/admin.py @@ -12,6 +12,7 @@ Options: -h, --help Print help """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/ansible.py b/robottelo/cli/ansible.py index c9d42dbcb3..d717f8cd4d 100644 --- a/robottelo/cli/ansible.py +++ b/robottelo/cli/ansible.py @@ -8,6 +8,7 @@ roles Manage ansible roles variables Manage ansible variables """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/architecture.py b/robottelo/cli/architecture.py index 02a9a173cf..6bad9bf55c 100644 --- a/robottelo/cli/architecture.py +++ b/robottelo/cli/architecture.py @@ -18,6 +18,7 @@ remove_operatingsystem Disassociate a resource update Update an architecture. """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/arfreport.py b/robottelo/cli/arfreport.py index 05e04c0d7c..a478a0ecfd 100644 --- a/robottelo/cli/arfreport.py +++ b/robottelo/cli/arfreport.py @@ -16,6 +16,7 @@ list List ARF reports """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/auth.py b/robottelo/cli/auth.py index a6995ce736..c50cf08fb6 100644 --- a/robottelo/cli/auth.py +++ b/robottelo/cli/auth.py @@ -11,6 +11,7 @@ logout Wipe your credentials status Information about current connections """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/base.py b/robottelo/cli/base.py index d276cd741f..04ad7a1488 100644 --- a/robottelo/cli/base.py +++ b/robottelo/cli/base.py @@ -1,4 +1,5 @@ """Generic base class for cli hammer commands.""" + import re from wait_for import wait_for diff --git a/robottelo/cli/bootdisk.py b/robottelo/cli/bootdisk.py index 50df399f7f..f50c817cc5 100644 --- a/robottelo/cli/bootdisk.py +++ b/robottelo/cli/bootdisk.py @@ -14,6 +14,7 @@ host Download host image subnet Download subnet generic image """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/capsule.py b/robottelo/cli/capsule.py index bb6825cc78..c5ba0ec891 100644 --- a/robottelo/cli/capsule.py +++ b/robottelo/cli/capsule.py @@ -19,6 +19,7 @@ refresh-features Refresh capsule features update Update a capsule """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/computeprofile.py b/robottelo/cli/computeprofile.py index b288e9c34c..2856138f03 100644 --- a/robottelo/cli/computeprofile.py +++ b/robottelo/cli/computeprofile.py @@ -18,6 +18,7 @@ -h, --help Print help Update a compute resource. """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/computeresource.py b/robottelo/cli/computeresource.py index 1026d16378..48823ef169 100644 --- a/robottelo/cli/computeresource.py +++ b/robottelo/cli/computeresource.py @@ -17,6 +17,7 @@ list List all compute resources. update Update a compute resource. """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/content_credentials.py b/robottelo/cli/content_credentials.py index b7582dadd4..6844ef0083 100644 --- a/robottelo/cli/content_credentials.py +++ b/robottelo/cli/content_credentials.py @@ -16,6 +16,7 @@ list List content credentials update Update a content credential """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/content_export.py b/robottelo/cli/content_export.py index 8d67ddfc03..c868e8483a 100644 --- a/robottelo/cli/content_export.py +++ b/robottelo/cli/content_export.py @@ -19,6 +19,7 @@ list View content view export histories """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/content_import.py b/robottelo/cli/content_import.py index 18669dd49f..d0910433dc 100644 --- a/robottelo/cli/content_import.py +++ b/robottelo/cli/content_import.py @@ -16,6 +16,7 @@ version Imports a content archive to a content view version """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/contentview.py b/robottelo/cli/contentview.py index 17732f3761..57d69b7dd2 100644 --- a/robottelo/cli/contentview.py +++ b/robottelo/cli/contentview.py @@ -33,6 +33,7 @@ -h, --help print help """ + from robottelo.cli import hammer from robottelo.cli.base import Base, CLIError diff --git a/robottelo/cli/defaults.py b/robottelo/cli/defaults.py index 7d624930f9..0c7524a65c 100644 --- a/robottelo/cli/defaults.py +++ b/robottelo/cli/defaults.py @@ -15,6 +15,7 @@ list List all the default parameters providers List all the providers """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/discoveredhost.py b/robottelo/cli/discoveredhost.py index 6404dfc89e..99c1edffd6 100644 --- a/robottelo/cli/discoveredhost.py +++ b/robottelo/cli/discoveredhost.py @@ -19,6 +19,7 @@ reboot Reboot a host refresh-facts Refresh the facts of a host """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/discoveryrule.py b/robottelo/cli/discoveryrule.py index 54bb5fc872..9685132ef8 100644 --- a/robottelo/cli/discoveryrule.py +++ b/robottelo/cli/discoveryrule.py @@ -16,6 +16,7 @@ list List all discovery rules update Update a rule """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/docker.py b/robottelo/cli/docker.py index 01fe51cb78..f12eb949e9 100644 --- a/robottelo/cli/docker.py +++ b/robottelo/cli/docker.py @@ -1,4 +1,5 @@ """Docker related hammer commands""" + from robottelo.cli.base import Base diff --git a/robottelo/cli/domain.py b/robottelo/cli/domain.py index bb449177fc..601aefc2eb 100644 --- a/robottelo/cli/domain.py +++ b/robottelo/cli/domain.py @@ -18,6 +18,7 @@ set_parameter Create or update parameter for a domain. update Update a domain. """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/environment.py b/robottelo/cli/environment.py index f47e2ba6aa..1c981216e7 100644 --- a/robottelo/cli/environment.py +++ b/robottelo/cli/environment.py @@ -17,6 +17,7 @@ sc-params List all smart class parameters update Update an environment """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/erratum.py b/robottelo/cli/erratum.py index abe3fa5759..762a678398 100644 --- a/robottelo/cli/erratum.py +++ b/robottelo/cli/erratum.py @@ -13,6 +13,7 @@ info Show an erratum list List errata """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/fact.py b/robottelo/cli/fact.py index 67a6d99d52..3521e828b3 100644 --- a/robottelo/cli/fact.py +++ b/robottelo/cli/fact.py @@ -12,6 +12,7 @@ list List all fact values. """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/file.py b/robottelo/cli/file.py index 3adb1fe166..643df551b1 100644 --- a/robottelo/cli/file.py +++ b/robottelo/cli/file.py @@ -13,6 +13,7 @@ info Show a file list List files """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/filter.py b/robottelo/cli/filter.py index 395e44e13d..595e67584a 100644 --- a/robottelo/cli/filter.py +++ b/robottelo/cli/filter.py @@ -17,6 +17,7 @@ list List all filters update Update a filter """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/globalparam.py b/robottelo/cli/globalparam.py index 8bca35dc3c..2dc069a062 100644 --- a/robottelo/cli/globalparam.py +++ b/robottelo/cli/globalparam.py @@ -14,6 +14,7 @@ list List all common parameters. set Set a global parameter. """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/gpgkey.py b/robottelo/cli/gpgkey.py index 4158fa04a7..610640e1c9 100644 --- a/robottelo/cli/gpgkey.py +++ b/robottelo/cli/gpgkey.py @@ -16,6 +16,7 @@ list List GPG Keys update Update a GPG Key """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/hammer.py b/robottelo/cli/hammer.py index 4e35b0c761..171cba6c0e 100644 --- a/robottelo/cli/hammer.py +++ b/robottelo/cli/hammer.py @@ -1,4 +1,5 @@ """Helpers to interact with hammer command line utility.""" + import csv import json import re diff --git a/robottelo/cli/host.py b/robottelo/cli/host.py index dc45c9db88..6f09307170 100644 --- a/robottelo/cli/host.py +++ b/robottelo/cli/host.py @@ -39,6 +39,7 @@ update Update a host """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/host_registration.py b/robottelo/cli/host_registration.py index 8d0adaecec..61abe2a7d5 100644 --- a/robottelo/cli/host_registration.py +++ b/robottelo/cli/host_registration.py @@ -13,6 +13,7 @@ -h, --help Print help """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/hostcollection.py b/robottelo/cli/hostcollection.py index 839ef48d4f..16e13d8911 100644 --- a/robottelo/cli/hostcollection.py +++ b/robottelo/cli/hostcollection.py @@ -23,6 +23,7 @@ remove-host Remove hosts from the host collection update Update a host collection """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/hostgroup.py b/robottelo/cli/hostgroup.py index 5be314b1a4..f13f787890 100644 --- a/robottelo/cli/hostgroup.py +++ b/robottelo/cli/hostgroup.py @@ -22,6 +22,7 @@ set-parameter Create or update parameter for a hostgroup update Update a host group """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/http_proxy.py b/robottelo/cli/http_proxy.py index 08405e8d04..ba6f6b4deb 100644 --- a/robottelo/cli/http_proxy.py +++ b/robottelo/cli/http_proxy.py @@ -16,6 +16,7 @@ Options: -h, --help Print help """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/job_invocation.py b/robottelo/cli/job_invocation.py index fe02dae4d7..8e8e37baca 100644 --- a/robottelo/cli/job_invocation.py +++ b/robottelo/cli/job_invocation.py @@ -15,6 +15,7 @@ rerun Rerun the job """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/job_template.py b/robottelo/cli/job_template.py index 7b072cc061..d33e77b09e 100644 --- a/robottelo/cli/job_template.py +++ b/robottelo/cli/job_template.py @@ -16,6 +16,7 @@ list List job templates update Update a job template """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/ldapauthsource.py b/robottelo/cli/ldapauthsource.py index fabb6a9c0b..1d460528f4 100644 --- a/robottelo/cli/ldapauthsource.py +++ b/robottelo/cli/ldapauthsource.py @@ -15,6 +15,7 @@ list List all LDAP authentication sources update Update an LDAP authentication source """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/lifecycleenvironment.py b/robottelo/cli/lifecycleenvironment.py index c22d226874..b6896d80f5 100644 --- a/robottelo/cli/lifecycleenvironment.py +++ b/robottelo/cli/lifecycleenvironment.py @@ -16,6 +16,7 @@ delete Destroy an environment info Show an environment """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/location.py b/robottelo/cli/location.py index aa3dd23497..82d5789139 100644 --- a/robottelo/cli/location.py +++ b/robottelo/cli/location.py @@ -36,6 +36,7 @@ remove-user Disassociate an user update Update a location """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/medium.py b/robottelo/cli/medium.py index 8372d96a7c..6958254b07 100644 --- a/robottelo/cli/medium.py +++ b/robottelo/cli/medium.py @@ -18,6 +18,7 @@ remove_operatingsystem Disassociate a resource update Update a medium. """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/model.py b/robottelo/cli/model.py index 419f2ff62a..453d5a55d1 100644 --- a/robottelo/cli/model.py +++ b/robottelo/cli/model.py @@ -16,6 +16,7 @@ list List all models. update Update a model. """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/module_stream.py b/robottelo/cli/module_stream.py index 1dcb8d9ee5..bc0a248e44 100644 --- a/robottelo/cli/module_stream.py +++ b/robottelo/cli/module_stream.py @@ -13,6 +13,7 @@ info Show a module-stream list List module-streams """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/operatingsys.py b/robottelo/cli/operatingsys.py index 8bf4411d56..361259d275 100644 --- a/robottelo/cli/operatingsys.py +++ b/robottelo/cli/operatingsys.py @@ -27,6 +27,7 @@ operating system. update Update an OS. """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/org.py b/robottelo/cli/org.py index 38103aff3a..21d2c7c053 100644 --- a/robottelo/cli/org.py +++ b/robottelo/cli/org.py @@ -40,6 +40,7 @@ organization. update Update an organization """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/ostreebranch.py b/robottelo/cli/ostreebranch.py index 5d68869978..f828299133 100644 --- a/robottelo/cli/ostreebranch.py +++ b/robottelo/cli/ostreebranch.py @@ -14,6 +14,7 @@ list List ostree_branches """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/package.py b/robottelo/cli/package.py index 75533348ad..df566b735d 100644 --- a/robottelo/cli/package.py +++ b/robottelo/cli/package.py @@ -13,6 +13,7 @@ info Show a package list List packages """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/partitiontable.py b/robottelo/cli/partitiontable.py index eb0ebd7fc9..dc15e25563 100644 --- a/robottelo/cli/partitiontable.py +++ b/robottelo/cli/partitiontable.py @@ -19,6 +19,7 @@ remove_operatingsystem Disassociate a resource update Update a ptable. """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/product.py b/robottelo/cli/product.py index 7a7f03eeff..90e0a53454 100644 --- a/robottelo/cli/product.py +++ b/robottelo/cli/product.py @@ -20,6 +20,7 @@ update Update a product update-proxy Updates an HTTP Proxy for a product """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/proxy.py b/robottelo/cli/proxy.py index c688794090..a7722b2293 100644 --- a/robottelo/cli/proxy.py +++ b/robottelo/cli/proxy.py @@ -18,6 +18,7 @@ refresh-features Refresh smart proxy features update Update a smart proxy. """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/puppet.py b/robottelo/cli/puppet.py index b340fc75a5..acc502fafc 100644 --- a/robottelo/cli/puppet.py +++ b/robottelo/cli/puppet.py @@ -14,6 +14,7 @@ list List all puppetclasses. sc-params List all smart class parameters """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/realm.py b/robottelo/cli/realm.py index bbbcc11b0a..ce89717fc8 100644 --- a/robottelo/cli/realm.py +++ b/robottelo/cli/realm.py @@ -16,6 +16,7 @@ Options: -h, --help print help """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/recurring_logic.py b/robottelo/cli/recurring_logic.py index 71c494c68d..85c6e7ebba 100644 --- a/robottelo/cli/recurring_logic.py +++ b/robottelo/cli/recurring_logic.py @@ -11,6 +11,7 @@ info Show recurring logic details list List recurring logics """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/report.py b/robottelo/cli/report.py index 50ca0c1a8b..e5dadade51 100644 --- a/robottelo/cli/report.py +++ b/robottelo/cli/report.py @@ -15,6 +15,7 @@ list List reports. """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/report_template.py b/robottelo/cli/report_template.py index 50646e3cd4..5f66c1ee64 100644 --- a/robottelo/cli/report_template.py +++ b/robottelo/cli/report_template.py @@ -21,6 +21,7 @@ schedule Schedule generating of a report update Update a report template """ + from os import chmod from tempfile import mkstemp diff --git a/robottelo/cli/repository.py b/robottelo/cli/repository.py index d5ac3caf7a..a17cc9fbcb 100644 --- a/robottelo/cli/repository.py +++ b/robottelo/cli/repository.py @@ -19,6 +19,7 @@ update Update a repository upload-content Upload content into the repository """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/repository_set.py b/robottelo/cli/repository_set.py index 65dede4e28..7c2afb6481 100644 --- a/robottelo/cli/repository_set.py +++ b/robottelo/cli/repository_set.py @@ -19,6 +19,7 @@ info Show a repository list List of repositories """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/rex_feature.py b/robottelo/cli/rex_feature.py index 354fdc51ff..b583a9e353 100644 --- a/robottelo/cli/rex_feature.py +++ b/robottelo/cli/rex_feature.py @@ -15,6 +15,7 @@ update Update a job template """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/role.py b/robottelo/cli/role.py index d83234fc8a..88eb6a40cd 100644 --- a/robottelo/cli/role.py +++ b/robottelo/cli/role.py @@ -17,6 +17,7 @@ list List all roles. update Update an role. """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/scap_policy.py b/robottelo/cli/scap_policy.py index 7235d2470c..2647900780 100644 --- a/robottelo/cli/scap_policy.py +++ b/robottelo/cli/scap_policy.py @@ -16,6 +16,7 @@ list List Policies update Update a Policy """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/scap_tailoring_files.py b/robottelo/cli/scap_tailoring_files.py index 0e75af17b4..912c25a639 100644 --- a/robottelo/cli/scap_tailoring_files.py +++ b/robottelo/cli/scap_tailoring_files.py @@ -17,6 +17,7 @@ list List Tailoring files update Update a Tailoring file """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/scapcontent.py b/robottelo/cli/scapcontent.py index 160da1d0d1..8e384488d8 100644 --- a/robottelo/cli/scapcontent.py +++ b/robottelo/cli/scapcontent.py @@ -16,6 +16,7 @@ list List SCAP contents update Update an SCAP content """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/scparams.py b/robottelo/cli/scparams.py index fea0431a5e..9e661b8f61 100644 --- a/robottelo/cli/scparams.py +++ b/robottelo/cli/scparams.py @@ -18,6 +18,7 @@ variable update Update a smart class parameter """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/settings.py b/robottelo/cli/settings.py index 49777104d4..13c45776a5 100644 --- a/robottelo/cli/settings.py +++ b/robottelo/cli/settings.py @@ -13,6 +13,7 @@ list List all settings set Update a setting """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/simple_content_access.py b/robottelo/cli/simple_content_access.py index d5e471b824..6f128a84f1 100644 --- a/robottelo/cli/simple_content_access.py +++ b/robottelo/cli/simple_content_access.py @@ -16,6 +16,7 @@ Simple Content Access enabled """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/sm_advanced.py b/robottelo/cli/sm_advanced.py index 4c2b4ffb33..1227a06bbe 100644 --- a/robottelo/cli/sm_advanced.py +++ b/robottelo/cli/sm_advanced.py @@ -81,6 +81,7 @@ Options: -h, --help print help """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/sm_advanced_by_tag.py b/robottelo/cli/sm_advanced_by_tag.py index afcc1018ab..f90758e68f 100644 --- a/robottelo/cli/sm_advanced_by_tag.py +++ b/robottelo/cli/sm_advanced_by_tag.py @@ -17,6 +17,7 @@ Options: -h, --help print help """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/sm_backup.py b/robottelo/cli/sm_backup.py index ef703134cf..0b60ef5274 100644 --- a/robottelo/cli/sm_backup.py +++ b/robottelo/cli/sm_backup.py @@ -13,6 +13,7 @@ Options: -h, --help print help """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/sm_health.py b/robottelo/cli/sm_health.py index f8da5ca309..c023a94389 100644 --- a/robottelo/cli/sm_health.py +++ b/robottelo/cli/sm_health.py @@ -14,6 +14,7 @@ Options: -h, --help print help """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/sm_maintenance_mode.py b/robottelo/cli/sm_maintenance_mode.py index 6cbe43e367..8e9ef09d67 100644 --- a/robottelo/cli/sm_maintenance_mode.py +++ b/robottelo/cli/sm_maintenance_mode.py @@ -12,6 +12,7 @@ Options: -h, --help print help """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/sm_packages.py b/robottelo/cli/sm_packages.py index d467427917..96aa69531b 100644 --- a/robottelo/cli/sm_packages.py +++ b/robottelo/cli/sm_packages.py @@ -18,6 +18,7 @@ Options: -h, --help print help """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/sm_restore.py b/robottelo/cli/sm_restore.py index 0bd68c9fe6..cad914e519 100644 --- a/robottelo/cli/sm_restore.py +++ b/robottelo/cli/sm_restore.py @@ -12,6 +12,7 @@ -i, --incremental Restore an incremental backup -h, --help print help """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/sm_service.py b/robottelo/cli/sm_service.py index c2ec5f32ca..212d33bda1 100644 --- a/robottelo/cli/sm_service.py +++ b/robottelo/cli/sm_service.py @@ -18,6 +18,7 @@ Options: -h, --help print help """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/sm_upgrade.py b/robottelo/cli/sm_upgrade.py index 77712b4159..a30e158218 100644 --- a/robottelo/cli/sm_upgrade.py +++ b/robottelo/cli/sm_upgrade.py @@ -14,6 +14,7 @@ Options: -h, --help print help """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/srpm.py b/robottelo/cli/srpm.py index 62578bbaa6..689a17c64e 100644 --- a/robottelo/cli/srpm.py +++ b/robottelo/cli/srpm.py @@ -10,6 +10,7 @@ info Show a SRPM Details list List srpms """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/subnet.py b/robottelo/cli/subnet.py index e0bf4a0d6b..5fc61ddc56 100644 --- a/robottelo/cli/subnet.py +++ b/robottelo/cli/subnet.py @@ -17,6 +17,7 @@ update Update a subnet """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/subscription.py b/robottelo/cli/subscription.py index 0e22eaeacc..916a906815 100644 --- a/robottelo/cli/subscription.py +++ b/robottelo/cli/subscription.py @@ -18,6 +18,7 @@ upload Upload a subscription manifest """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/syncplan.py b/robottelo/cli/syncplan.py index 9894335ab0..b4f59d3eed 100644 --- a/robottelo/cli/syncplan.py +++ b/robottelo/cli/syncplan.py @@ -16,6 +16,7 @@ list List sync plans update """ + from robottelo.cli.base import Base from robottelo.exceptions import CLIError diff --git a/robottelo/cli/task.py b/robottelo/cli/task.py index b2a2514240..79a19c3034 100644 --- a/robottelo/cli/task.py +++ b/robottelo/cli/task.py @@ -14,6 +14,7 @@ progress Show the progress of the task resume Resume all tasks paused in error state """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/template.py b/robottelo/cli/template.py index 3729fc4bf7..e2836346a9 100644 --- a/robottelo/cli/template.py +++ b/robottelo/cli/template.py @@ -20,6 +20,7 @@ remove-operatingsystem Disassociate an operating system update Update a provisioning template """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/template_input.py b/robottelo/cli/template_input.py index 9b861dbf9a..7d0a73dadf 100644 --- a/robottelo/cli/template_input.py +++ b/robottelo/cli/template_input.py @@ -15,6 +15,7 @@ info Show template input details list List template inputs """ + from robottelo.cli.base import Base, CLIError diff --git a/robottelo/cli/template_sync.py b/robottelo/cli/template_sync.py index 72ee70fa00..e3da9dbf20 100644 --- a/robottelo/cli/template_sync.py +++ b/robottelo/cli/template_sync.py @@ -39,6 +39,7 @@ prefix The string all imported templates should begin with. repo Override the default repo from settings. """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/user.py b/robottelo/cli/user.py index eb37133e78..52dc7233f5 100644 --- a/robottelo/cli/user.py +++ b/robottelo/cli/user.py @@ -20,6 +20,7 @@ ssh-keys Managing User SSH Keys. update Update an user. """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/usergroup.py b/robottelo/cli/usergroup.py index f29ad3f557..71344fc371 100644 --- a/robottelo/cli/usergroup.py +++ b/robottelo/cli/usergroup.py @@ -20,6 +20,7 @@ remove-user-group Disassociate an user group update Update a user group """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/virt_who_config.py b/robottelo/cli/virt_who_config.py index 4cb6dd1223..7e2e2e05b6 100644 --- a/robottelo/cli/virt_who_config.py +++ b/robottelo/cli/virt_who_config.py @@ -19,6 +19,7 @@ list List of virt-who configurations update Update a virt-who configuration """ + from robottelo.cli.base import Base diff --git a/robottelo/cli/webhook.py b/robottelo/cli/webhook.py index ea37b6c777..a9c311fc60 100644 --- a/robottelo/cli/webhook.py +++ b/robottelo/cli/webhook.py @@ -13,12 +13,12 @@ Options: -h, --help Print help """ + from robottelo.cli.base import Base, CLIError from robottelo.constants import WEBHOOK_EVENTS, WEBHOOK_METHODS class Webhook(Base): - command_base = 'webhook' @classmethod diff --git a/robottelo/constants/__init__.py b/robottelo/constants/__init__.py index 4851a6d34d..b3cfcdd8f3 100644 --- a/robottelo/constants/__init__.py +++ b/robottelo/constants/__init__.py @@ -1,4 +1,5 @@ """Defines various constants""" + from pathlib import Path from box import Box @@ -2079,6 +2080,7 @@ class Colored(Box): EXPIRED_MANIFEST = 'expired-manifest.zip' + # Data File Paths class DataFile(Box): """The boxed Data directory class with its attributes pointing to the Data directory files""" diff --git a/robottelo/content_info.py b/robottelo/content_info.py index fd404f5a7d..803692a082 100644 --- a/robottelo/content_info.py +++ b/robottelo/content_info.py @@ -1,4 +1,5 @@ """Miscellaneous content helper functions""" + import os import re diff --git a/robottelo/host_helpers/api_factory.py b/robottelo/host_helpers/api_factory.py index df7085e0d0..6bd9cd8365 100644 --- a/robottelo/host_helpers/api_factory.py +++ b/robottelo/host_helpers/api_factory.py @@ -2,6 +2,7 @@ It is not meant to be used directly, but as part of a robottelo.hosts.Satellite instance example: my_satellite.api_factory.api_method() """ + from contextlib import contextmanager from datetime import datetime import time diff --git a/robottelo/host_helpers/cli_factory.py b/robottelo/host_helpers/cli_factory.py index cc32500222..4e62d3d070 100644 --- a/robottelo/host_helpers/cli_factory.py +++ b/robottelo/host_helpers/cli_factory.py @@ -3,6 +3,7 @@ It is not meant to be used directly, but as part of a robottelo.hosts.Satellite instance example: my_satellite.cli_factory.make_org() """ + import datetime from functools import lru_cache, partial import inspect diff --git a/robottelo/host_helpers/contenthost_mixins.py b/robottelo/host_helpers/contenthost_mixins.py index 3b01ef2dff..c76d23405f 100644 --- a/robottelo/host_helpers/contenthost_mixins.py +++ b/robottelo/host_helpers/contenthost_mixins.py @@ -1,4 +1,5 @@ """A collection of mixins for robottelo.hosts classes""" + from functools import cached_property import json from tempfile import NamedTemporaryFile diff --git a/robottelo/host_helpers/repository_mixins.py b/robottelo/host_helpers/repository_mixins.py index 0ff2bdecd6..a55bc53ff8 100644 --- a/robottelo/host_helpers/repository_mixins.py +++ b/robottelo/host_helpers/repository_mixins.py @@ -2,6 +2,7 @@ All the Repository classes in this module are supposed to use from sat_object.cli_factory object. The direct import of the repo classes in this module is prohibited !!!!! """ + import inspect import sys @@ -509,7 +510,6 @@ class RepositoryCollection: satellite = None def __init__(self, distro=None, repositories=None): - self._items = [] if distro is not None and distro not in constants.DISTROS_SUPPORTED: diff --git a/robottelo/host_helpers/satellite_mixins.py b/robottelo/host_helpers/satellite_mixins.py index d20a70d2d1..58fe5b5d23 100644 --- a/robottelo/host_helpers/satellite_mixins.py +++ b/robottelo/host_helpers/satellite_mixins.py @@ -308,7 +308,7 @@ def validate_pulp_filepath( ): """Checks the existence of certain files in a pulp dir""" extension_query = ' -o '.join([f'-name "{file}"' for file in file_names]) - result = self.execute(fr'find {dir_path}{org.name} -type f \( {extension_query} \)') + result = self.execute(rf'find {dir_path}{org.name} -type f \( {extension_query} \)') return result.stdout diff --git a/robottelo/host_helpers/ui_factory.py b/robottelo/host_helpers/ui_factory.py index df156ad6d6..84c1498bcd 100644 --- a/robottelo/host_helpers/ui_factory.py +++ b/robottelo/host_helpers/ui_factory.py @@ -3,6 +3,7 @@ Need to pass the existing session object to the ui_factory method as a parameter example: my_satellite.ui_factory(session).ui_method() """ + from fauxfactory import gen_string from robottelo.constants import DEFAULT_CV, ENVIRONMENT diff --git a/robottelo/hosts.py b/robottelo/hosts.py index fb5a51099a..72dc0bb392 100644 --- a/robottelo/hosts.py +++ b/robottelo/hosts.py @@ -63,7 +63,7 @@ POWER_OPERATIONS = { VmState.RUNNING: 'running', VmState.STOPPED: 'stopped', - 'reboot': 'reboot' + 'reboot': 'reboot', # TODO paused, suspended, shelved? } @@ -840,10 +840,7 @@ def register_contenthost( registration. """ - if username and password: - userpass = f' --username {username} --password {password}' - else: - userpass = '' + userpass = f' --username {username} --password {password}' if username and password else '' # Setup the base command cmd = 'subscription-manager register' if org: diff --git a/robottelo/ssh.py b/robottelo/ssh.py index 8b72bed349..1be3a65a81 100644 --- a/robottelo/ssh.py +++ b/robottelo/ssh.py @@ -1,4 +1,5 @@ """Utility module to handle the shared ssh connection.""" + from robottelo.cli import hammer diff --git a/robottelo/utils/datafactory.py b/robottelo/utils/datafactory.py index 1834e0f87b..ae52d8fd74 100644 --- a/robottelo/utils/datafactory.py +++ b/robottelo/utils/datafactory.py @@ -1,4 +1,5 @@ """Data Factory for all entities""" + from functools import wraps import random import string diff --git a/robottelo/utils/decorators/__init__.py b/robottelo/utils/decorators/__init__.py index 371afd50f1..3dd3c9edeb 100644 --- a/robottelo/utils/decorators/__init__.py +++ b/robottelo/utils/decorators/__init__.py @@ -1,4 +1,5 @@ """Implements various decorators""" + from functools import wraps OBJECT_CACHE = {} diff --git a/robottelo/utils/decorators/func_locker.py b/robottelo/utils/decorators/func_locker.py index e4feaa46f2..8363242831 100644 --- a/robottelo/utils/decorators/func_locker.py +++ b/robottelo/utils/decorators/func_locker.py @@ -39,6 +39,7 @@ def test_that_conflict_with_test_to_lock(self) with locking_function(self.test_to_lock): # do some operations that conflict with test_to_lock """ + from contextlib import contextmanager import functools import inspect @@ -223,7 +224,6 @@ def lock_function( class_name = '.'.join(class_names) def main_wrapper(func): - func.__class_name__ = class_name func.__function_locked__ = True diff --git a/robottelo/utils/decorators/func_shared/file_storage.py b/robottelo/utils/decorators/func_shared/file_storage.py index 70a6d6af88..e7935300c8 100644 --- a/robottelo/utils/decorators/func_shared/file_storage.py +++ b/robottelo/utils/decorators/func_shared/file_storage.py @@ -45,7 +45,6 @@ class FileStorageHandler(BaseStorageHandler): """Key value file storage handler.""" def __init__(self, root_dir=None, create=True, lock_timeout=LOCK_TIMEOUT): - if root_dir is None: root_dir = _get_root_dir() diff --git a/robottelo/utils/decorators/func_shared/redis_storage.py b/robottelo/utils/decorators/func_shared/redis_storage.py index 571ac0ac69..74a5b8d0ec 100644 --- a/robottelo/utils/decorators/func_shared/redis_storage.py +++ b/robottelo/utils/decorators/func_shared/redis_storage.py @@ -23,7 +23,6 @@ def __init__( password=REDIS_PASSWORD, lock_timeout=LOCK_TIMEOUT, ): - self._lock_timeout = lock_timeout self._client = redis.StrictRedis(host=host, port=port, db=db, password=password) diff --git a/robottelo/utils/decorators/func_shared/shared.py b/robottelo/utils/decorators/func_shared/shared.py index 4c325084c4..50e2d371fb 100644 --- a/robottelo/utils/decorators/func_shared/shared.py +++ b/robottelo/utils/decorators/func_shared/shared.py @@ -84,6 +84,7 @@ def shared_class_method(cls, org=None, repo=None): return dict(org=cls.org, repo=cls.repo} """ + import datetime import functools import hashlib @@ -213,7 +214,6 @@ def __init__( inject=False, injected_kw='_inject', ): - if storage_handler is None: storage_handler = _get_default_storage_handler() @@ -258,7 +258,6 @@ def _encode_result_kwargs(self, kwargs): return kwargs def _call_function(self): - retries = self._max_retries if not retries: retries = 1 @@ -465,11 +464,7 @@ def _get_function_name_key(function_name, scope=None, scope_kwargs=None, scope_c scope_name = _get_scope_name( scope=scope, scope_kwargs=scope_kwargs, scope_context=scope_context ) - if scope_name: - function_name_key = '.'.join([scope_name, function_name]) - else: - function_name_key = function_name - return function_name_key + return '.'.join([scope_name, function_name]) if scope_name else function_name def shared( diff --git a/robottelo/utils/manifest.py b/robottelo/utils/manifest.py index 52c220f3c5..aa377ae73e 100644 --- a/robottelo/utils/manifest.py +++ b/robottelo/utils/manifest.py @@ -69,9 +69,9 @@ def manifest_clone(self, org_environment_access=False, name='default'): consumer_data['uuid'] = str(uuid.uuid1()) if org_environment_access: consumer_data['contentAccessMode'] = 'org_environment' - consumer_data['owner'][ - 'contentAccessModeList' - ] = 'entitlement,org_environment' + consumer_data['owner']['contentAccessModeList'] = ( + 'entitlement,org_environment' + ) new_consumer_export_zip.writestr(name, json.dumps(consumer_data)) else: new_consumer_export_zip.writestr(name, consumer_export_zip.read(name)) diff --git a/robottelo/utils/ohsnap.py b/robottelo/utils/ohsnap.py index 96241a759b..83669cdb61 100644 --- a/robottelo/utils/ohsnap.py +++ b/robottelo/utils/ohsnap.py @@ -1,4 +1,5 @@ """Utility module to communicate with Ohsnap API""" + from box import Box from packaging.version import Version import requests diff --git a/robottelo/utils/shared_resource.py b/robottelo/utils/shared_resource.py index 0ad0bd92e4..fa17f3f0c1 100644 --- a/robottelo/utils/shared_resource.py +++ b/robottelo/utils/shared_resource.py @@ -21,6 +21,7 @@ ... yield target_sat # give the upgraded satellite to the test ... # Do post-upgrade cleanup steps if any """ + import json from pathlib import Path import time diff --git a/robottelo/utils/ssh.py b/robottelo/utils/ssh.py index 8b72bed349..1be3a65a81 100644 --- a/robottelo/utils/ssh.py +++ b/robottelo/utils/ssh.py @@ -1,4 +1,5 @@ """Utility module to handle the shared ssh connection.""" + from robottelo.cli import hammer diff --git a/robottelo/utils/vault.py b/robottelo/utils/vault.py index 97f95755bb..417fa2c13b 100644 --- a/robottelo/utils/vault.py +++ b/robottelo/utils/vault.py @@ -1,4 +1,5 @@ """Hashicorp Vault Utils where vault CLI is wrapped to perform vault operations""" + import json import os import re diff --git a/robottelo/utils/virtwho.py b/robottelo/utils/virtwho.py index 9d2b033d6e..0013071fba 100644 --- a/robottelo/utils/virtwho.py +++ b/robottelo/utils/virtwho.py @@ -1,4 +1,5 @@ """Utility module to handle the virtwho configure UI/CLI/API testing""" + import json import re import uuid diff --git a/scripts/config_helpers.py b/scripts/config_helpers.py index cf422588b0..bc559c5091 100644 --- a/scripts/config_helpers.py +++ b/scripts/config_helpers.py @@ -1,4 +1,5 @@ """A series of commands to help with robottelo configuration""" + from pathlib import Path import click diff --git a/scripts/graph_entities.py b/scripts/graph_entities.py index 46038a3e3b..bd4accfa2e 100755 --- a/scripts/graph_entities.py +++ b/scripts/graph_entities.py @@ -7,6 +7,7 @@ command provided by the make file in the parent directory. """ + import inspect from nailgun import entities, entity_mixins diff --git a/scripts/hammer_command_tree.py b/scripts/hammer_command_tree.py index 55a10add78..580447047c 100755 --- a/scripts/hammer_command_tree.py +++ b/scripts/hammer_command_tree.py @@ -2,6 +2,7 @@ help. """ + import json from robottelo import ssh diff --git a/scripts/token_editor.py b/scripts/token_editor.py index 923aef02aa..f492c8c3fb 100755 --- a/scripts/token_editor.py +++ b/scripts/token_editor.py @@ -4,6 +4,7 @@ Reads Python test modules under test/foreman and edit docstring tokens' prefix from ``OLD_TOKEN_PREFIX`` to ``NEW_TOKEN_PREFIX``. """ + import glob import os import re @@ -30,6 +31,6 @@ for test_module in test_modules: with open(test_module) as handler: content = handler.read() - content = TOKEN_RE.sub(fr'{NEW_TOKEN_PREFIX}\1:', content) + content = TOKEN_RE.sub(rf'{NEW_TOKEN_PREFIX}\1:', content) with open(test_module, 'w') as handler: handler.write(content) diff --git a/scripts/tokenize_customer_scenario.py b/scripts/tokenize_customer_scenario.py index 14a0cbf75a..f810e00c4e 100644 --- a/scripts/tokenize_customer_scenario.py +++ b/scripts/tokenize_customer_scenario.py @@ -13,6 +13,7 @@ On robottelo root dir run: $ python scripts/tokenize_customer_scenario.py """ + import codemod from codemod import Query, regex_suggestor, run_interactive from codemod.helpers import path_filter diff --git a/scripts/validate_config.py b/scripts/validate_config.py index a01f350ae6..04af5d7ac4 100644 --- a/scripts/validate_config.py +++ b/scripts/validate_config.py @@ -1,4 +1,5 @@ """Usage: python scripts/validate_config.py""" + from dynaconf.validator import ValidationError from robottelo.config import get_settings diff --git a/tests/foreman/api/test_acs.py b/tests/foreman/api/test_acs.py index 7821db07fc..a8b24345bc 100644 --- a/tests/foreman/api/test_acs.py +++ b/tests/foreman/api/test_acs.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from fauxfactory import gen_string import pytest from requests.exceptions import HTTPError diff --git a/tests/foreman/api/test_activationkey.py b/tests/foreman/api/test_activationkey.py index ef5add381f..36ee295ef9 100644 --- a/tests/foreman/api/test_activationkey.py +++ b/tests/foreman/api/test_activationkey.py @@ -12,6 +12,7 @@ """ + import http from fauxfactory import gen_integer, gen_string diff --git a/tests/foreman/api/test_ansible.py b/tests/foreman/api/test_ansible.py index 435501d069..71d47b860d 100644 --- a/tests/foreman/api/test_ansible.py +++ b/tests/foreman/api/test_ansible.py @@ -11,6 +11,7 @@ :CaseImportance: Critical """ + from fauxfactory import gen_string import pytest from wait_for import wait_for diff --git a/tests/foreman/api/test_architecture.py b/tests/foreman/api/test_architecture.py index 362abbfae3..b40173fe21 100644 --- a/tests/foreman/api/test_architecture.py +++ b/tests/foreman/api/test_architecture.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from fauxfactory import gen_choice import pytest from requests.exceptions import HTTPError diff --git a/tests/foreman/api/test_audit.py b/tests/foreman/api/test_audit.py index a90eda8388..430657d9c8 100644 --- a/tests/foreman/api/test_audit.py +++ b/tests/foreman/api/test_audit.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest from robottelo.utils.datafactory import gen_string diff --git a/tests/foreman/api/test_bookmarks.py b/tests/foreman/api/test_bookmarks.py index 5d5833ef56..9b532a4815 100644 --- a/tests/foreman/api/test_bookmarks.py +++ b/tests/foreman/api/test_bookmarks.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import random from fauxfactory import gen_string diff --git a/tests/foreman/api/test_capsule.py b/tests/foreman/api/test_capsule.py index 7cbb989f94..5600cc040a 100644 --- a/tests/foreman/api/test_capsule.py +++ b/tests/foreman/api/test_capsule.py @@ -11,6 +11,7 @@ :CaseImportance: Critical """ + from fauxfactory import gen_string, gen_url import pytest from requests import HTTPError diff --git a/tests/foreman/api/test_classparameters.py b/tests/foreman/api/test_classparameters.py index 931a11edec..d74e708bd6 100644 --- a/tests/foreman/api/test_classparameters.py +++ b/tests/foreman/api/test_classparameters.py @@ -11,6 +11,7 @@ :Team: Rocket """ + import json from random import choice diff --git a/tests/foreman/api/test_computeprofile.py b/tests/foreman/api/test_computeprofile.py index 6d374bc8b3..785278ee2b 100644 --- a/tests/foreman/api/test_computeprofile.py +++ b/tests/foreman/api/test_computeprofile.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest from requests.exceptions import HTTPError diff --git a/tests/foreman/api/test_computeresource_azurerm.py b/tests/foreman/api/test_computeresource_azurerm.py index 47bf831306..d8751f6578 100644 --- a/tests/foreman/api/test_computeresource_azurerm.py +++ b/tests/foreman/api/test_computeresource_azurerm.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from fauxfactory import gen_string import pytest diff --git a/tests/foreman/api/test_computeresource_gce.py b/tests/foreman/api/test_computeresource_gce.py index 2d088f4f2a..8f27e9b98f 100644 --- a/tests/foreman/api/test_computeresource_gce.py +++ b/tests/foreman/api/test_computeresource_gce.py @@ -14,6 +14,7 @@ :CaseImportance: High """ + import random from fauxfactory import gen_string diff --git a/tests/foreman/api/test_computeresource_libvirt.py b/tests/foreman/api/test_computeresource_libvirt.py index ad95fb9f20..ce0c0ff0b9 100644 --- a/tests/foreman/api/test_computeresource_libvirt.py +++ b/tests/foreman/api/test_computeresource_libvirt.py @@ -15,6 +15,7 @@ :CaseImportance: High """ + from fauxfactory import gen_string import pytest from requests.exceptions import HTTPError diff --git a/tests/foreman/api/test_contentcredentials.py b/tests/foreman/api/test_contentcredentials.py index 3f088ae625..2263edca0d 100644 --- a/tests/foreman/api/test_contentcredentials.py +++ b/tests/foreman/api/test_contentcredentials.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from copy import copy from fauxfactory import gen_string diff --git a/tests/foreman/api/test_contentview.py b/tests/foreman/api/test_contentview.py index eda0c9ec6b..e85532def0 100644 --- a/tests/foreman/api/test_contentview.py +++ b/tests/foreman/api/test_contentview.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from datetime import datetime, timedelta import random diff --git a/tests/foreman/api/test_contentviewfilter.py b/tests/foreman/api/test_contentviewfilter.py index 6360bf5da1..0516582ed5 100644 --- a/tests/foreman/api/test_contentviewfilter.py +++ b/tests/foreman/api/test_contentviewfilter.py @@ -15,6 +15,7 @@ :CaseImportance: High """ + import http from random import randint diff --git a/tests/foreman/api/test_contentviewversion.py b/tests/foreman/api/test_contentviewversion.py index 5f3414456e..b870ffb19f 100644 --- a/tests/foreman/api/test_contentviewversion.py +++ b/tests/foreman/api/test_contentviewversion.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from fauxfactory import gen_string import pytest from requests.exceptions import HTTPError diff --git a/tests/foreman/api/test_convert2rhel.py b/tests/foreman/api/test_convert2rhel.py index c78d06f0ac..a5dece8f71 100644 --- a/tests/foreman/api/test_convert2rhel.py +++ b/tests/foreman/api/test_convert2rhel.py @@ -11,6 +11,7 @@ :Team: Rocket """ + import pytest import requests diff --git a/tests/foreman/api/test_discoveredhost.py b/tests/foreman/api/test_discoveredhost.py index 976c1812e4..31ad0b1d41 100644 --- a/tests/foreman/api/test_discoveredhost.py +++ b/tests/foreman/api/test_discoveredhost.py @@ -9,6 +9,7 @@ :CaseAutomation: Automated """ + import re from fauxfactory import gen_choice, gen_ipaddr, gen_mac, gen_string diff --git a/tests/foreman/api/test_discoveryrule.py b/tests/foreman/api/test_discoveryrule.py index 3d1c1f4bf4..2ffddb5171 100644 --- a/tests/foreman/api/test_discoveryrule.py +++ b/tests/foreman/api/test_discoveryrule.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from fauxfactory import gen_choice, gen_integer, gen_string import pytest from requests.exceptions import HTTPError diff --git a/tests/foreman/api/test_docker.py b/tests/foreman/api/test_docker.py index eab9d213db..6bebe5e81f 100644 --- a/tests/foreman/api/test_docker.py +++ b/tests/foreman/api/test_docker.py @@ -7,6 +7,7 @@ :CaseImportance: High """ + from random import choice, randint, shuffle from fauxfactory import gen_string, gen_url diff --git a/tests/foreman/api/test_environment.py b/tests/foreman/api/test_environment.py index 02f7a3928e..d0e62dbe6a 100644 --- a/tests/foreman/api/test_environment.py +++ b/tests/foreman/api/test_environment.py @@ -15,6 +15,7 @@ :CaseImportance: Critical """ + from fauxfactory import gen_string import pytest from requests.exceptions import HTTPError diff --git a/tests/foreman/api/test_errata.py b/tests/foreman/api/test_errata.py index 81974401a9..8fd717b44f 100644 --- a/tests/foreman/api/test_errata.py +++ b/tests/foreman/api/test_errata.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + # For ease of use hc refers to host-collection throughout this document from time import sleep, time @@ -122,8 +123,7 @@ def _validate_errata_counts(host, errata_type, expected_value, timeout=120): sleep(5) else: pytest.fail( - 'Host {} contains {} {} errata, but expected to contain ' - '{} of them'.format( + 'Host {} contains {} {} errata, but expected to contain {} of them'.format( host.name, host.content_facet_attributes['errata_counts'][errata_type], errata_type, @@ -149,8 +149,7 @@ def _fetch_available_errata(host, expected_amount=None, timeout=120): errata = host.errata() else: pytest.fail( - 'Host {} contains {} available errata, but expected to ' - 'contain {} of them'.format( + 'Host {} contains {} available errata, but expected to contain {} of them'.format( host.name, len(errata['results']), expected_amount if not None else 'No expected_amount provided', @@ -400,7 +399,7 @@ def package_applicability_changed_as_expected( output = host.execute(f'rpm -q {package_basename}').stdout current_package = output[:-1] assert package_basename in current_package - if current_package == package_filename: + if current_package == package_filename: # noqa: SIM108 # we have already checked if applicable package count changed, # in case the same version as prior was installed and present. prior_package = None # package must not have been present before this modification @@ -495,13 +494,16 @@ def _publish_and_wait(sat, org, cv, search_rate=1, max_tries=10): task_id = sat.api.ContentView(id=cv.id).publish({'id': cv.id, 'organization': org})['id'] assert task_id, f'No task was invoked to publish the Content-View: {cv.id}.' # Should take < 1 minute, check in 5s intervals - sat.wait_for_tasks( - search_query=(f'label = Actions::Katello::ContentView::Publish and id = {task_id}'), - search_rate=search_rate, - max_tries=max_tries, - ), ( - f'Failed to publish the Content-View: {cv.id}, in time.' - f'Task: {task_id} failed, or timed out ({search_rate*max_tries}s).' + ( + sat.wait_for_tasks( + search_query=(f'label = Actions::Katello::ContentView::Publish and id = {task_id}'), + search_rate=search_rate, + max_tries=max_tries, + ), + ( + f'Failed to publish the Content-View: {cv.id}, in time.' + f'Task: {task_id} failed, or timed out ({search_rate*max_tries}s).' + ), ) @@ -623,13 +625,16 @@ def test_positive_install_in_hc( 'organization_id': module_sca_manifest_org.id, }, )['id'] - target_sat.wait_for_tasks( - search_query=(f'label = Actions::RemoteExecution::RunHostsJob and id = {task_id}'), - search_rate=15, - max_tries=10, - ), ( - f'Could not install erratum: {CUSTOM_REPO_ERRATA_ID}, to Host-Collection.' - f' Task: {task_id} failed, or timed out.' + ( + target_sat.wait_for_tasks( + search_query=(f'label = Actions::RemoteExecution::RunHostsJob and id = {task_id}'), + search_rate=15, + max_tries=10, + ), + ( + f'Could not install erratum: {CUSTOM_REPO_ERRATA_ID}, to Host-Collection.' + f' Task: {task_id} failed, or timed out.' + ), ) for client in content_hosts: # No applicable errata after install on all clients @@ -928,8 +933,8 @@ def test_positive_install_multiple_in_host( f' but installed {len(updated_packages)}.' ) # Check sets of installed package filename(s) strings, matches expected - assert set(updated_packages) == set( - security_packages_to_install + assert ( + set(updated_packages) == set(security_packages_to_install) ), 'Expected package version filename(s) and installed package version filenam(s) are not the same.' diff --git a/tests/foreman/api/test_filter.py b/tests/foreman/api/test_filter.py index d13d5a7eca..b676a67c6d 100644 --- a/tests/foreman/api/test_filter.py +++ b/tests/foreman/api/test_filter.py @@ -15,6 +15,7 @@ :CaseImportance: High """ + import pytest from requests.exceptions import HTTPError diff --git a/tests/foreman/api/test_foremantask.py b/tests/foreman/api/test_foremantask.py index c736a0e716..0cab125336 100644 --- a/tests/foreman/api/test_foremantask.py +++ b/tests/foreman/api/test_foremantask.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest from requests.exceptions import HTTPError diff --git a/tests/foreman/api/test_host.py b/tests/foreman/api/test_host.py index eb3e89dc6a..e8982215ad 100644 --- a/tests/foreman/api/test_host.py +++ b/tests/foreman/api/test_host.py @@ -15,6 +15,7 @@ :CaseImportance: High """ + import http from fauxfactory import gen_choice, gen_integer, gen_ipaddr, gen_mac, gen_string diff --git a/tests/foreman/api/test_hostcollection.py b/tests/foreman/api/test_hostcollection.py index 985f989718..3675b7a40b 100644 --- a/tests/foreman/api/test_hostcollection.py +++ b/tests/foreman/api/test_hostcollection.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from random import choice, randint from broker import Broker diff --git a/tests/foreman/api/test_hostgroup.py b/tests/foreman/api/test_hostgroup.py index e0e6fd9ed9..5313ec0400 100644 --- a/tests/foreman/api/test_hostgroup.py +++ b/tests/foreman/api/test_hostgroup.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from random import randint from fauxfactory import gen_string diff --git a/tests/foreman/api/test_http_proxy.py b/tests/foreman/api/test_http_proxy.py index 1bd00051e6..4d4b3faf8f 100644 --- a/tests/foreman/api/test_http_proxy.py +++ b/tests/foreman/api/test_http_proxy.py @@ -11,6 +11,7 @@ :CaseAutomation: Automated """ + from fauxfactory import gen_string import pytest diff --git a/tests/foreman/api/test_ldapauthsource.py b/tests/foreman/api/test_ldapauthsource.py index 885d290e74..09742a8ff8 100644 --- a/tests/foreman/api/test_ldapauthsource.py +++ b/tests/foreman/api/test_ldapauthsource.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest from requests.exceptions import HTTPError diff --git a/tests/foreman/api/test_lifecycleenvironment.py b/tests/foreman/api/test_lifecycleenvironment.py index b68017efb8..61ec1a69a0 100644 --- a/tests/foreman/api/test_lifecycleenvironment.py +++ b/tests/foreman/api/test_lifecycleenvironment.py @@ -15,6 +15,7 @@ :CaseImportance: High """ + from fauxfactory import gen_string import pytest from requests.exceptions import HTTPError diff --git a/tests/foreman/api/test_location.py b/tests/foreman/api/test_location.py index 2e54a4862f..28c2d9c0b2 100644 --- a/tests/foreman/api/test_location.py +++ b/tests/foreman/api/test_location.py @@ -14,6 +14,7 @@ :CaseImportance: High """ + from random import randint from fauxfactory import gen_integer, gen_string diff --git a/tests/foreman/api/test_media.py b/tests/foreman/api/test_media.py index 79c5cb7f20..f58f798217 100644 --- a/tests/foreman/api/test_media.py +++ b/tests/foreman/api/test_media.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import random from fauxfactory import gen_string, gen_url @@ -38,7 +39,7 @@ def class_media(self, module_org, class_target_sat): ('name', 'new_name'), **parametrized( list(zip(valid_data_list().values(), valid_data_list().values(), strict=True)) - ) + ), ) def test_positive_crud_with_name(self, module_org, name, new_name, module_target_sat): """Create, update, delete media with valid name only diff --git a/tests/foreman/api/test_multiple_paths.py b/tests/foreman/api/test_multiple_paths.py index 8c683ca309..b179e487fb 100644 --- a/tests/foreman/api/test_multiple_paths.py +++ b/tests/foreman/api/test_multiple_paths.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import http from nailgun import client, entities, entity_fields diff --git a/tests/foreman/api/test_notifications.py b/tests/foreman/api/test_notifications.py index f2477ad329..13b142d9c5 100644 --- a/tests/foreman/api/test_notifications.py +++ b/tests/foreman/api/test_notifications.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from mailbox import mbox from re import findall from tempfile import mkstemp @@ -231,7 +232,7 @@ def long_running_task(target_sat): 'password': settings.server.ssh_password, }, ) - sql_date_2_days_ago = "now() - INTERVAL \'2 days\'" + sql_date_2_days_ago = "now() - INTERVAL '2 days'" result = target_sat.execute( "su - postgres -c \"psql foreman postgres <> {0}'''.format( - HAMMER_CONFIG, 'true' if enable else 'false' - ) + echo ' :use_sessions: {1}' >> {0}'''.format(HAMMER_CONFIG, 'true' if enable else 'false') ) if result.status == 0 and add_default_creds: result = satellite.execute( diff --git a/tests/foreman/cli/test_bootdisk.py b/tests/foreman/cli/test_bootdisk.py index 5e0ca29eec..7d9cf6ce70 100644 --- a/tests/foreman/cli/test_bootdisk.py +++ b/tests/foreman/cli/test_bootdisk.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from fauxfactory import gen_mac, gen_string import pytest diff --git a/tests/foreman/cli/test_bootstrap_script.py b/tests/foreman/cli/test_bootstrap_script.py index f4b71c24bd..65872032d1 100644 --- a/tests/foreman/cli/test_bootstrap_script.py +++ b/tests/foreman/cli/test_bootstrap_script.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest diff --git a/tests/foreman/cli/test_capsule.py b/tests/foreman/cli/test_capsule.py index ddcc100326..3f7e98b104 100644 --- a/tests/foreman/cli/test_capsule.py +++ b/tests/foreman/cli/test_capsule.py @@ -11,6 +11,7 @@ :CaseImportance: Critical """ + import pytest pytestmark = [pytest.mark.run_in_one_thread] diff --git a/tests/foreman/cli/test_capsulecontent.py b/tests/foreman/cli/test_capsulecontent.py index 73e42659fa..a75ffbb1ae 100644 --- a/tests/foreman/cli/test_capsulecontent.py +++ b/tests/foreman/cli/test_capsulecontent.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest from robottelo.config import settings diff --git a/tests/foreman/cli/test_classparameters.py b/tests/foreman/cli/test_classparameters.py index 022ceed0aa..f6b0ca7a4e 100644 --- a/tests/foreman/cli/test_classparameters.py +++ b/tests/foreman/cli/test_classparameters.py @@ -11,6 +11,7 @@ :Team: Rocket """ + import pytest from robottelo.config import settings diff --git a/tests/foreman/cli/test_computeresource_azurerm.py b/tests/foreman/cli/test_computeresource_azurerm.py index 1756a0ed67..1c64a55c5b 100644 --- a/tests/foreman/cli/test_computeresource_azurerm.py +++ b/tests/foreman/cli/test_computeresource_azurerm.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from fauxfactory import gen_string import pytest @@ -343,8 +344,9 @@ def class_host_ft( Provisions the host on AzureRM using Finish template Later in tests this host will be used to perform assertions """ - with sat_azure.hammer_api_timeout(), sat_azure.skip_yum_update_during_provisioning( - template='Kickstart default finish' + with ( + sat_azure.hammer_api_timeout(), + sat_azure.skip_yum_update_during_provisioning(template='Kickstart default finish'), ): host = sat_azure.cli.Host.create( { @@ -472,8 +474,9 @@ def class_host_ud( Provisions the host on AzureRM using UserData template Later in tests this host will be used to perform assertions """ - with sat_azure.hammer_api_timeout(), sat_azure.skip_yum_update_during_provisioning( - template='Kickstart default user data' + with ( + sat_azure.hammer_api_timeout(), + sat_azure.skip_yum_update_during_provisioning(template='Kickstart default user data'), ): host = sat_azure.cli.Host.create( { diff --git a/tests/foreman/cli/test_computeresource_ec2.py b/tests/foreman/cli/test_computeresource_ec2.py index e4e1e669e6..36c128bdee 100644 --- a/tests/foreman/cli/test_computeresource_ec2.py +++ b/tests/foreman/cli/test_computeresource_ec2.py @@ -8,6 +8,7 @@ :CaseImportance: High """ + from fauxfactory import gen_string import pytest diff --git a/tests/foreman/cli/test_computeresource_libvirt.py b/tests/foreman/cli/test_computeresource_libvirt.py index 2a4720750a..656a8ed32c 100644 --- a/tests/foreman/cli/test_computeresource_libvirt.py +++ b/tests/foreman/cli/test_computeresource_libvirt.py @@ -28,6 +28,7 @@ :CaseImportance: High """ + import random from fauxfactory import gen_string, gen_url diff --git a/tests/foreman/cli/test_computeresource_osp.py b/tests/foreman/cli/test_computeresource_osp.py index ff6779056a..1b80cae877 100644 --- a/tests/foreman/cli/test_computeresource_osp.py +++ b/tests/foreman/cli/test_computeresource_osp.py @@ -10,6 +10,7 @@ :CaseImportance: High """ + from box import Box from fauxfactory import gen_string import pytest diff --git a/tests/foreman/cli/test_computeresource_rhev.py b/tests/foreman/cli/test_computeresource_rhev.py index 173b9c1c41..9e93125eb6 100644 --- a/tests/foreman/cli/test_computeresource_rhev.py +++ b/tests/foreman/cli/test_computeresource_rhev.py @@ -10,6 +10,7 @@ :CaseImportance: High """ + from fauxfactory import gen_string import pytest from wait_for import wait_for diff --git a/tests/foreman/cli/test_computeresource_vmware.py b/tests/foreman/cli/test_computeresource_vmware.py index 62ee4a7150..da69418eec 100644 --- a/tests/foreman/cli/test_computeresource_vmware.py +++ b/tests/foreman/cli/test_computeresource_vmware.py @@ -10,6 +10,7 @@ :CaseAutomation: Automated """ + from fauxfactory import gen_string import pytest from wait_for import wait_for diff --git a/tests/foreman/cli/test_container_management.py b/tests/foreman/cli/test_container_management.py index 17d0b0b4bd..871993090e 100644 --- a/tests/foreman/cli/test_container_management.py +++ b/tests/foreman/cli/test_container_management.py @@ -9,6 +9,7 @@ :CaseComponent: ContainerManagement-Content """ + from fauxfactory import gen_string import pytest from wait_for import wait_for diff --git a/tests/foreman/cli/test_contentaccess.py b/tests/foreman/cli/test_contentaccess.py index 0c59e5c70e..5eefd3af5b 100644 --- a/tests/foreman/cli/test_contentaccess.py +++ b/tests/foreman/cli/test_contentaccess.py @@ -9,6 +9,7 @@ :team: Phoenix-subscriptions """ + import time from nailgun import entities diff --git a/tests/foreman/cli/test_contentcredentials.py b/tests/foreman/cli/test_contentcredentials.py index 208812cb85..14d4ff5071 100644 --- a/tests/foreman/cli/test_contentcredentials.py +++ b/tests/foreman/cli/test_contentcredentials.py @@ -13,6 +13,7 @@ :CaseImportance: High """ + from tempfile import mkstemp from fauxfactory import gen_alphanumeric, gen_choice, gen_integer, gen_string diff --git a/tests/foreman/cli/test_contentview.py b/tests/foreman/cli/test_contentview.py index c2de286b9f..33a1814933 100644 --- a/tests/foreman/cli/test_contentview.py +++ b/tests/foreman/cli/test_contentview.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import random from fauxfactory import gen_alphanumeric, gen_string diff --git a/tests/foreman/cli/test_contentviewfilter.py b/tests/foreman/cli/test_contentviewfilter.py index 65ffeb940a..0a198b2754 100644 --- a/tests/foreman/cli/test_contentviewfilter.py +++ b/tests/foreman/cli/test_contentviewfilter.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import random from fauxfactory import gen_string diff --git a/tests/foreman/cli/test_discoveredhost.py b/tests/foreman/cli/test_discoveredhost.py index e578f35e1a..4c81335e2a 100644 --- a/tests/foreman/cli/test_discoveredhost.py +++ b/tests/foreman/cli/test_discoveredhost.py @@ -9,6 +9,7 @@ :Team: Rocket """ + import pytest from wait_for import wait_for diff --git a/tests/foreman/cli/test_discoveryrule.py b/tests/foreman/cli/test_discoveryrule.py index 2d9059f196..933b68538a 100644 --- a/tests/foreman/cli/test_discoveryrule.py +++ b/tests/foreman/cli/test_discoveryrule.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from functools import partial import random diff --git a/tests/foreman/cli/test_docker.py b/tests/foreman/cli/test_docker.py index 10b1d1dd4f..30f96d9212 100644 --- a/tests/foreman/cli/test_docker.py +++ b/tests/foreman/cli/test_docker.py @@ -7,6 +7,7 @@ :CaseImportance: High """ + from random import choice, randint from fauxfactory import gen_string, gen_url diff --git a/tests/foreman/cli/test_domain.py b/tests/foreman/cli/test_domain.py index 32f8136959..d77829e303 100644 --- a/tests/foreman/cli/test_domain.py +++ b/tests/foreman/cli/test_domain.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from fauxfactory import gen_string import pytest diff --git a/tests/foreman/cli/test_environment.py b/tests/foreman/cli/test_environment.py index 90e5b79e72..422030f6af 100644 --- a/tests/foreman/cli/test_environment.py +++ b/tests/foreman/cli/test_environment.py @@ -11,6 +11,7 @@ :CaseImportance: Critical """ + from random import choice from fauxfactory import gen_alphanumeric, gen_string diff --git a/tests/foreman/cli/test_errata.py b/tests/foreman/cli/test_errata.py index 0dc3e09165..881f95a1c7 100644 --- a/tests/foreman/cli/test_errata.py +++ b/tests/foreman/cli/test_errata.py @@ -10,6 +10,7 @@ :CaseImportance: High """ + from datetime import date, datetime, timedelta from operator import itemgetter import re diff --git a/tests/foreman/cli/test_fact.py b/tests/foreman/cli/test_fact.py index ddaaa47794..7913d68287 100644 --- a/tests/foreman/cli/test_fact.py +++ b/tests/foreman/cli/test_fact.py @@ -11,6 +11,7 @@ :CaseImportance: Critical """ + from fauxfactory import gen_string import pytest diff --git a/tests/foreman/cli/test_filter.py b/tests/foreman/cli/test_filter.py index 4108ce07d6..3f05953d6c 100644 --- a/tests/foreman/cli/test_filter.py +++ b/tests/foreman/cli/test_filter.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest from robottelo.exceptions import CLIReturnCodeError diff --git a/tests/foreman/cli/test_foremantask.py b/tests/foreman/cli/test_foremantask.py index bdce6e63a9..da49b88a28 100644 --- a/tests/foreman/cli/test_foremantask.py +++ b/tests/foreman/cli/test_foremantask.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest diff --git a/tests/foreman/cli/test_globalparam.py b/tests/foreman/cli/test_globalparam.py index 41bb8ca769..6c1eaed9c0 100644 --- a/tests/foreman/cli/test_globalparam.py +++ b/tests/foreman/cli/test_globalparam.py @@ -11,6 +11,7 @@ :CaseImportance: Critical """ + from functools import partial from fauxfactory import gen_string diff --git a/tests/foreman/cli/test_hammer.py b/tests/foreman/cli/test_hammer.py index aa3bfcf4ae..bc78daa88c 100644 --- a/tests/foreman/cli/test_hammer.py +++ b/tests/foreman/cli/test_hammer.py @@ -11,6 +11,7 @@ :CaseImportance: Critical """ + import io import json import re diff --git a/tests/foreman/cli/test_host.py b/tests/foreman/cli/test_host.py index d053d7d513..42cd5a0719 100644 --- a/tests/foreman/cli/test_host.py +++ b/tests/foreman/cli/test_host.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from random import choice import re diff --git a/tests/foreman/cli/test_hostcollection.py b/tests/foreman/cli/test_hostcollection.py index ce3426030b..e01238e440 100644 --- a/tests/foreman/cli/test_hostcollection.py +++ b/tests/foreman/cli/test_hostcollection.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from broker import Broker from fauxfactory import gen_string import pytest diff --git a/tests/foreman/cli/test_hostgroup.py b/tests/foreman/cli/test_hostgroup.py index febe94038f..dee6662a95 100644 --- a/tests/foreman/cli/test_hostgroup.py +++ b/tests/foreman/cli/test_hostgroup.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from fauxfactory import gen_integer from nailgun import entities import pytest diff --git a/tests/foreman/cli/test_http_proxy.py b/tests/foreman/cli/test_http_proxy.py index 68ea95559c..bc7e07b0cd 100644 --- a/tests/foreman/cli/test_http_proxy.py +++ b/tests/foreman/cli/test_http_proxy.py @@ -11,6 +11,7 @@ :CaseAutomation: Automated """ + from fauxfactory import gen_integer, gen_string, gen_url import pytest diff --git a/tests/foreman/cli/test_installer.py b/tests/foreman/cli/test_installer.py index cf0eb838ee..a31ad21123 100644 --- a/tests/foreman/cli/test_installer.py +++ b/tests/foreman/cli/test_installer.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest pytestmark = [pytest.mark.stubbed] diff --git a/tests/foreman/cli/test_jobtemplate.py b/tests/foreman/cli/test_jobtemplate.py index 66553d2c54..8fb8012038 100644 --- a/tests/foreman/cli/test_jobtemplate.py +++ b/tests/foreman/cli/test_jobtemplate.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from fauxfactory import gen_string import pytest diff --git a/tests/foreman/cli/test_ldapauthsource.py b/tests/foreman/cli/test_ldapauthsource.py index e3cb8bb32a..f87695dd58 100644 --- a/tests/foreman/cli/test_ldapauthsource.py +++ b/tests/foreman/cli/test_ldapauthsource.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from fauxfactory import gen_string from nailgun import entities import pytest @@ -113,7 +114,7 @@ def test_positive_refresh_usergroup_with_ad(self, member_group, ad_data, module_ 'attr-firstname': LDAP_ATTR['firstname'], 'attr-lastname': LDAP_ATTR['surname'], 'attr-mail': LDAP_ATTR['mail'], - 'account': fr"{ad_data['workgroup']}\{ad_data['ldap_user_name']}", + 'account': rf"{ad_data['workgroup']}\{ad_data['ldap_user_name']}", 'account-password': ad_data['ldap_user_passwd'], 'base-dn': ad_data['base_dn'], } diff --git a/tests/foreman/cli/test_leapp_client.py b/tests/foreman/cli/test_leapp_client.py index 83c577de58..e4402d3f6a 100644 --- a/tests/foreman/cli/test_leapp_client.py +++ b/tests/foreman/cli/test_leapp_client.py @@ -11,6 +11,7 @@ :CaseAutomation: Automated """ + from broker import Broker from fauxfactory import gen_string import pytest diff --git a/tests/foreman/cli/test_lifecycleenvironment.py b/tests/foreman/cli/test_lifecycleenvironment.py index 75bf12c681..294753e04e 100644 --- a/tests/foreman/cli/test_lifecycleenvironment.py +++ b/tests/foreman/cli/test_lifecycleenvironment.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from math import ceil from fauxfactory import gen_string diff --git a/tests/foreman/cli/test_location.py b/tests/foreman/cli/test_location.py index 9f835c1c58..eff9220f14 100644 --- a/tests/foreman/cli/test_location.py +++ b/tests/foreman/cli/test_location.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from fauxfactory import gen_string import pytest diff --git a/tests/foreman/cli/test_logging.py b/tests/foreman/cli/test_logging.py index bb7daceb60..c4bf8602e0 100644 --- a/tests/foreman/cli/test_logging.py +++ b/tests/foreman/cli/test_logging.py @@ -11,6 +11,7 @@ :CaseImportance: Medium """ + import re from fauxfactory import gen_string @@ -242,7 +243,7 @@ def test_positive_logging_from_pulp3(module_org, target_sat): target_sat.cli.Repository.synchronize({'id': repo['id']}) # Get the id of repository sync from task task_out = target_sat.execute( - "hammer task list | grep -F \'Synchronize repository {\"text\"=>\"repository\'" + "hammer task list | grep -F 'Synchronize repository {\"text\"=>\"repository'" ).stdout.splitlines()[0][:8] prod_log_out = target_sat.execute(f'grep {task_out} {source_log}').stdout.splitlines()[0] # Get correlation id of pulp from production logs diff --git a/tests/foreman/cli/test_medium.py b/tests/foreman/cli/test_medium.py index 26017b415a..3e3b037ba2 100644 --- a/tests/foreman/cli/test_medium.py +++ b/tests/foreman/cli/test_medium.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from fauxfactory import gen_alphanumeric import pytest diff --git a/tests/foreman/cli/test_model.py b/tests/foreman/cli/test_model.py index 8fc51be9f6..f60a6c59fc 100644 --- a/tests/foreman/cli/test_model.py +++ b/tests/foreman/cli/test_model.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from fauxfactory import gen_string import pytest @@ -37,7 +38,7 @@ def class_model(self, target_sat): ('name', 'new_name'), **parametrized( list(zip(valid_data_list().values(), valid_data_list().values(), strict=True)) - ) + ), ) def test_positive_crud_with_name(self, name, new_name, module_target_sat): """Successfully creates, updates and deletes a Model. diff --git a/tests/foreman/cli/test_operatingsystem.py b/tests/foreman/cli/test_operatingsystem.py index 48ed8af809..615ffb9990 100644 --- a/tests/foreman/cli/test_operatingsystem.py +++ b/tests/foreman/cli/test_operatingsystem.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from fauxfactory import gen_alphanumeric, gen_string import pytest diff --git a/tests/foreman/cli/test_organization.py b/tests/foreman/cli/test_organization.py index da79144f14..eded57e07e 100644 --- a/tests/foreman/cli/test_organization.py +++ b/tests/foreman/cli/test_organization.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from fauxfactory import gen_string import pytest diff --git a/tests/foreman/cli/test_oscap.py b/tests/foreman/cli/test_oscap.py index 588fd2371f..ea0f15318a 100644 --- a/tests/foreman/cli/test_oscap.py +++ b/tests/foreman/cli/test_oscap.py @@ -11,6 +11,7 @@ :CaseAutomation: Automated """ + from fauxfactory import gen_string from nailgun import entities import pytest diff --git a/tests/foreman/cli/test_oscap_tailoringfiles.py b/tests/foreman/cli/test_oscap_tailoringfiles.py index e95cfb2891..127ba051e4 100644 --- a/tests/foreman/cli/test_oscap_tailoringfiles.py +++ b/tests/foreman/cli/test_oscap_tailoringfiles.py @@ -11,6 +11,7 @@ :CaseAutomation: Automated """ + from fauxfactory import gen_string import pytest @@ -185,7 +186,6 @@ def test_negative_associate_tailoring_file_with_different_scap(self): @pytest.mark.skip_if_open("BZ:1857572") @pytest.mark.tier2 def test_positive_download_tailoring_file(self, tailoring_file_path, target_sat): - """Download the tailoring file from satellite :id: 75d8c810-19a7-4285-bc3a-a1fb1a0e9088 diff --git a/tests/foreman/cli/test_ostreebranch.py b/tests/foreman/cli/test_ostreebranch.py index d768b3f2d7..0d885528a0 100644 --- a/tests/foreman/cli/test_ostreebranch.py +++ b/tests/foreman/cli/test_ostreebranch.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import random from nailgun import entities diff --git a/tests/foreman/cli/test_partitiontable.py b/tests/foreman/cli/test_partitiontable.py index 51764ac8f0..e89af27e16 100644 --- a/tests/foreman/cli/test_partitiontable.py +++ b/tests/foreman/cli/test_partitiontable.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from random import randint from fauxfactory import gen_string diff --git a/tests/foreman/cli/test_ping.py b/tests/foreman/cli/test_ping.py index 1036b3c5fd..0d6b6929c2 100644 --- a/tests/foreman/cli/test_ping.py +++ b/tests/foreman/cli/test_ping.py @@ -11,6 +11,7 @@ :CaseImportance: Critical """ + import pytest pytestmark = [pytest.mark.tier1, pytest.mark.upgrade] diff --git a/tests/foreman/cli/test_product.py b/tests/foreman/cli/test_product.py index 3d413209db..ec81348a85 100644 --- a/tests/foreman/cli/test_product.py +++ b/tests/foreman/cli/test_product.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from fauxfactory import gen_alphanumeric, gen_integer, gen_string, gen_url import pytest diff --git a/tests/foreman/cli/test_provisioning.py b/tests/foreman/cli/test_provisioning.py index 1c7799edc5..21f937dac2 100644 --- a/tests/foreman/cli/test_provisioning.py +++ b/tests/foreman/cli/test_provisioning.py @@ -11,6 +11,7 @@ :CaseImportance: Critical """ + import pytest diff --git a/tests/foreman/cli/test_provisioningtemplate.py b/tests/foreman/cli/test_provisioningtemplate.py index 59aabc2d2c..a27b6fe534 100644 --- a/tests/foreman/cli/test_provisioningtemplate.py +++ b/tests/foreman/cli/test_provisioningtemplate.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import random from random import randint diff --git a/tests/foreman/cli/test_puppetclass.py b/tests/foreman/cli/test_puppetclass.py index 3a8b50856b..a3dcd8837f 100644 --- a/tests/foreman/cli/test_puppetclass.py +++ b/tests/foreman/cli/test_puppetclass.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest from robottelo.config import settings diff --git a/tests/foreman/cli/test_realm.py b/tests/foreman/cli/test_realm.py index e6480abd3a..7250fb4f0c 100644 --- a/tests/foreman/cli/test_realm.py +++ b/tests/foreman/cli/test_realm.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import random from fauxfactory import gen_string diff --git a/tests/foreman/cli/test_registration.py b/tests/foreman/cli/test_registration.py index 0d2c648831..adf275eb06 100644 --- a/tests/foreman/cli/test_registration.py +++ b/tests/foreman/cli/test_registration.py @@ -11,6 +11,7 @@ :Team: Rocket """ + import json import re from tempfile import mkstemp diff --git a/tests/foreman/cli/test_remoteexecution.py b/tests/foreman/cli/test_remoteexecution.py index 8667b6aae3..fc14a5daa6 100644 --- a/tests/foreman/cli/test_remoteexecution.py +++ b/tests/foreman/cli/test_remoteexecution.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from calendar import monthrange from datetime import datetime, timedelta import random diff --git a/tests/foreman/cli/test_report.py b/tests/foreman/cli/test_report.py index ea4f14371b..588346f943 100644 --- a/tests/foreman/cli/test_report.py +++ b/tests/foreman/cli/test_report.py @@ -11,6 +11,7 @@ :CaseImportance: Critical """ + import random import pytest diff --git a/tests/foreman/cli/test_reporttemplates.py b/tests/foreman/cli/test_reporttemplates.py index 9c9bcf0e5a..b1a92d6704 100644 --- a/tests/foreman/cli/test_reporttemplates.py +++ b/tests/foreman/cli/test_reporttemplates.py @@ -10,6 +10,7 @@ :CaseImportance: High """ + from broker import Broker from fauxfactory import gen_alpha import pytest diff --git a/tests/foreman/cli/test_repositories.py b/tests/foreman/cli/test_repositories.py index fdbe9948b0..f7f4fdafdb 100644 --- a/tests/foreman/cli/test_repositories.py +++ b/tests/foreman/cli/test_repositories.py @@ -11,6 +11,7 @@ :CaseImportance: Critical """ + import pytest from requests.exceptions import HTTPError diff --git a/tests/foreman/cli/test_repository.py b/tests/foreman/cli/test_repository.py index 6d612029d1..9d3bad4046 100644 --- a/tests/foreman/cli/test_repository.py +++ b/tests/foreman/cli/test_repository.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from random import choice from string import punctuation diff --git a/tests/foreman/cli/test_repository_set.py b/tests/foreman/cli/test_repository_set.py index 092034c6dc..71d7d09149 100644 --- a/tests/foreman/cli/test_repository_set.py +++ b/tests/foreman/cli/test_repository_set.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest from robottelo.constants import PRDS, REPOSET diff --git a/tests/foreman/cli/test_rhcloud_inventory.py b/tests/foreman/cli/test_rhcloud_inventory.py index ed84fd465d..d8fbb53adb 100644 --- a/tests/foreman/cli/test_rhcloud_inventory.py +++ b/tests/foreman/cli/test_rhcloud_inventory.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from datetime import datetime import time diff --git a/tests/foreman/cli/test_role.py b/tests/foreman/cli/test_role.py index 7ccdafdf4f..6e16e0f075 100644 --- a/tests/foreman/cli/test_role.py +++ b/tests/foreman/cli/test_role.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from math import ceil from random import choice import re diff --git a/tests/foreman/cli/test_satellitesync.py b/tests/foreman/cli/test_satellitesync.py index 09ff7391a2..2884fbfea4 100644 --- a/tests/foreman/cli/test_satellitesync.py +++ b/tests/foreman/cli/test_satellitesync.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import os from time import sleep diff --git a/tests/foreman/cli/test_settings.py b/tests/foreman/cli/test_settings.py index fdd005e02e..3c8f37461c 100644 --- a/tests/foreman/cli/test_settings.py +++ b/tests/foreman/cli/test_settings.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import random from time import sleep diff --git a/tests/foreman/cli/test_sso.py b/tests/foreman/cli/test_sso.py index 949e021ff4..e24b847ed7 100644 --- a/tests/foreman/cli/test_sso.py +++ b/tests/foreman/cli/test_sso.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest pytestmark = [pytest.mark.stubbed, pytest.mark.upgrade] diff --git a/tests/foreman/cli/test_subnet.py b/tests/foreman/cli/test_subnet.py index 74a6e1727f..c7daca3bb2 100644 --- a/tests/foreman/cli/test_subnet.py +++ b/tests/foreman/cli/test_subnet.py @@ -11,6 +11,7 @@ :CaseImportance: Medium """ + import random import re diff --git a/tests/foreman/cli/test_subscription.py b/tests/foreman/cli/test_subscription.py index c28ba08e61..bb48c6148f 100644 --- a/tests/foreman/cli/test_subscription.py +++ b/tests/foreman/cli/test_subscription.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from fauxfactory import gen_string from manifester import Manifester from nailgun import entities diff --git a/tests/foreman/cli/test_syncplan.py b/tests/foreman/cli/test_syncplan.py index 129686447f..eecf7c5f37 100644 --- a/tests/foreman/cli/test_syncplan.py +++ b/tests/foreman/cli/test_syncplan.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from datetime import datetime, timedelta from time import sleep diff --git a/tests/foreman/cli/test_templatesync.py b/tests/foreman/cli/test_templatesync.py index b0cc31b200..4d8aa85037 100644 --- a/tests/foreman/cli/test_templatesync.py +++ b/tests/foreman/cli/test_templatesync.py @@ -9,6 +9,7 @@ :Team: Endeavour """ + import base64 from fauxfactory import gen_string diff --git a/tests/foreman/cli/test_user.py b/tests/foreman/cli/test_user.py index 3646e301db..8b9c2b9714 100644 --- a/tests/foreman/cli/test_user.py +++ b/tests/foreman/cli/test_user.py @@ -17,6 +17,7 @@ :CaseImportance: High """ + import datetime import random from time import sleep diff --git a/tests/foreman/cli/test_usergroup.py b/tests/foreman/cli/test_usergroup.py index 1c757b4e76..5ad9106a6f 100644 --- a/tests/foreman/cli/test_usergroup.py +++ b/tests/foreman/cli/test_usergroup.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import random import pytest diff --git a/tests/foreman/cli/test_vm_install_products_package.py b/tests/foreman/cli/test_vm_install_products_package.py index eb5a38a09f..3443efb2bc 100644 --- a/tests/foreman/cli/test_vm_install_products_package.py +++ b/tests/foreman/cli/test_vm_install_products_package.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from broker import Broker import pytest diff --git a/tests/foreman/cli/test_webhook.py b/tests/foreman/cli/test_webhook.py index 2849b6aa57..b981f01f8b 100644 --- a/tests/foreman/cli/test_webhook.py +++ b/tests/foreman/cli/test_webhook.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from functools import partial from random import choice diff --git a/tests/foreman/destructive/test_ansible.py b/tests/foreman/destructive/test_ansible.py index b57ba89c58..28f6e93209 100644 --- a/tests/foreman/destructive/test_ansible.py +++ b/tests/foreman/destructive/test_ansible.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest pytestmark = [pytest.mark.destructive, pytest.mark.upgrade] diff --git a/tests/foreman/destructive/test_auth.py b/tests/foreman/destructive/test_auth.py index 06a5909743..cf218def68 100644 --- a/tests/foreman/destructive/test_auth.py +++ b/tests/foreman/destructive/test_auth.py @@ -11,6 +11,7 @@ :CaseImportance: Critical """ + from fauxfactory import gen_string import pytest diff --git a/tests/foreman/destructive/test_capsule.py b/tests/foreman/destructive/test_capsule.py index 1cc63f4fbb..9d3ce22b42 100644 --- a/tests/foreman/destructive/test_capsule.py +++ b/tests/foreman/destructive/test_capsule.py @@ -11,6 +11,7 @@ :CaseImportance: Critical """ + from fauxfactory import gen_string import pytest diff --git a/tests/foreman/destructive/test_capsule_loadbalancer.py b/tests/foreman/destructive/test_capsule_loadbalancer.py index cf36aac8a9..f9b3bbbf8d 100644 --- a/tests/foreman/destructive/test_capsule_loadbalancer.py +++ b/tests/foreman/destructive/test_capsule_loadbalancer.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest from wrapanapi import VmState diff --git a/tests/foreman/destructive/test_capsulecontent.py b/tests/foreman/destructive/test_capsulecontent.py index d060ae29c7..16240f6546 100644 --- a/tests/foreman/destructive/test_capsulecontent.py +++ b/tests/foreman/destructive/test_capsulecontent.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from box import Box from fauxfactory import gen_alpha import pytest diff --git a/tests/foreman/destructive/test_clone.py b/tests/foreman/destructive/test_clone.py index 1ad4cd25f2..e435f3fbfc 100644 --- a/tests/foreman/destructive/test_clone.py +++ b/tests/foreman/destructive/test_clone.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest from robottelo import constants diff --git a/tests/foreman/destructive/test_contenthost.py b/tests/foreman/destructive/test_contenthost.py index c098f86c06..23f8ea7100 100644 --- a/tests/foreman/destructive/test_contenthost.py +++ b/tests/foreman/destructive/test_contenthost.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest from robottelo.config import settings diff --git a/tests/foreman/destructive/test_contentview.py b/tests/foreman/destructive/test_contentview.py index d6b39f7556..6e7f48d8fc 100644 --- a/tests/foreman/destructive/test_contentview.py +++ b/tests/foreman/destructive/test_contentview.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import random from time import sleep diff --git a/tests/foreman/destructive/test_discoveredhost.py b/tests/foreman/destructive/test_discoveredhost.py index 8034957ec7..86568230e0 100644 --- a/tests/foreman/destructive/test_discoveredhost.py +++ b/tests/foreman/destructive/test_discoveredhost.py @@ -9,6 +9,7 @@ :CaseAutomation: Automated """ + from copy import copy import re diff --git a/tests/foreman/destructive/test_foreman_rake.py b/tests/foreman/destructive/test_foreman_rake.py index 5162fa94be..1cbc67a7b2 100644 --- a/tests/foreman/destructive/test_foreman_rake.py +++ b/tests/foreman/destructive/test_foreman_rake.py @@ -11,6 +11,7 @@ :Team: Endeavour """ + import pytest pytestmark = pytest.mark.destructive diff --git a/tests/foreman/destructive/test_foreman_service.py b/tests/foreman/destructive/test_foreman_service.py index 6d0d24de11..fc033cd296 100644 --- a/tests/foreman/destructive/test_foreman_service.py +++ b/tests/foreman/destructive/test_foreman_service.py @@ -7,6 +7,7 @@ :CaseImportance: Medium """ + import pytest from robottelo.constants import DEFAULT_ORG diff --git a/tests/foreman/destructive/test_host.py b/tests/foreman/destructive/test_host.py index bab00e5aca..4a8ae350f3 100644 --- a/tests/foreman/destructive/test_host.py +++ b/tests/foreman/destructive/test_host.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from airgun.exceptions import NoSuchElementException import pytest diff --git a/tests/foreman/destructive/test_infoblox.py b/tests/foreman/destructive/test_infoblox.py index cb3aad76c7..e3e7c3409c 100644 --- a/tests/foreman/destructive/test_infoblox.py +++ b/tests/foreman/destructive/test_infoblox.py @@ -9,6 +9,7 @@ :CaseImportance: High """ + from fauxfactory import gen_mac, gen_string import pytest import requests diff --git a/tests/foreman/destructive/test_installer.py b/tests/foreman/destructive/test_installer.py index 36776213c1..8c61633fc5 100644 --- a/tests/foreman/destructive/test_installer.py +++ b/tests/foreman/destructive/test_installer.py @@ -11,6 +11,7 @@ :CaseImportance: Critical """ + import random from fauxfactory import gen_domain, gen_string diff --git a/tests/foreman/destructive/test_katello_certs_check.py b/tests/foreman/destructive/test_katello_certs_check.py index ce42047973..2d629e9f38 100644 --- a/tests/foreman/destructive/test_katello_certs_check.py +++ b/tests/foreman/destructive/test_katello_certs_check.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import re import pytest diff --git a/tests/foreman/destructive/test_ldap_authentication.py b/tests/foreman/destructive/test_ldap_authentication.py index 3a8468de3d..050ae241d0 100644 --- a/tests/foreman/destructive/test_ldap_authentication.py +++ b/tests/foreman/destructive/test_ldap_authentication.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import os from time import sleep @@ -196,9 +197,12 @@ def test_positive_create_with_https( assert ldap_source['ldap_server']['name'] == ldap_auth_name assert ldap_source['ldap_server']['host'] == auth_data['ldap_hostname'] assert ldap_source['ldap_server']['port'] == '636' - with module_target_sat.ui_session( - test_name, username, auth_data['ldap_user_passwd'] - ) as ldapsession, pytest.raises(NavigationTriesExceeded): + with ( + module_target_sat.ui_session( + test_name, username, auth_data['ldap_user_passwd'] + ) as ldapsession, + pytest.raises(NavigationTriesExceeded), + ): ldapsession.user.search('') assert module_target_sat.api.User().search(query={'search': f'login="{username}"'}) diff --git a/tests/foreman/destructive/test_ldapauthsource.py b/tests/foreman/destructive/test_ldapauthsource.py index 0cebd78253..1b6aeec270 100644 --- a/tests/foreman/destructive/test_ldapauthsource.py +++ b/tests/foreman/destructive/test_ldapauthsource.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from time import sleep import pytest diff --git a/tests/foreman/destructive/test_leapp_satellite.py b/tests/foreman/destructive/test_leapp_satellite.py index 9022b4fec8..8d673b9464 100644 --- a/tests/foreman/destructive/test_leapp_satellite.py +++ b/tests/foreman/destructive/test_leapp_satellite.py @@ -9,6 +9,7 @@ :CaseImportance: High """ + from broker import Broker import pytest diff --git a/tests/foreman/destructive/test_packages.py b/tests/foreman/destructive/test_packages.py index da9c15f651..c7098c9892 100644 --- a/tests/foreman/destructive/test_packages.py +++ b/tests/foreman/destructive/test_packages.py @@ -11,6 +11,7 @@ :CaseImportance: Critical """ + import re import pytest diff --git a/tests/foreman/destructive/test_ping.py b/tests/foreman/destructive/test_ping.py index 96ae171c8f..145ce663be 100644 --- a/tests/foreman/destructive/test_ping.py +++ b/tests/foreman/destructive/test_ping.py @@ -11,6 +11,7 @@ :CaseImportance: Critical """ + import pytest pytestmark = pytest.mark.destructive diff --git a/tests/foreman/destructive/test_puppetplugin.py b/tests/foreman/destructive/test_puppetplugin.py index 9bd118ac4e..3411f13000 100644 --- a/tests/foreman/destructive/test_puppetplugin.py +++ b/tests/foreman/destructive/test_puppetplugin.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest from robottelo.constants import PUPPET_CAPSULE_INSTALLER, PUPPET_COMMON_INSTALLER_OPTS diff --git a/tests/foreman/destructive/test_realm.py b/tests/foreman/destructive/test_realm.py index cbddcdc3bc..7ee6f51903 100644 --- a/tests/foreman/destructive/test_realm.py +++ b/tests/foreman/destructive/test_realm.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import random from fauxfactory import gen_string diff --git a/tests/foreman/destructive/test_registration.py b/tests/foreman/destructive/test_registration.py index 9c8dbfa492..7b4aae79eb 100644 --- a/tests/foreman/destructive/test_registration.py +++ b/tests/foreman/destructive/test_registration.py @@ -10,6 +10,7 @@ :Team: Rocket """ + import pytest from robottelo.config import settings diff --git a/tests/foreman/destructive/test_remoteexecution.py b/tests/foreman/destructive/test_remoteexecution.py index c9c6bdb8b2..190708153a 100644 --- a/tests/foreman/destructive/test_remoteexecution.py +++ b/tests/foreman/destructive/test_remoteexecution.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from fauxfactory import gen_string from nailgun import client from nailgun.entity_mixins import TaskFailedError diff --git a/tests/foreman/destructive/test_rename.py b/tests/foreman/destructive/test_rename.py index 03fd9ff0d6..8f06cd7a5f 100644 --- a/tests/foreman/destructive/test_rename.py +++ b/tests/foreman/destructive/test_rename.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from fauxfactory import gen_string import pytest diff --git a/tests/foreman/destructive/test_repository.py b/tests/foreman/destructive/test_repository.py index 026134f201..41c380df2a 100644 --- a/tests/foreman/destructive/test_repository.py +++ b/tests/foreman/destructive/test_repository.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from nailgun.entity_mixins import TaskFailedError import pytest diff --git a/tests/foreman/endtoend/test_api_endtoend.py b/tests/foreman/endtoend/test_api_endtoend.py index cede80dfec..57562c6cb9 100644 --- a/tests/foreman/endtoend/test_api_endtoend.py +++ b/tests/foreman/endtoend/test_api_endtoend.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from collections import defaultdict import http from pprint import pformat diff --git a/tests/foreman/endtoend/test_cli_endtoend.py b/tests/foreman/endtoend/test_cli_endtoend.py index dc44d6691f..789b0bf4d1 100644 --- a/tests/foreman/endtoend/test_cli_endtoend.py +++ b/tests/foreman/endtoend/test_cli_endtoend.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from fauxfactory import gen_alphanumeric, gen_ipaddr import pytest diff --git a/tests/foreman/installer/test_infoblox.py b/tests/foreman/installer/test_infoblox.py index 5f839d4e85..b17b3db02a 100644 --- a/tests/foreman/installer/test_infoblox.py +++ b/tests/foreman/installer/test_infoblox.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest diff --git a/tests/foreman/installer/test_installer.py b/tests/foreman/installer/test_installer.py index 696e05f52e..ae8ce8d300 100644 --- a/tests/foreman/installer/test_installer.py +++ b/tests/foreman/installer/test_installer.py @@ -11,6 +11,7 @@ :CaseImportance: Critical """ + import pytest import requests import yaml diff --git a/tests/foreman/longrun/test_inc_updates.py b/tests/foreman/longrun/test_inc_updates.py index 693f9441e4..3f00f09662 100644 --- a/tests/foreman/longrun/test_inc_updates.py +++ b/tests/foreman/longrun/test_inc_updates.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from datetime import datetime, timedelta from nailgun import entities diff --git a/tests/foreman/longrun/test_oscap.py b/tests/foreman/longrun/test_oscap.py index 53777de356..aaaa127a09 100644 --- a/tests/foreman/longrun/test_oscap.py +++ b/tests/foreman/longrun/test_oscap.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from broker import Broker from fauxfactory import gen_string from nailgun import entities diff --git a/tests/foreman/longrun/test_remoteexecution.py b/tests/foreman/longrun/test_remoteexecution.py index abff4966d7..14c75f1cec 100644 --- a/tests/foreman/longrun/test_remoteexecution.py +++ b/tests/foreman/longrun/test_remoteexecution.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest diff --git a/tests/foreman/maintain/test_advanced.py b/tests/foreman/maintain/test_advanced.py index 68b00e5c07..219a22d03d 100644 --- a/tests/foreman/maintain/test_advanced.py +++ b/tests/foreman/maintain/test_advanced.py @@ -11,6 +11,7 @@ :CaseImportance: Critical """ + import pytest import yaml diff --git a/tests/foreman/maintain/test_backup_restore.py b/tests/foreman/maintain/test_backup_restore.py index 4abe8aa039..0ddbfb18b9 100644 --- a/tests/foreman/maintain/test_backup_restore.py +++ b/tests/foreman/maintain/test_backup_restore.py @@ -12,6 +12,7 @@ """ + import re from fauxfactory import gen_string @@ -136,7 +137,7 @@ def test_positive_backup_split_pulp_tar( assert 'FAIL' not in result.stdout # Check for expected files - backup_dir = re.findall(fr'{subdir}\/{instance}-backup-.*-[0-5][0-9]', result.stdout)[0] + backup_dir = re.findall(rf'{subdir}\/{instance}-backup-.*-[0-5][0-9]', result.stdout)[0] files = sat_maintain.execute(f'ls -a {backup_dir}').stdout.split('\n') files = [i for i in files if not re.compile(r'^\.*$').search(i)] @@ -180,7 +181,7 @@ def test_positive_backup_capsule_features( assert 'FAIL' not in result.stdout # Check for expected files - backup_dir = re.findall(fr'{subdir}\/{instance}-backup-.*-[0-5][0-9]', result.stdout)[0] + backup_dir = re.findall(rf'{subdir}\/{instance}-backup-.*-[0-5][0-9]', result.stdout)[0] files = sat_maintain.execute(f'ls -a {backup_dir}').stdout.split('\n') files = [i for i in files if not re.compile(r'^\.*$').search(i)] @@ -215,7 +216,7 @@ def test_positive_backup_all(sat_maintain, setup_backup_tests, module_synced_rep assert result.status == 0 assert 'FAIL' not in result.stdout - init_backup_dir = re.findall(fr'{subdir}\/{instance}-backup-.*-[0-5][0-9]', result.stdout)[0] + init_backup_dir = re.findall(rf'{subdir}\/{instance}-backup-.*-[0-5][0-9]', result.stdout)[0] result = sat_maintain.cli.Backup.run_backup( backup_dir=subdir, @@ -262,7 +263,7 @@ def test_positive_backup_offline_logical(sat_maintain, setup_backup_tests, modul assert 'FAIL' not in result.stdout # Check for expected files - backup_dir = re.findall(fr'{subdir}\/{instance}-backup-.*-[0-5][0-9]', result.stdout)[0] + backup_dir = re.findall(rf'{subdir}\/{instance}-backup-.*-[0-5][0-9]', result.stdout)[0] files = sat_maintain.execute(f'ls -a {backup_dir}').stdout.split('\n') files = [i for i in files if not re.compile(r'^\.*$').search(i)] @@ -402,7 +403,7 @@ def test_positive_puppet_backup_restore( assert 'FAIL' not in result.stdout # Check for expected files - backup_dir = re.findall(fr'{subdir}\/{instance}-backup-.*-[0-5][0-9]', result.stdout)[0] + backup_dir = re.findall(rf'{subdir}\/{instance}-backup-.*-[0-5][0-9]', result.stdout)[0] files = sat_maintain.execute(f'ls -a {backup_dir}').stdout.split('\n') files = [i for i in files if not re.compile(r'^\.*$').search(i)] @@ -488,7 +489,7 @@ def test_positive_backup_restore( assert 'FAIL' not in result.stdout # Check for expected files - backup_dir = re.findall(fr'{subdir}\/{instance}-backup-.*-[0-5][0-9]', result.stdout)[0] + backup_dir = re.findall(rf'{subdir}\/{instance}-backup-.*-[0-5][0-9]', result.stdout)[0] files = sat_maintain.execute(f'ls -a {backup_dir}').stdout.split('\n') files = [i for i in files if not re.compile(r'^\.*$').search(i)] @@ -572,7 +573,7 @@ def test_positive_backup_restore_incremental( assert result.status == 0 assert 'FAIL' not in result.stdout - init_backup_dir = re.findall(fr'{subdir}\/satellite-backup-.*-[0-5][0-9]', result.stdout)[0] + init_backup_dir = re.findall(rf'{subdir}\/satellite-backup-.*-[0-5][0-9]', result.stdout)[0] # create additional content secondary_repo = sat_maintain.api.Repository( @@ -591,7 +592,7 @@ def test_positive_backup_restore_incremental( assert 'FAIL' not in result.stdout # check for expected files - inc_backup_dir = re.findall(fr'{subdir}\/satellite-backup-.*-[0-5][0-9]', result.stdout)[0] + inc_backup_dir = re.findall(rf'{subdir}\/satellite-backup-.*-[0-5][0-9]', result.stdout)[0] files = sat_maintain.execute(f'ls -a {inc_backup_dir}').stdout.split('\n') files = [i for i in files if not re.compile(r'^\.*$').search(i)] diff --git a/tests/foreman/maintain/test_health.py b/tests/foreman/maintain/test_health.py index 9ba117f72c..b5bb4e6f51 100644 --- a/tests/foreman/maintain/test_health.py +++ b/tests/foreman/maintain/test_health.py @@ -11,6 +11,7 @@ :CaseImportance: Critical """ + import time from fauxfactory import gen_string diff --git a/tests/foreman/maintain/test_maintenance_mode.py b/tests/foreman/maintain/test_maintenance_mode.py index b8d5024e1b..a405371d51 100644 --- a/tests/foreman/maintain/test_maintenance_mode.py +++ b/tests/foreman/maintain/test_maintenance_mode.py @@ -11,6 +11,7 @@ :CaseImportance: Critical """ + import pytest import yaml diff --git a/tests/foreman/maintain/test_offload_DB.py b/tests/foreman/maintain/test_offload_DB.py index 0e1b3ced9d..3c069658f9 100644 --- a/tests/foreman/maintain/test_offload_DB.py +++ b/tests/foreman/maintain/test_offload_DB.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest from robottelo.config import settings diff --git a/tests/foreman/maintain/test_packages.py b/tests/foreman/maintain/test_packages.py index f0ae22d6d1..90483a6971 100644 --- a/tests/foreman/maintain/test_packages.py +++ b/tests/foreman/maintain/test_packages.py @@ -11,6 +11,7 @@ :CaseImportance: Critical """ + import pytest from robottelo.config import settings diff --git a/tests/foreman/maintain/test_service.py b/tests/foreman/maintain/test_service.py index 3ff3379005..e35a55d9e0 100644 --- a/tests/foreman/maintain/test_service.py +++ b/tests/foreman/maintain/test_service.py @@ -11,6 +11,7 @@ :CaseImportance: Critical """ + from fauxfactory import gen_string import pytest from wait_for import wait_for diff --git a/tests/foreman/maintain/test_upgrade.py b/tests/foreman/maintain/test_upgrade.py index 2a0f1a28ca..4f17592629 100644 --- a/tests/foreman/maintain/test_upgrade.py +++ b/tests/foreman/maintain/test_upgrade.py @@ -11,6 +11,7 @@ :CaseImportance: Critical """ + import pytest from robottelo.config import settings diff --git a/tests/foreman/sanity/test_bvt.py b/tests/foreman/sanity/test_bvt.py index 7da1ccc3d8..9c37152fa3 100644 --- a/tests/foreman/sanity/test_bvt.py +++ b/tests/foreman/sanity/test_bvt.py @@ -11,6 +11,7 @@ :CaseImportance: Critical """ + import re import pytest diff --git a/tests/foreman/sys/test_dynflow.py b/tests/foreman/sys/test_dynflow.py index 2b758bcb20..c93f3475d2 100644 --- a/tests/foreman/sys/test_dynflow.py +++ b/tests/foreman/sys/test_dynflow.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest diff --git a/tests/foreman/sys/test_fam.py b/tests/foreman/sys/test_fam.py index f4500a2b59..e4675d4f58 100644 --- a/tests/foreman/sys/test_fam.py +++ b/tests/foreman/sys/test_fam.py @@ -11,6 +11,7 @@ :Team: Platform """ + from broker import Broker import pytest diff --git a/tests/foreman/sys/test_katello_certs_check.py b/tests/foreman/sys/test_katello_certs_check.py index 4c4906e392..523567e1c0 100644 --- a/tests/foreman/sys/test_katello_certs_check.py +++ b/tests/foreman/sys/test_katello_certs_check.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import re import pytest diff --git a/tests/foreman/sys/test_pulp3_filesystem.py b/tests/foreman/sys/test_pulp3_filesystem.py index ac747ca5f1..a0ab51630a 100644 --- a/tests/foreman/sys/test_pulp3_filesystem.py +++ b/tests/foreman/sys/test_pulp3_filesystem.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from datetime import datetime import json diff --git a/tests/foreman/sys/test_webpack.py b/tests/foreman/sys/test_webpack.py index c71e9016e9..df08627d29 100644 --- a/tests/foreman/sys/test_webpack.py +++ b/tests/foreman/sys/test_webpack.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest diff --git a/tests/foreman/ui/test_acs.py b/tests/foreman/ui/test_acs.py index 40da1c2200..da5a3c144e 100644 --- a/tests/foreman/ui/test_acs.py +++ b/tests/foreman/ui/test_acs.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest from robottelo import constants diff --git a/tests/foreman/ui/test_activationkey.py b/tests/foreman/ui/test_activationkey.py index 7630a1761b..98cf3cffa4 100644 --- a/tests/foreman/ui/test_activationkey.py +++ b/tests/foreman/ui/test_activationkey.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import random from broker import Broker diff --git a/tests/foreman/ui/test_ansible.py b/tests/foreman/ui/test_ansible.py index c538ef099e..4a9b416256 100644 --- a/tests/foreman/ui/test_ansible.py +++ b/tests/foreman/ui/test_ansible.py @@ -8,6 +8,7 @@ :CaseImportance: Critical """ + from fauxfactory import gen_string import pytest from wait_for import wait_for @@ -182,7 +183,7 @@ def _finalize(): result = rhel_contenthost.execute(command) assert result.status == 0, f'Failed to register host: {result.stderr}' target_host = rhel_contenthost.nailgun_host - default_value = '[\"test\"]' + default_value = '[\"test\"]' # fmt: skip parameter_type = 'array' with target_sat.ui_session() as session: session.organization.select(org_name=module_org.name) diff --git a/tests/foreman/ui/test_architecture.py b/tests/foreman/ui/test_architecture.py index e6448f4442..54dc1be1f9 100644 --- a/tests/foreman/ui/test_architecture.py +++ b/tests/foreman/ui/test_architecture.py @@ -11,6 +11,7 @@ :CaseImportance: Low """ + from fauxfactory import gen_string import pytest diff --git a/tests/foreman/ui/test_audit.py b/tests/foreman/ui/test_audit.py index b7d0ce6344..9c5cc17250 100644 --- a/tests/foreman/ui/test_audit.py +++ b/tests/foreman/ui/test_audit.py @@ -9,6 +9,7 @@ :Team: Endeavour """ + from fauxfactory import gen_string import pytest diff --git a/tests/foreman/ui/test_bookmarks.py b/tests/foreman/ui/test_bookmarks.py index 096f8fdf7c..0670563ab6 100644 --- a/tests/foreman/ui/test_bookmarks.py +++ b/tests/foreman/ui/test_bookmarks.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from airgun.exceptions import DisabledWidgetError, NoSuchElementException from fauxfactory import gen_string import pytest diff --git a/tests/foreman/ui/test_branding.py b/tests/foreman/ui/test_branding.py index 8fe30b1c2e..0929285af1 100644 --- a/tests/foreman/ui/test_branding.py +++ b/tests/foreman/ui/test_branding.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest diff --git a/tests/foreman/ui/test_capsulecontent.py b/tests/foreman/ui/test_capsulecontent.py index 43fc34b430..53d08b6841 100644 --- a/tests/foreman/ui/test_capsulecontent.py +++ b/tests/foreman/ui/test_capsulecontent.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest from robottelo.config import settings diff --git a/tests/foreman/ui/test_computeprofiles.py b/tests/foreman/ui/test_computeprofiles.py index dfe73935f3..0f0cb99c1e 100644 --- a/tests/foreman/ui/test_computeprofiles.py +++ b/tests/foreman/ui/test_computeprofiles.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from fauxfactory import gen_string import pytest diff --git a/tests/foreman/ui/test_computeresource.py b/tests/foreman/ui/test_computeresource.py index abbc088aa4..b39cc00e3a 100644 --- a/tests/foreman/ui/test_computeresource.py +++ b/tests/foreman/ui/test_computeresource.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest from wait_for import wait_for @@ -288,7 +289,6 @@ def test_positive_VM_import(session, module_org, module_location, rhev_data, mod name = gen_string('alpha') with session: - session.computeresource.create( { 'name': name, diff --git a/tests/foreman/ui/test_computeresource_azurerm.py b/tests/foreman/ui/test_computeresource_azurerm.py index 36228513ff..5d09ad88a6 100644 --- a/tests/foreman/ui/test_computeresource_azurerm.py +++ b/tests/foreman/ui/test_computeresource_azurerm.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from fauxfactory import gen_string import pytest diff --git a/tests/foreman/ui/test_computeresource_ec2.py b/tests/foreman/ui/test_computeresource_ec2.py index 0d08685543..1dae4eb749 100644 --- a/tests/foreman/ui/test_computeresource_ec2.py +++ b/tests/foreman/ui/test_computeresource_ec2.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from fauxfactory import gen_string import pytest diff --git a/tests/foreman/ui/test_computeresource_gce.py b/tests/foreman/ui/test_computeresource_gce.py index a25edb1da4..4c48e90280 100644 --- a/tests/foreman/ui/test_computeresource_gce.py +++ b/tests/foreman/ui/test_computeresource_gce.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import json import random diff --git a/tests/foreman/ui/test_computeresource_libvirt.py b/tests/foreman/ui/test_computeresource_libvirt.py index 42477b8d46..8328f1a4cf 100644 --- a/tests/foreman/ui/test_computeresource_libvirt.py +++ b/tests/foreman/ui/test_computeresource_libvirt.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from random import choice from fauxfactory import gen_string diff --git a/tests/foreman/ui/test_computeresource_vmware.py b/tests/foreman/ui/test_computeresource_vmware.py index 4c9516e9cd..881ca3c8ea 100644 --- a/tests/foreman/ui/test_computeresource_vmware.py +++ b/tests/foreman/ui/test_computeresource_vmware.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from math import floor, log10 from random import choice diff --git a/tests/foreman/ui/test_config_group.py b/tests/foreman/ui/test_config_group.py index b38384d297..34e6b32b9c 100644 --- a/tests/foreman/ui/test_config_group.py +++ b/tests/foreman/ui/test_config_group.py @@ -11,6 +11,7 @@ :CaseImportance: Low """ + from fauxfactory import gen_string import pytest diff --git a/tests/foreman/ui/test_containerimagetag.py b/tests/foreman/ui/test_containerimagetag.py index 41f8960d96..9d8892e67b 100644 --- a/tests/foreman/ui/test_containerimagetag.py +++ b/tests/foreman/ui/test_containerimagetag.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest from robottelo.constants import ( diff --git a/tests/foreman/ui/test_contentcredentials.py b/tests/foreman/ui/test_contentcredentials.py index 4fa3f51998..42be72d12e 100644 --- a/tests/foreman/ui/test_contentcredentials.py +++ b/tests/foreman/ui/test_contentcredentials.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest from robottelo.config import settings diff --git a/tests/foreman/ui/test_contenthost.py b/tests/foreman/ui/test_contenthost.py index 5f351076e5..fc4071412b 100644 --- a/tests/foreman/ui/test_contenthost.py +++ b/tests/foreman/ui/test_contenthost.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from datetime import datetime, timedelta import re from urllib.parse import urlparse @@ -1773,7 +1774,7 @@ def test_pagination_multiple_hosts_multiple_pages(session, module_host_template, f'os = {module_host_template.operatingsystem.name}' ) # Assert dump of fake hosts found includes the higest numbered host created for this test - match = re.search(fr'test-{host_num:0>2}', str(all_fake_hosts_found)) + match = re.search(rf'test-{host_num:0>2}', str(all_fake_hosts_found)) assert match, 'Highest numbered host not found.' # Get all the pagination values pagination_values = session.contenthost.read_all('Pagination')['Pagination'] @@ -1811,8 +1812,8 @@ def test_search_for_virt_who_hypervisors(session, default_location, module_targe hypervisor_display_name = f'virt-who-{hypervisor_name}-{org.id}' # Search with hypervisor=True gives the correct result. assert ( - session.contenthost.search('hypervisor = true')[0]['Name'] - ) == hypervisor_display_name + (session.contenthost.search('hypervisor = true')[0]['Name']) == hypervisor_display_name + ) # Search with hypervisor=false gives the correct result. content_hosts = [host['Name'] for host in session.contenthost.search('hypervisor = false')] assert hypervisor_display_name not in content_hosts diff --git a/tests/foreman/ui/test_contentview.py b/tests/foreman/ui/test_contentview.py index 625d5fb927..0d203fc770 100644 --- a/tests/foreman/ui/test_contentview.py +++ b/tests/foreman/ui/test_contentview.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from fauxfactory import gen_string import pytest diff --git a/tests/foreman/ui/test_contentview_old.py b/tests/foreman/ui/test_contentview_old.py index 0bff1edfb8..ce20ed0aec 100644 --- a/tests/foreman/ui/test_contentview_old.py +++ b/tests/foreman/ui/test_contentview_old.py @@ -14,6 +14,7 @@ :CaseImportance: High """ + import datetime from random import randint diff --git a/tests/foreman/ui/test_dashboard.py b/tests/foreman/ui/test_dashboard.py index 9788e1c6f3..071e44cc4d 100644 --- a/tests/foreman/ui/test_dashboard.py +++ b/tests/foreman/ui/test_dashboard.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from nailgun.entity_mixins import TaskFailedError import pytest @@ -52,14 +53,14 @@ def test_positive_host_configuration_status(session, target_sat): 'Hosts with no reports', ] search_strings_list = [ - 'last_report > \"30 minutes ago\" and (status.applied > 0 or' + 'last_report > "30 minutes ago" and (status.applied > 0 or' ' status.restarted > 0) and (status.failed = 0)', - 'last_report > \"30 minutes ago\" and (status.failed > 0 or' + 'last_report > "30 minutes ago" and (status.failed > 0 or' ' status.failed_restarts > 0) and status.enabled = true', - 'last_report > \"30 minutes ago\" and status.enabled = true and' + 'last_report > "30 minutes ago" and status.enabled = true and' ' status.applied = 0 and status.failed = 0 and status.pending = 0', - 'last_report > \"30 minutes ago\" and status.pending > 0 and status.enabled = true', - 'last_report < \"30 minutes ago\" and status.enabled = true', + 'last_report > "30 minutes ago" and status.pending > 0 and status.enabled = true', + 'last_report < "30 minutes ago" and status.enabled = true', 'status.enabled = false', 'not has last_report and status.enabled = true', ] diff --git a/tests/foreman/ui/test_discoveredhost.py b/tests/foreman/ui/test_discoveredhost.py index 64476188f8..82fbdf5ca9 100644 --- a/tests/foreman/ui/test_discoveredhost.py +++ b/tests/foreman/ui/test_discoveredhost.py @@ -9,6 +9,7 @@ :Team: Rocket """ + from fauxfactory import gen_string import pytest from wait_for import wait_for diff --git a/tests/foreman/ui/test_discoveryrule.py b/tests/foreman/ui/test_discoveryrule.py index 83ab23cbcc..85958d57e5 100644 --- a/tests/foreman/ui/test_discoveryrule.py +++ b/tests/foreman/ui/test_discoveryrule.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from fauxfactory import gen_integer, gen_ipaddr, gen_string import pytest diff --git a/tests/foreman/ui/test_domain.py b/tests/foreman/ui/test_domain.py index 4a116f762f..51a8a048c5 100644 --- a/tests/foreman/ui/test_domain.py +++ b/tests/foreman/ui/test_domain.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from fauxfactory import gen_string import pytest diff --git a/tests/foreman/ui/test_eol_banner.py b/tests/foreman/ui/test_eol_banner.py index c19b19838e..cc3c46eadf 100644 --- a/tests/foreman/ui/test_eol_banner.py +++ b/tests/foreman/ui/test_eol_banner.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from datetime import datetime, timedelta from airgun.session import Session diff --git a/tests/foreman/ui/test_errata.py b/tests/foreman/ui/test_errata.py index 612f92786a..ba5c9b27ab 100644 --- a/tests/foreman/ui/test_errata.py +++ b/tests/foreman/ui/test_errata.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from datetime import datetime, timedelta from broker import Broker @@ -163,10 +164,7 @@ def cv_publish_promote(sat, org, cv, lce=None, needs_publish=True): # Take a single instance of lce, or list of instances lce_ids = 'Library' if lce is not None: - if not isinstance(lce, list): - lce_ids = [lce.id] - else: - lce_ids = sorted(_lce.id for _lce in lce) + lce_ids = [lce.id] if not isinstance(lce, list) else sorted(_lce.id for _lce in lce) if needs_publish is True: _publish_and_wait(sat, org, cv) @@ -198,13 +196,16 @@ def _publish_and_wait(sat, org, cv): task_id = sat.api.ContentView(id=cv.id).publish({'id': cv.id, 'organization': org})['id'] assert task_id, f'No task was invoked to publish the Content-View: {cv.id}.' # Should take < 1 minute, check in 5s intervals - sat.wait_for_tasks( - search_query=(f'label = Actions::Katello::ContentView::Publish and id = {task_id}'), - search_rate=5, - max_tries=12, - ), ( - f'Failed to publish the Content-View: {cv.id}, in time.' - f'Task: {task_id} failed, or timed out (60s).' + ( + sat.wait_for_tasks( + search_query=(f'label = Actions::Katello::ContentView::Publish and id = {task_id}'), + search_rate=5, + max_tries=12, + ), + ( + f'Failed to publish the Content-View: {cv.id}, in time.' + f'Task: {task_id} failed, or timed out (60s).' + ), ) @@ -298,7 +299,14 @@ def registered_contenthost( @request.addfinalizer # Cleanup for in-between parameterized sessions def cleanup(): - nonlocal rhel_contenthost, module_cv, module_lce, custom_repos, custom_products, errata_host_ak, module_sca_manifest_org + nonlocal \ + rhel_contenthost, \ + module_cv, \ + module_lce, \ + custom_repos, \ + custom_products, \ + errata_host_ak, \ + module_sca_manifest_org rhel_contenthost.unregister() errata_host_ak.delete() # find any other aks and delete them diff --git a/tests/foreman/ui/test_hardwaremodel.py b/tests/foreman/ui/test_hardwaremodel.py index c2733d17d3..262bb567ce 100644 --- a/tests/foreman/ui/test_hardwaremodel.py +++ b/tests/foreman/ui/test_hardwaremodel.py @@ -9,6 +9,7 @@ :Team: Endeavour """ + from fauxfactory import gen_string import pytest diff --git a/tests/foreman/ui/test_host.py b/tests/foreman/ui/test_host.py index 0869a68290..a767c85f78 100644 --- a/tests/foreman/ui/test_host.py +++ b/tests/foreman/ui/test_host.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import copy import csv import os diff --git a/tests/foreman/ui/test_hostcollection.py b/tests/foreman/ui/test_hostcollection.py index 91c76c5536..49ea829f4b 100644 --- a/tests/foreman/ui/test_hostcollection.py +++ b/tests/foreman/ui/test_hostcollection.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import time from broker import Broker diff --git a/tests/foreman/ui/test_hostgroup.py b/tests/foreman/ui/test_hostgroup.py index 46d167194f..3a7c8aeb58 100644 --- a/tests/foreman/ui/test_hostgroup.py +++ b/tests/foreman/ui/test_hostgroup.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from fauxfactory import gen_string import pytest diff --git a/tests/foreman/ui/test_http_proxy.py b/tests/foreman/ui/test_http_proxy.py index 10d2249be3..625b4c6af3 100644 --- a/tests/foreman/ui/test_http_proxy.py +++ b/tests/foreman/ui/test_http_proxy.py @@ -11,6 +11,7 @@ :CaseAutomation: Automated """ + from box import Box from fauxfactory import gen_integer, gen_string, gen_url import pytest diff --git a/tests/foreman/ui/test_jobtemplate.py b/tests/foreman/ui/test_jobtemplate.py index e2be74da64..c4ad3fa6cc 100644 --- a/tests/foreman/ui/test_jobtemplate.py +++ b/tests/foreman/ui/test_jobtemplate.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from fauxfactory import gen_string import pytest diff --git a/tests/foreman/ui/test_ldap_authentication.py b/tests/foreman/ui/test_ldap_authentication.py index 554244957f..0fec6fba27 100644 --- a/tests/foreman/ui/test_ldap_authentication.py +++ b/tests/foreman/ui/test_ldap_authentication.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import os from fauxfactory import gen_url @@ -404,9 +405,12 @@ def test_positive_delete_external_roles( session.usergroup.update( ldap_usergroup_name, {'roles.resources.unassigned': [foreman_role.name]} ) - with target_sat.ui_session( - test_name, ldap_data['ldap_user_name'], ldap_data['ldap_user_passwd'] - ) as ldapsession, pytest.raises(NavigationTriesExceeded): + with ( + target_sat.ui_session( + test_name, ldap_data['ldap_user_name'], ldap_data['ldap_user_passwd'] + ) as ldapsession, + pytest.raises(NavigationTriesExceeded), + ): ldapsession.location.create({'name': gen_string('alpha')}) @@ -758,9 +762,12 @@ def test_positive_login_user_basic_roles( role = target_sat.api.Role().create() permissions = {'Architecture': PERMISSIONS['Architecture']} target_sat.api_factory.create_role_permissions(role, permissions) - with target_sat.ui_session( - test_name, ldap_data['ldap_user_name'], ldap_data['ldap_user_passwd'] - ) as ldapsession, pytest.raises(NavigationTriesExceeded): + with ( + target_sat.ui_session( + test_name, ldap_data['ldap_user_name'], ldap_data['ldap_user_passwd'] + ) as ldapsession, + pytest.raises(NavigationTriesExceeded), + ): ldapsession.usergroup.search('') with session: session.user.update(ldap_data['ldap_user_name'], {'roles.resources.assigned': [role.name]}) @@ -792,9 +799,12 @@ def test_positive_login_user_password_otp( otp_pass = ( f"{default_ipa_host.ldap_user_passwd}{generate_otp(default_ipa_host.time_based_secret)}" ) - with target_sat.ui_session( - test_name, default_ipa_host.ipa_otp_username, otp_pass - ) as ldapsession, pytest.raises(NavigationTriesExceeded): + with ( + target_sat.ui_session( + test_name, default_ipa_host.ipa_otp_username, otp_pass + ) as ldapsession, + pytest.raises(NavigationTriesExceeded), + ): ldapsession.user.search('') users = target_sat.api.User().search( query={'search': f'login="{default_ipa_host.ipa_otp_username}"'} @@ -1210,11 +1220,14 @@ def test_userlist_with_external_admin( assert idm_user in ldapsession.task.read_all()['current_user'] # verify the users count with local admin and remote/external admin - with target_sat.ui_session( - user=idm_admin, password=settings.server.ssh_password - ) as remote_admin_session, target_sat.ui_session( - user=settings.server.admin_username, password=settings.server.admin_password - ) as local_admin_session: + with ( + target_sat.ui_session( + user=idm_admin, password=settings.server.ssh_password + ) as remote_admin_session, + target_sat.ui_session( + user=settings.server.admin_username, password=settings.server.admin_password + ) as local_admin_session, + ): assert local_admin_session.user.search(idm_user)[0]['Username'] == idm_user assert remote_admin_session.user.search(idm_user)[0]['Username'] == idm_user diff --git a/tests/foreman/ui/test_lifecycleenvironment.py b/tests/foreman/ui/test_lifecycleenvironment.py index 9c389fdd19..f3c966bd10 100644 --- a/tests/foreman/ui/test_lifecycleenvironment.py +++ b/tests/foreman/ui/test_lifecycleenvironment.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from navmazing import NavigationTriesExceeded import pytest diff --git a/tests/foreman/ui/test_location.py b/tests/foreman/ui/test_location.py index 2ddb1620b2..123673b669 100644 --- a/tests/foreman/ui/test_location.py +++ b/tests/foreman/ui/test_location.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from fauxfactory import gen_ipaddr, gen_string import pytest diff --git a/tests/foreman/ui/test_media.py b/tests/foreman/ui/test_media.py index 75a39f80ed..5c41ab4067 100644 --- a/tests/foreman/ui/test_media.py +++ b/tests/foreman/ui/test_media.py @@ -11,6 +11,7 @@ :CaseImportance: Low """ + from fauxfactory import gen_string import pytest diff --git a/tests/foreman/ui/test_modulestreams.py b/tests/foreman/ui/test_modulestreams.py index 8bdd808ec6..6d782f1616 100644 --- a/tests/foreman/ui/test_modulestreams.py +++ b/tests/foreman/ui/test_modulestreams.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from fauxfactory import gen_string import pytest diff --git a/tests/foreman/ui/test_operatingsystem.py b/tests/foreman/ui/test_operatingsystem.py index 1324b55623..71a030772c 100644 --- a/tests/foreman/ui/test_operatingsystem.py +++ b/tests/foreman/ui/test_operatingsystem.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest from robottelo.constants import HASH_TYPE diff --git a/tests/foreman/ui/test_organization.py b/tests/foreman/ui/test_organization.py index 7b200391f7..cbbc653208 100644 --- a/tests/foreman/ui/test_organization.py +++ b/tests/foreman/ui/test_organization.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from fauxfactory import gen_string import pytest diff --git a/tests/foreman/ui/test_oscappolicy.py b/tests/foreman/ui/test_oscappolicy.py index bbfc9492c7..7f0e98e001 100644 --- a/tests/foreman/ui/test_oscappolicy.py +++ b/tests/foreman/ui/test_oscappolicy.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest from robottelo.constants import OSCAP_PROFILE diff --git a/tests/foreman/ui/test_oscaptailoringfile.py b/tests/foreman/ui/test_oscaptailoringfile.py index 0145ac250c..346db2c10e 100644 --- a/tests/foreman/ui/test_oscaptailoringfile.py +++ b/tests/foreman/ui/test_oscaptailoringfile.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest from robottelo.utils.datafactory import gen_string diff --git a/tests/foreman/ui/test_package.py b/tests/foreman/ui/test_package.py index 9d6e91a9ab..8dadbfe2d0 100644 --- a/tests/foreman/ui/test_package.py +++ b/tests/foreman/ui/test_package.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from fauxfactory import gen_string import pytest diff --git a/tests/foreman/ui/test_partitiontable.py b/tests/foreman/ui/test_partitiontable.py index 127dc1ec67..b8f0416331 100644 --- a/tests/foreman/ui/test_partitiontable.py +++ b/tests/foreman/ui/test_partitiontable.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from fauxfactory import gen_string import pytest diff --git a/tests/foreman/ui/test_product.py b/tests/foreman/ui/test_product.py index 88f2eb1e52..4fd8922352 100644 --- a/tests/foreman/ui/test_product.py +++ b/tests/foreman/ui/test_product.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from datetime import timedelta from fauxfactory import gen_choice diff --git a/tests/foreman/ui/test_provisioningtemplate.py b/tests/foreman/ui/test_provisioningtemplate.py index da2b8446dc..7ad306e246 100644 --- a/tests/foreman/ui/test_provisioningtemplate.py +++ b/tests/foreman/ui/test_provisioningtemplate.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest from robottelo.constants import DataFile diff --git a/tests/foreman/ui/test_puppetclass.py b/tests/foreman/ui/test_puppetclass.py index b44ad73e7a..42ae2b359a 100644 --- a/tests/foreman/ui/test_puppetclass.py +++ b/tests/foreman/ui/test_puppetclass.py @@ -11,6 +11,7 @@ :CaseImportance: Low """ + from fauxfactory import gen_string import pytest diff --git a/tests/foreman/ui/test_puppetenvironment.py b/tests/foreman/ui/test_puppetenvironment.py index 57502a5119..6add550854 100644 --- a/tests/foreman/ui/test_puppetenvironment.py +++ b/tests/foreman/ui/test_puppetenvironment.py @@ -11,6 +11,7 @@ :CaseImportance: Low """ + import pytest from robottelo.constants import DEFAULT_CV, ENVIRONMENT diff --git a/tests/foreman/ui/test_registration.py b/tests/foreman/ui/test_registration.py index 9d223340a3..65c79b8163 100644 --- a/tests/foreman/ui/test_registration.py +++ b/tests/foreman/ui/test_registration.py @@ -10,6 +10,7 @@ :Team: Rocket """ + from datetime import datetime import re @@ -540,7 +541,6 @@ def test_positive_host_registration_with_non_admin_user( with module_target_sat.ui_session( test_name, user=user.login, password=user_password ) as session: - cmd = session.host_new.get_register_command( { 'general.insecure': True, diff --git a/tests/foreman/ui/test_remoteexecution.py b/tests/foreman/ui/test_remoteexecution.py index e34f49772a..51f8d4f3dd 100644 --- a/tests/foreman/ui/test_remoteexecution.py +++ b/tests/foreman/ui/test_remoteexecution.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from collections import OrderedDict import datetime import time diff --git a/tests/foreman/ui/test_reporttemplates.py b/tests/foreman/ui/test_reporttemplates.py index fe833d683f..79a4424007 100644 --- a/tests/foreman/ui/test_reporttemplates.py +++ b/tests/foreman/ui/test_reporttemplates.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import csv import json import os diff --git a/tests/foreman/ui/test_repositories.py b/tests/foreman/ui/test_repositories.py index d75f456cf7..081c2d96fd 100644 --- a/tests/foreman/ui/test_repositories.py +++ b/tests/foreman/ui/test_repositories.py @@ -11,6 +11,7 @@ :CaseImportance: Critical """ + import pytest diff --git a/tests/foreman/ui/test_repository.py b/tests/foreman/ui/test_repository.py index 8522e03a4d..50d0dfb6b8 100644 --- a/tests/foreman/ui/test_repository.py +++ b/tests/foreman/ui/test_repository.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from datetime import datetime, timedelta from random import randint, shuffle diff --git a/tests/foreman/ui/test_rhc.py b/tests/foreman/ui/test_rhc.py index df90a5768c..b9f02dcee8 100644 --- a/tests/foreman/ui/test_rhc.py +++ b/tests/foreman/ui/test_rhc.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from datetime import datetime, timedelta from fauxfactory import gen_string diff --git a/tests/foreman/ui/test_rhcloud_insights.py b/tests/foreman/ui/test_rhcloud_insights.py index 3646658c2b..286727095d 100644 --- a/tests/foreman/ui/test_rhcloud_insights.py +++ b/tests/foreman/ui/test_rhcloud_insights.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from datetime import datetime import pytest diff --git a/tests/foreman/ui/test_rhcloud_inventory.py b/tests/foreman/ui/test_rhcloud_inventory.py index 9c98ade020..f576f88b3e 100644 --- a/tests/foreman/ui/test_rhcloud_inventory.py +++ b/tests/foreman/ui/test_rhcloud_inventory.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from datetime import datetime, timedelta import pytest diff --git a/tests/foreman/ui/test_role.py b/tests/foreman/ui/test_role.py index 652bdcbd4f..6a93789f6a 100644 --- a/tests/foreman/ui/test_role.py +++ b/tests/foreman/ui/test_role.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import random from navmazing import NavigationTriesExceeded diff --git a/tests/foreman/ui/test_search.py b/tests/foreman/ui/test_search.py index cc9120bfc2..df58459e2a 100644 --- a/tests/foreman/ui/test_search.py +++ b/tests/foreman/ui/test_search.py @@ -10,6 +10,7 @@ :CaseImportance: Medium """ + from collections import namedtuple from fauxfactory import gen_string diff --git a/tests/foreman/ui/test_settings.py b/tests/foreman/ui/test_settings.py index c3c233bf97..fee05bee93 100644 --- a/tests/foreman/ui/test_settings.py +++ b/tests/foreman/ui/test_settings.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import math from fauxfactory import gen_url diff --git a/tests/foreman/ui/test_smartclassparameter.py b/tests/foreman/ui/test_smartclassparameter.py index adc5169f2a..7cfe14cd03 100644 --- a/tests/foreman/ui/test_smartclassparameter.py +++ b/tests/foreman/ui/test_smartclassparameter.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from random import choice, uniform import pytest diff --git a/tests/foreman/ui/test_subnet.py b/tests/foreman/ui/test_subnet.py index 45886c3ec8..c29bfcb850 100644 --- a/tests/foreman/ui/test_subnet.py +++ b/tests/foreman/ui/test_subnet.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from fauxfactory import gen_ipaddr import pytest diff --git a/tests/foreman/ui/test_subscription.py b/tests/foreman/ui/test_subscription.py index 45bfcd47d9..4157d6c5e4 100644 --- a/tests/foreman/ui/test_subscription.py +++ b/tests/foreman/ui/test_subscription.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from tempfile import mkstemp import time diff --git a/tests/foreman/ui/test_sync.py b/tests/foreman/ui/test_sync.py index 44cfc7483b..2a62030af7 100644 --- a/tests/foreman/ui/test_sync.py +++ b/tests/foreman/ui/test_sync.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from fauxfactory import gen_string import pytest diff --git a/tests/foreman/ui/test_syncplan.py b/tests/foreman/ui/test_syncplan.py index 70a2a31a81..b4be83f714 100644 --- a/tests/foreman/ui/test_syncplan.py +++ b/tests/foreman/ui/test_syncplan.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from datetime import datetime, timedelta import time diff --git a/tests/foreman/ui/test_templatesync.py b/tests/foreman/ui/test_templatesync.py index 766608cd30..e76444ee4a 100644 --- a/tests/foreman/ui/test_templatesync.py +++ b/tests/foreman/ui/test_templatesync.py @@ -9,6 +9,7 @@ :Team: Endeavour """ + from fauxfactory import gen_string import pytest import requests diff --git a/tests/foreman/ui/test_user.py b/tests/foreman/ui/test_user.py index 72e56d8241..0130409eab 100644 --- a/tests/foreman/ui/test_user.py +++ b/tests/foreman/ui/test_user.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import random from fauxfactory import gen_email, gen_string diff --git a/tests/foreman/ui/test_usergroup.py b/tests/foreman/ui/test_usergroup.py index a3196188f4..46e20ffe7a 100644 --- a/tests/foreman/ui/test_usergroup.py +++ b/tests/foreman/ui/test_usergroup.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from fauxfactory import gen_string, gen_utf8 import pytest diff --git a/tests/foreman/ui/test_webhook.py b/tests/foreman/ui/test_webhook.py index c0e3b470c2..90668a8f9d 100644 --- a/tests/foreman/ui/test_webhook.py +++ b/tests/foreman/ui/test_webhook.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from fauxfactory import gen_string, gen_url import pytest diff --git a/tests/foreman/virtwho/api/test_esx.py b/tests/foreman/virtwho/api/test_esx.py index bb6046188a..4b208bae4c 100644 --- a/tests/foreman/virtwho/api/test_esx.py +++ b/tests/foreman/virtwho/api/test_esx.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest from robottelo.config import settings @@ -359,9 +360,7 @@ def test_positive_remove_env_option( # Check the option "env=" should be removed from etc/virt-who.d/virt-who.conf option = "env" config_file = get_configure_file(virtwho_config_api.id) - env_error = ( - f"option {{\'{option}\'}} is not exist or not be enabled in {{\'{config_file}\'}}" - ) + env_error = f"option {{'{option}'}} is not exist or not be enabled in {{'{config_file}'}}" with pytest.raises(Exception) as exc_info: # noqa: PT011 - TODO determine better exception get_configure_option({option}, {config_file}) assert str(exc_info.value) == env_error diff --git a/tests/foreman/virtwho/api/test_esx_sca.py b/tests/foreman/virtwho/api/test_esx_sca.py index 2d43f59637..10c9500eed 100644 --- a/tests/foreman/virtwho/api/test_esx_sca.py +++ b/tests/foreman/virtwho/api/test_esx_sca.py @@ -9,6 +9,7 @@ :Team: Phoenix """ + import pytest from robottelo.config import settings @@ -407,9 +408,7 @@ def test_positive_remove_env_option( # Check the option "env=" should be removed from etc/virt-who.d/virt-who.conf option = "env" config_file = get_configure_file(virtwho_config_api.id) - env_error = ( - f"option {{\'{option}\'}} is not exist or not be enabled in {{\'{config_file}\'}}" - ) + env_error = f"option {{'{option}'}} is not exist or not be enabled in {{'{config_file}'}}" with pytest.raises(Exception) as exc_info: # noqa: PT011 - TODO determine better exception get_configure_option({option}, {config_file}) assert str(exc_info.value) == env_error diff --git a/tests/foreman/virtwho/api/test_hyperv.py b/tests/foreman/virtwho/api/test_hyperv.py index 6d93f1ddb9..d66c13ed62 100644 --- a/tests/foreman/virtwho/api/test_hyperv.py +++ b/tests/foreman/virtwho/api/test_hyperv.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest from robottelo.config import settings diff --git a/tests/foreman/virtwho/api/test_hyperv_sca.py b/tests/foreman/virtwho/api/test_hyperv_sca.py index 715ac92cd1..e74748cde6 100644 --- a/tests/foreman/virtwho/api/test_hyperv_sca.py +++ b/tests/foreman/virtwho/api/test_hyperv_sca.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest from robottelo.utils.virtwho import ( diff --git a/tests/foreman/virtwho/api/test_kubevirt.py b/tests/foreman/virtwho/api/test_kubevirt.py index ef1e7ac578..ece48a6724 100644 --- a/tests/foreman/virtwho/api/test_kubevirt.py +++ b/tests/foreman/virtwho/api/test_kubevirt.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest from robottelo.config import settings diff --git a/tests/foreman/virtwho/api/test_kubevirt_sca.py b/tests/foreman/virtwho/api/test_kubevirt_sca.py index 51628052cd..56f34e17ec 100644 --- a/tests/foreman/virtwho/api/test_kubevirt_sca.py +++ b/tests/foreman/virtwho/api/test_kubevirt_sca.py @@ -9,6 +9,7 @@ :team: Phoenix-subscriptions """ + import pytest from robottelo.utils.virtwho import ( diff --git a/tests/foreman/virtwho/api/test_libvirt.py b/tests/foreman/virtwho/api/test_libvirt.py index b551e0e81d..677d5124a2 100644 --- a/tests/foreman/virtwho/api/test_libvirt.py +++ b/tests/foreman/virtwho/api/test_libvirt.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest from robottelo.config import settings diff --git a/tests/foreman/virtwho/api/test_libvirt_sca.py b/tests/foreman/virtwho/api/test_libvirt_sca.py index f88edd8d47..34d6b78f84 100644 --- a/tests/foreman/virtwho/api/test_libvirt_sca.py +++ b/tests/foreman/virtwho/api/test_libvirt_sca.py @@ -9,6 +9,7 @@ :team: Phoenix-subscriptions """ + import pytest from robottelo.utils.virtwho import ( diff --git a/tests/foreman/virtwho/api/test_nutanix.py b/tests/foreman/virtwho/api/test_nutanix.py index e40433b1c5..6e29e63847 100644 --- a/tests/foreman/virtwho/api/test_nutanix.py +++ b/tests/foreman/virtwho/api/test_nutanix.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest from robottelo.config import settings diff --git a/tests/foreman/virtwho/api/test_nutanix_sca.py b/tests/foreman/virtwho/api/test_nutanix_sca.py index 14b6d2a04f..b6f7bbc935 100644 --- a/tests/foreman/virtwho/api/test_nutanix_sca.py +++ b/tests/foreman/virtwho/api/test_nutanix_sca.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest from robottelo.utils.virtwho import ( diff --git a/tests/foreman/virtwho/cli/test_esx.py b/tests/foreman/virtwho/cli/test_esx.py index c18ffb3ab3..0b148edbfc 100644 --- a/tests/foreman/virtwho/cli/test_esx.py +++ b/tests/foreman/virtwho/cli/test_esx.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import re from fauxfactory import gen_string @@ -410,9 +411,7 @@ def test_positive_remove_env_option( # Check the option "env=" should be removed from etc/virt-who.d/virt-who.conf option = "env" config_file = get_configure_file(virtwho_config_cli['id']) - env_error = ( - f"option {{\'{option}\'}} is not exist or not be enabled in {{\'{config_file}\'}}" - ) + env_error = f"option {{'{option}'}} is not exist or not be enabled in {{'{config_file}'}}" with pytest.raises(Exception) as exc_info: # noqa: PT011 - TODO determine better exception get_configure_option({option}, {config_file}) assert str(exc_info.value) == env_error diff --git a/tests/foreman/virtwho/cli/test_esx_sca.py b/tests/foreman/virtwho/cli/test_esx_sca.py index 6b15b6803f..a6c2e4843e 100644 --- a/tests/foreman/virtwho/cli/test_esx_sca.py +++ b/tests/foreman/virtwho/cli/test_esx_sca.py @@ -9,6 +9,7 @@ :Team: Phoenix """ + import re from fauxfactory import gen_string @@ -492,9 +493,7 @@ def test_positive_remove_env_option( # Check the option "env=" should be removed from etc/virt-who.d/virt-who.conf option = "env" config_file = get_configure_file(virtwho_config_cli['id']) - env_error = ( - f"option {{\'{option}\'}} is not exist or not be enabled in {{\'{config_file}\'}}" - ) + env_error = f"option {{'{option}'}} is not exist or not be enabled in {{'{config_file}'}}" with pytest.raises(Exception) as exc_info: # noqa: PT011 - TODO determine better exception get_configure_option({option}, {config_file}) assert str(exc_info.value) == env_error diff --git a/tests/foreman/virtwho/cli/test_hyperv.py b/tests/foreman/virtwho/cli/test_hyperv.py index 657ee3e04f..98f84d277e 100644 --- a/tests/foreman/virtwho/cli/test_hyperv.py +++ b/tests/foreman/virtwho/cli/test_hyperv.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest from robottelo.config import settings diff --git a/tests/foreman/virtwho/cli/test_hyperv_sca.py b/tests/foreman/virtwho/cli/test_hyperv_sca.py index 7c59213485..e72da8f78e 100644 --- a/tests/foreman/virtwho/cli/test_hyperv_sca.py +++ b/tests/foreman/virtwho/cli/test_hyperv_sca.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest from robottelo.utils.virtwho import ( diff --git a/tests/foreman/virtwho/cli/test_kubevirt.py b/tests/foreman/virtwho/cli/test_kubevirt.py index f29a22e4a1..88e9bcdcc2 100644 --- a/tests/foreman/virtwho/cli/test_kubevirt.py +++ b/tests/foreman/virtwho/cli/test_kubevirt.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest from robottelo.config import settings diff --git a/tests/foreman/virtwho/cli/test_kubevirt_sca.py b/tests/foreman/virtwho/cli/test_kubevirt_sca.py index d682b5f915..1c96fbc88a 100644 --- a/tests/foreman/virtwho/cli/test_kubevirt_sca.py +++ b/tests/foreman/virtwho/cli/test_kubevirt_sca.py @@ -9,6 +9,7 @@ :team: Phoenix-subscriptions """ + import pytest from robottelo.utils.virtwho import ( diff --git a/tests/foreman/virtwho/cli/test_libvirt.py b/tests/foreman/virtwho/cli/test_libvirt.py index 70ac4056fa..ea8f09c9cd 100644 --- a/tests/foreman/virtwho/cli/test_libvirt.py +++ b/tests/foreman/virtwho/cli/test_libvirt.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest from robottelo.config import settings diff --git a/tests/foreman/virtwho/cli/test_libvirt_sca.py b/tests/foreman/virtwho/cli/test_libvirt_sca.py index 2bfeda3080..85ee3e8d7f 100644 --- a/tests/foreman/virtwho/cli/test_libvirt_sca.py +++ b/tests/foreman/virtwho/cli/test_libvirt_sca.py @@ -9,6 +9,7 @@ :team: Phoenix-subscriptions """ + import pytest from robottelo.utils.virtwho import ( diff --git a/tests/foreman/virtwho/cli/test_nutanix.py b/tests/foreman/virtwho/cli/test_nutanix.py index b5478912ab..7233e8454d 100644 --- a/tests/foreman/virtwho/cli/test_nutanix.py +++ b/tests/foreman/virtwho/cli/test_nutanix.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest from robottelo.config import settings diff --git a/tests/foreman/virtwho/cli/test_nutanix_sca.py b/tests/foreman/virtwho/cli/test_nutanix_sca.py index 360aac0f67..a3ed65953a 100644 --- a/tests/foreman/virtwho/cli/test_nutanix_sca.py +++ b/tests/foreman/virtwho/cli/test_nutanix_sca.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest from robottelo.utils.virtwho import ( diff --git a/tests/foreman/virtwho/ui/test_esx.py b/tests/foreman/virtwho/ui/test_esx.py index efd46e6deb..dc615e7b4a 100644 --- a/tests/foreman/virtwho/ui/test_esx.py +++ b/tests/foreman/virtwho/ui/test_esx.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from datetime import datetime from fauxfactory import gen_string @@ -731,9 +732,7 @@ def test_positive_remove_env_option( option = "env" config_id = get_configure_id(name) config_file = get_configure_file(config_id) - env_error = ( - f"option {{\'{option}\'}} is not exist or not be enabled in {{\'{config_file}\'}}" - ) + env_error = f"option {{'{option}'}} is not exist or not be enabled in {{'{config_file}'}}" with pytest.raises(Exception) as exc_info: # noqa: PT011 - TODO determine better exception get_configure_option({option}, {config_file}) assert str(exc_info.value) == env_error diff --git a/tests/foreman/virtwho/ui/test_esx_sca.py b/tests/foreman/virtwho/ui/test_esx_sca.py index 3656ba0903..118e7a0cfb 100644 --- a/tests/foreman/virtwho/ui/test_esx_sca.py +++ b/tests/foreman/virtwho/ui/test_esx_sca.py @@ -9,6 +9,7 @@ :team: Phoenix-subscriptions """ + from datetime import datetime from airgun.session import Session @@ -312,9 +313,7 @@ def test_positive_remove_env_option( option = "env" config_id = get_configure_id(name) config_file = get_configure_file(config_id) - env_error = ( - f"option {{\'{option}\'}} is not exist or not be enabled in {{\'{config_file}\'}}" - ) + env_error = f"option {{'{option}'}} is not exist or not be enabled in {{'{config_file}'}}" with pytest.raises(Exception) as exc_info: # noqa: PT011 - TODO determine better exception get_configure_option({option}, {config_file}) assert str(exc_info.value) == env_error diff --git a/tests/foreman/virtwho/ui/test_hyperv.py b/tests/foreman/virtwho/ui/test_hyperv.py index 8348540326..2db519760f 100644 --- a/tests/foreman/virtwho/ui/test_hyperv.py +++ b/tests/foreman/virtwho/ui/test_hyperv.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest from robottelo.config import settings diff --git a/tests/foreman/virtwho/ui/test_hyperv_sca.py b/tests/foreman/virtwho/ui/test_hyperv_sca.py index a5b560c99a..5fcd47bdb8 100644 --- a/tests/foreman/virtwho/ui/test_hyperv_sca.py +++ b/tests/foreman/virtwho/ui/test_hyperv_sca.py @@ -9,6 +9,7 @@ :team: Phoenix-subscriptions """ + import pytest from robottelo.utils.virtwho import ( diff --git a/tests/foreman/virtwho/ui/test_kubevirt.py b/tests/foreman/virtwho/ui/test_kubevirt.py index e12c4774fc..0f8a01f317 100644 --- a/tests/foreman/virtwho/ui/test_kubevirt.py +++ b/tests/foreman/virtwho/ui/test_kubevirt.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest from robottelo.config import settings diff --git a/tests/foreman/virtwho/ui/test_kubevirt_sca.py b/tests/foreman/virtwho/ui/test_kubevirt_sca.py index a155492986..14714df675 100644 --- a/tests/foreman/virtwho/ui/test_kubevirt_sca.py +++ b/tests/foreman/virtwho/ui/test_kubevirt_sca.py @@ -9,6 +9,7 @@ :team: Phoenix-subscriptions """ + import pytest from robottelo.utils.virtwho import ( diff --git a/tests/foreman/virtwho/ui/test_libvirt.py b/tests/foreman/virtwho/ui/test_libvirt.py index a66bf1737b..1d1ffaa0dc 100644 --- a/tests/foreman/virtwho/ui/test_libvirt.py +++ b/tests/foreman/virtwho/ui/test_libvirt.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest from robottelo.config import settings diff --git a/tests/foreman/virtwho/ui/test_libvirt_sca.py b/tests/foreman/virtwho/ui/test_libvirt_sca.py index ffef902441..66c73926ab 100644 --- a/tests/foreman/virtwho/ui/test_libvirt_sca.py +++ b/tests/foreman/virtwho/ui/test_libvirt_sca.py @@ -9,6 +9,7 @@ :team: Phoenix-subscriptions """ + import pytest from robottelo.utils.virtwho import ( diff --git a/tests/foreman/virtwho/ui/test_nutanix.py b/tests/foreman/virtwho/ui/test_nutanix.py index 7ec05f191d..2b7295fd35 100644 --- a/tests/foreman/virtwho/ui/test_nutanix.py +++ b/tests/foreman/virtwho/ui/test_nutanix.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from fauxfactory import gen_string import pytest diff --git a/tests/foreman/virtwho/ui/test_nutanix_sca.py b/tests/foreman/virtwho/ui/test_nutanix_sca.py index bb2483195d..b085fc55ec 100644 --- a/tests/foreman/virtwho/ui/test_nutanix_sca.py +++ b/tests/foreman/virtwho/ui/test_nutanix_sca.py @@ -9,6 +9,7 @@ :Team: Phoenix-subscriptions """ + from fauxfactory import gen_string import pytest diff --git a/tests/robottelo/test_datafactory.py b/tests/robottelo/test_datafactory.py index b93d401ed8..9d8406640c 100644 --- a/tests/robottelo/test_datafactory.py +++ b/tests/robottelo/test_datafactory.py @@ -1,4 +1,5 @@ """Tests for module ``robottelo.utils.datafactory``.""" + import itertools import random from unittest import mock diff --git a/tests/robottelo/test_decorators.py b/tests/robottelo/test_decorators.py index 6c5e60f568..9a50461962 100644 --- a/tests/robottelo/test_decorators.py +++ b/tests/robottelo/test_decorators.py @@ -1,4 +1,5 @@ """Unit tests for :mod:`robottelo.utils.decorators`.""" + from unittest import mock import pytest diff --git a/tests/robottelo/test_dependencies.py b/tests/robottelo/test_dependencies.py index 950cbeebec..d12372a64a 100644 --- a/tests/robottelo/test_dependencies.py +++ b/tests/robottelo/test_dependencies.py @@ -1,4 +1,5 @@ """Test important behavior in robottelo's direct dependencies""" + import contextlib diff --git a/tests/robottelo/test_func_locker.py b/tests/robottelo/test_func_locker.py index d0da97431e..de2ef29aa3 100644 --- a/tests/robottelo/test_func_locker.py +++ b/tests/robottelo/test_func_locker.py @@ -96,8 +96,9 @@ def simple_recursive_locking_function(): """try to trigger the same lock from the same process, an exception should be expected """ - with func_locker.locking_function(simple_locked_function), func_locker.locking_function( - simple_locked_function + with ( + func_locker.locking_function(simple_locked_function), + func_locker.locking_function(simple_locked_function), ): pass return 'I should not be reached' @@ -125,9 +126,10 @@ def simple_function_to_lock(): def simple_with_locking_function(index=None): global counter_file time.sleep(0.05) - with func_locker.locking_function(simple_locked_function), open( - _get_function_lock_path('simple_locked_function') - ) as rf: + with ( + func_locker.locking_function(simple_locked_function), + open(_get_function_lock_path('simple_locked_function')) as rf, + ): content = rf.read() if index is not None: @@ -234,9 +236,10 @@ def test_locker_file_location_when_in_class(self): content = '' assert str(os.getpid()) != content - with func_locker.locking_function(SimpleClass.simple_function_to_lock), open( - file_path - ) as rf: + with ( + func_locker.locking_function(SimpleClass.simple_function_to_lock), + open(file_path) as rf, + ): content = rf.read() assert str(os.getpid()) == content @@ -249,9 +252,10 @@ def test_locker_file_location_when_in_class(self): content = '' assert str(os.getpid()) != content - with func_locker.locking_function(SimpleClass.simple_function_to_lock_cls), open( - file_path - ) as rf: + with ( + func_locker.locking_function(SimpleClass.simple_function_to_lock_cls), + open(file_path) as rf, + ): content = rf.read() assert str(os.getpid()) == content @@ -296,9 +300,10 @@ def test_locker_file_location_when_in_class(self): else: content = '' assert str(os.getpid()) != content - with func_locker.locking_function(SimpleClass.SubClass.simple_function_to_lock_cls), open( - file_path - ) as rf: + with ( + func_locker.locking_function(SimpleClass.SubClass.simple_function_to_lock_cls), + open(file_path) as rf, + ): content = rf.read() assert str(os.getpid()) == content @@ -410,7 +415,8 @@ def test_scoped_with_locking(self): assert os.path.exists(lock_file_path) def test_negative_with_locking_not_locked(self): - with pytest.raises( - func_locker.FunctionLockerError, match=r'.*Cannot ensure locking.*' - ), func_locker.locking_function(simple_function_not_locked): + with ( + pytest.raises(func_locker.FunctionLockerError, match=r'.*Cannot ensure locking.*'), + func_locker.locking_function(simple_function_not_locked), + ): pass diff --git a/tests/robottelo/test_hammer.py b/tests/robottelo/test_hammer.py index 0a887a4c0b..fce548fa0d 100644 --- a/tests/robottelo/test_hammer.py +++ b/tests/robottelo/test_hammer.py @@ -1,4 +1,5 @@ """Tests for Robottelo's hammer helpers""" + from robottelo.cli import hammer diff --git a/tests/robottelo/test_helpers.py b/tests/robottelo/test_helpers.py index 0b39bb54b9..b73fb78af7 100644 --- a/tests/robottelo/test_helpers.py +++ b/tests/robottelo/test_helpers.py @@ -1,4 +1,5 @@ """Tests for module ``robottelo.helpers``.""" + import pytest from robottelo.utils import slugify_component, validate_ssh_pub_key diff --git a/tests/robottelo/test_issue_handlers.py b/tests/robottelo/test_issue_handlers.py index d8fdce0c7b..430cf18644 100644 --- a/tests/robottelo/test_issue_handlers.py +++ b/tests/robottelo/test_issue_handlers.py @@ -365,7 +365,6 @@ def _remove_file(): os.remove(DEFAULT_BZ_CACHE_FILE) try: - subprocess.run( [sys.executable, '-m', 'pytest', '--collect-only', 'tests/robottelo'], check=True ) @@ -408,7 +407,11 @@ def test_add_workaround(): add_workaround(data, matches, 'test', foo='bar') add_workaround( - data, matches, 'test', validation=lambda *a, **k: False, zaz='traz' # Should not be added + data, + matches, + 'test', + validation=lambda *a, **k: False, + zaz='traz', # Should not be added ) for match in matches: diff --git a/tests/robottelo/test_ssh.py b/tests/robottelo/test_ssh.py index 6167a0292b..28012695d9 100644 --- a/tests/robottelo/test_ssh.py +++ b/tests/robottelo/test_ssh.py @@ -1,4 +1,5 @@ """Tests for module ``robottelo.utils.ssh``.""" + from unittest import mock from robottelo import ssh diff --git a/tests/upgrades/conftest.py b/tests/upgrades/conftest.py index 4c759f66b7..afa8c8eb21 100644 --- a/tests/upgrades/conftest.py +++ b/tests/upgrades/conftest.py @@ -81,6 +81,7 @@ def test_capsule_post_upgrade_skipped(pre_upgrade_data): # in post_upgrade scenario, test results should be # 2 passed, 6 deselected """ + import datetime import functools import json diff --git a/tests/upgrades/test_activation_key.py b/tests/upgrades/test_activation_key.py index 11d37ccdab..540c5b52b5 100644 --- a/tests/upgrades/test_activation_key.py +++ b/tests/upgrades/test_activation_key.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest from requests.exceptions import HTTPError diff --git a/tests/upgrades/test_bookmarks.py b/tests/upgrades/test_bookmarks.py index ff53bcdb30..f9f0986aec 100644 --- a/tests/upgrades/test_bookmarks.py +++ b/tests/upgrades/test_bookmarks.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest from robottelo.constants import BOOKMARK_ENTITIES_SELECTION diff --git a/tests/upgrades/test_capsule.py b/tests/upgrades/test_capsule.py index c7cf63e997..e106c9a860 100644 --- a/tests/upgrades/test_capsule.py +++ b/tests/upgrades/test_capsule.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import os import pytest diff --git a/tests/upgrades/test_classparameter.py b/tests/upgrades/test_classparameter.py index b7f8d1c6ed..f0fd73f78a 100644 --- a/tests/upgrades/test_classparameter.py +++ b/tests/upgrades/test_classparameter.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import json import pytest diff --git a/tests/upgrades/test_client.py b/tests/upgrades/test_client.py index c89496485b..94fc71d1de 100644 --- a/tests/upgrades/test_client.py +++ b/tests/upgrades/test_client.py @@ -14,6 +14,7 @@ :CaseImportance: High """ + import pytest from robottelo.config import settings diff --git a/tests/upgrades/test_contentview.py b/tests/upgrades/test_contentview.py index 2b581297b1..537ea003e0 100644 --- a/tests/upgrades/test_contentview.py +++ b/tests/upgrades/test_contentview.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from fauxfactory import gen_alpha import pytest diff --git a/tests/upgrades/test_discovery.py b/tests/upgrades/test_discovery.py index c85e02e01f..1cf7404fb1 100644 --- a/tests/upgrades/test_discovery.py +++ b/tests/upgrades/test_discovery.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import re from packaging.version import Version diff --git a/tests/upgrades/test_errata.py b/tests/upgrades/test_errata.py index 90dec2b305..1425d34115 100644 --- a/tests/upgrades/test_errata.py +++ b/tests/upgrades/test_errata.py @@ -11,6 +11,7 @@ :CaseImportance: Critical """ + import pytest from wait_for import wait_for diff --git a/tests/upgrades/test_host.py b/tests/upgrades/test_host.py index b60585d63b..b5db455ab3 100644 --- a/tests/upgrades/test_host.py +++ b/tests/upgrades/test_host.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from fauxfactory import gen_string import pytest diff --git a/tests/upgrades/test_hostcontent.py b/tests/upgrades/test_hostcontent.py index 0a6a60e2a9..b8faff77fe 100644 --- a/tests/upgrades/test_hostcontent.py +++ b/tests/upgrades/test_hostcontent.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest diff --git a/tests/upgrades/test_hostgroup.py b/tests/upgrades/test_hostgroup.py index a6d67a106d..a61e854bc5 100644 --- a/tests/upgrades/test_hostgroup.py +++ b/tests/upgrades/test_hostgroup.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from fauxfactory import gen_string import pytest diff --git a/tests/upgrades/test_performance_tuning.py b/tests/upgrades/test_performance_tuning.py index 33237e8f56..28a30aeed9 100644 --- a/tests/upgrades/test_performance_tuning.py +++ b/tests/upgrades/test_performance_tuning.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import filecmp import pytest diff --git a/tests/upgrades/test_provisioningtemplate.py b/tests/upgrades/test_provisioningtemplate.py index 7c603c30a5..cc686e3d22 100644 --- a/tests/upgrades/test_provisioningtemplate.py +++ b/tests/upgrades/test_provisioningtemplate.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from fauxfactory import gen_string import pytest diff --git a/tests/upgrades/test_puppet.py b/tests/upgrades/test_puppet.py index b0c96394cc..9c8f53fbbe 100644 --- a/tests/upgrades/test_puppet.py +++ b/tests/upgrades/test_puppet.py @@ -11,6 +11,7 @@ :CaseImportance: Medium """ + import pytest diff --git a/tests/upgrades/test_remoteexecution.py b/tests/upgrades/test_remoteexecution.py index 6aeaecb863..6eba06e1b7 100644 --- a/tests/upgrades/test_remoteexecution.py +++ b/tests/upgrades/test_remoteexecution.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest diff --git a/tests/upgrades/test_repository.py b/tests/upgrades/test_repository.py index 31233d820c..9b4de62f02 100644 --- a/tests/upgrades/test_repository.py +++ b/tests/upgrades/test_repository.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest from robottelo.config import settings diff --git a/tests/upgrades/test_role.py b/tests/upgrades/test_role.py index 25c0ab411c..1af836c5bc 100644 --- a/tests/upgrades/test_role.py +++ b/tests/upgrades/test_role.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest diff --git a/tests/upgrades/test_satellite_maintain.py b/tests/upgrades/test_satellite_maintain.py index 03abb569e9..128a6dd64b 100644 --- a/tests/upgrades/test_satellite_maintain.py +++ b/tests/upgrades/test_satellite_maintain.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import re import pytest diff --git a/tests/upgrades/test_satellitesync.py b/tests/upgrades/test_satellitesync.py index ad9356d2f9..627f389ca1 100644 --- a/tests/upgrades/test_satellitesync.py +++ b/tests/upgrades/test_satellitesync.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest from robottelo.constants import PULP_EXPORT_DIR diff --git a/tests/upgrades/test_subnet.py b/tests/upgrades/test_subnet.py index 0fbc2f3827..220b9316c7 100644 --- a/tests/upgrades/test_subnet.py +++ b/tests/upgrades/test_subnet.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest diff --git a/tests/upgrades/test_subscription.py b/tests/upgrades/test_subscription.py index dc6d33b84b..cbf34dd05a 100644 --- a/tests/upgrades/test_subscription.py +++ b/tests/upgrades/test_subscription.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from manifester import Manifester import pytest diff --git a/tests/upgrades/test_syncplan.py b/tests/upgrades/test_syncplan.py index 5939c8e16d..0a9f1e8f78 100644 --- a/tests/upgrades/test_syncplan.py +++ b/tests/upgrades/test_syncplan.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from fauxfactory import gen_choice import pytest diff --git a/tests/upgrades/test_user.py b/tests/upgrades/test_user.py index b21da9b5ba..bdcc354973 100644 --- a/tests/upgrades/test_user.py +++ b/tests/upgrades/test_user.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + import pytest diff --git a/tests/upgrades/test_usergroup.py b/tests/upgrades/test_usergroup.py index 11ac95e2af..36687f048d 100644 --- a/tests/upgrades/test_usergroup.py +++ b/tests/upgrades/test_usergroup.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from fauxfactory import gen_string import pytest diff --git a/tests/upgrades/test_virtwho.py b/tests/upgrades/test_virtwho.py index e86868ebf3..0e9e15369d 100644 --- a/tests/upgrades/test_virtwho.py +++ b/tests/upgrades/test_virtwho.py @@ -11,6 +11,7 @@ :CaseImportance: High """ + from fauxfactory import gen_string import pytest @@ -148,7 +149,7 @@ def test_post_crud_virt_who_configuration(self, form_data, pre_upgrade_data, tar # Verify the virt-who config-file exists. config_file = get_configure_file(vhd.id) - get_configure_option('hypervisor_id', config_file), + get_configure_option('hypervisor_id', config_file) # Verify Report is sent to satellite. command = get_configure_command(vhd.id, org=org_name) From ef09bc786943d772c05b1d38c8cedf740d95ee2d Mon Sep 17 00:00:00 2001 From: Samuel Bible Date: Fri, 3 May 2024 09:38:56 -0500 Subject: [PATCH 19/20] CV Eval - Deletion (#14678) * Deleting all test cases marked as such in CV Eval * Add back mistakenly removed test * Remove unnecessary imports --- tests/foreman/api/test_contentview.py | 316 ------- tests/foreman/api/test_contentviewfilter.py | 119 +-- tests/foreman/api/test_contentviewversion.py | 507 ---------- tests/foreman/api/test_docker.py | 465 +-------- tests/foreman/cli/test_contentview.py | 944 +------------------ tests/foreman/cli/test_contentviewfilter.py | 72 -- tests/foreman/cli/test_docker.py | 366 ------- 7 files changed, 45 insertions(+), 2744 deletions(-) diff --git a/tests/foreman/api/test_contentview.py b/tests/foreman/api/test_contentview.py index e85532def0..31b649f506 100644 --- a/tests/foreman/api/test_contentview.py +++ b/tests/foreman/api/test_contentview.py @@ -24,7 +24,6 @@ CONTAINER_REGISTRY_HUB, CUSTOM_RPM_SHA_512_FEED_COUNT, DEFAULT_ARCHITECTURE, - FILTER_ERRATA_TYPE, PERMISSIONS, PRDS, REPOS, @@ -190,33 +189,6 @@ def test_positive_add_custom_content(self, module_product, module_org, module_ta assert len(content_view.repository) == 1 assert content_view.repository[0].read().name == yum_repo.name - @pytest.mark.tier2 - @pytest.mark.skipif( - (not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url' - ) - def test_positive_add_custom_module_streams( - self, content_view, module_product, module_org, module_target_sat - ): - """Associate custom content (module streams) in a view - - :id: 9e4821cb-293a-4d84-bd1f-bb9fff36b143 - - :expectedresults: Custom content (module streams) assigned and present in content view - - :CaseImportance: High - """ - yum_repo = module_target_sat.api.Repository( - product=module_product, url=settings.repos.module_stream_1.url - ).create() - yum_repo.sync() - assert len(content_view.repository) == 0 - content_view.repository = [yum_repo] - content_view = content_view.update(['repository']) - assert len(content_view.repository) == 1 - repo = content_view.repository[0].read() - assert repo.name == yum_repo.name - assert repo.content_counts['module_stream'] == 7 - @pytest.mark.tier2 def test_negative_add_dupe_repos( self, content_view, module_product, module_org, module_target_sat @@ -342,22 +314,6 @@ def test_ccv_promote_registry_name_change(self, module_target_sat, module_sca_ma class TestContentViewCreate: """Create tests for content views.""" - @pytest.mark.parametrize('composite', [True, False]) - @pytest.mark.tier1 - def test_positive_create_composite(self, composite, target_sat): - """Create composite and non-composite content views. - - :id: 4a3b616d-53ab-4396-9a50-916d6c42a401 - - :parametrized: yes - - :expectedresults: Creation succeeds and content-view is composite or - non-composite, respectively. - - :CaseImportance: Critical - """ - assert target_sat.api.ContentView(composite=composite).create().composite == composite - @pytest.mark.parametrize('name', **parametrized(valid_data_list())) @pytest.mark.tier1 def test_positive_create_with_name(self, name, target_sat): @@ -563,35 +519,6 @@ def test_positive_promote_with_yum_multiple(self, content_view, module_org, modu assert len(cvv_attrs['environments']) == REPEAT + 1 assert cvv_attrs['package_count'] > 0 - @pytest.mark.tier2 - def test_positive_add_to_composite(self, content_view, module_org, module_target_sat): - """Create normal content view, publish and add it to a new - composite content view - - :id: 36894150-5321-4ffd-ab5a-a7ad01401cf4 - - :expectedresults: Content view can be created and assigned to composite - one through content view versions mechanism - - :CaseImportance: Critical - """ - content_view.repository = [self.yum_repo] - content_view.update(['repository']) - content_view.publish() - content_view = content_view.read() - - composite_cv = module_target_sat.api.ContentView( - composite=True, - organization=module_org, - ).create() - composite_cv.component = content_view.version # list of one CV version - composite_cv = composite_cv.update(['component']) - - # composite CV → CV version == CV → CV version - assert composite_cv.component[0].id == content_view.version[0].id - # composite CV → CV version → CV == CV - assert composite_cv.component[0].read().content_view.id == content_view.id - @pytest.mark.tier2 def test_negative_publish_during_repo_sync(self, content_view, module_target_sat): """Attempt to publish a new version of the content-view, @@ -640,32 +567,6 @@ def test_negative_publish_during_repo_sync(self, content_view, module_target_sat # no new versions of content view, any existing remained the same assert content_view.read().version == existing_versions - @pytest.mark.tier2 - def test_negative_add_components_to_composite( - self, content_view, module_org, module_target_sat - ): - """Attempt to associate components in a non-composite content - view - - :id: 60aa7a4e-df6e-407e-86c7-a4c540bda8b5 - - :expectedresults: User cannot add components to the view - - :CaseImportance: Low - """ - content_view.repository = [self.yum_repo] - content_view.update(['repository']) - content_view.publish() - content_view = content_view.read() - non_composite_cv = module_target_sat.api.ContentView( - composite=False, - organization=module_org, - ).create() - non_composite_cv.component = content_view.version # list of one cvv - with pytest.raises(HTTPError): - non_composite_cv.update(['component']) - assert len(non_composite_cv.read().component) == 0 - @pytest.mark.upgrade @pytest.mark.tier2 def test_positive_promote_composite_multiple_content_once( @@ -1005,27 +906,6 @@ def test_negative_update_name(self, module_cv, new_name, module_target_sat): assert cv.name != new_name -class TestContentViewDelete: - """Tests for deleting content views.""" - - @pytest.mark.parametrize('name', **parametrized(valid_data_list())) - @pytest.mark.tier1 - def test_positive_delete(self, content_view, name, target_sat): - """Create content view and then delete it. - - :id: d582f1b3-8118-4e78-a639-237c6f9d27c6 - - :parametrized: yes - - :expectedresults: Content View is successfully deleted. - - :CaseImportance: Critical - """ - content_view.delete() - with pytest.raises(HTTPError): - target_sat.api.ContentView(id=content_view.id).read() - - @pytest.mark.run_in_one_thread class TestContentViewRedHatContent: """Tests for publishing and promoting content views.""" @@ -1050,19 +930,6 @@ def initiate_testclass( module_cv.update(['repository']) request.cls.yumcv = module_cv.read() - @pytest.mark.tier2 - def test_positive_add_rh(self): - """associate Red Hat content in a view - - :id: f011a269-813d-4e82-afe8-f106b23cb03e - - :expectedresults: RH Content assigned and present in a view - - :CaseImportance: High - """ - assert len(self.yumcv.repository) == 1 - assert self.yumcv.repository[0].read().name == REPOS['rhst7']['name'] - @pytest.mark.tier2 def test_positive_add_rh_custom_spin(self, target_sat): """Associate Red Hat content in a view and filter it using rule @@ -1088,47 +955,6 @@ def test_positive_add_rh_custom_spin(self, target_sat): ).create() assert cv_filter.id == cv_filter_rule.content_view_filter.id - @pytest.mark.tier2 - def test_positive_update_rh_custom_spin(self, target_sat): - """Edit content views for a custom rh spin. For example, - modify a filter - - :id: 81d77ecd-8bac-44c6-8bc2-b6e38ad77a0b - - :expectedresults: edited content view save is successful and info is - updated - - :CaseImportance: High - """ - cvf = target_sat.api.ErratumContentViewFilter( - content_view=self.yumcv, - ).create() - assert self.yumcv.id == cvf.content_view.id - - cv_filter_rule = target_sat.api.ContentViewFilterRule( - content_view_filter=cvf, types=[FILTER_ERRATA_TYPE['enhancement']] - ).create() - assert cv_filter_rule.types == [FILTER_ERRATA_TYPE['enhancement']] - - cv_filter_rule.types = [FILTER_ERRATA_TYPE['bugfix']] - cv_filter_rule = cv_filter_rule.update(['types']) - assert cv_filter_rule.types == [FILTER_ERRATA_TYPE['bugfix']] - - @pytest.mark.tier2 - def test_positive_publish_rh(self, module_org, content_view): - """Attempt to publish a content view containing Red Hat content - - :id: 4f1698ef-a23b-48d6-be25-dbbf2d76c95c - - :expectedresults: Content view can be published - - :CaseImportance: Critical - """ - content_view.repository = [self.repo] - content_view.update(['repository']) - content_view.publish() - assert len(content_view.read().version) == 1 - @pytest.mark.tier2 def test_positive_publish_rh_custom_spin(self, module_org, content_view, module_target_sat): """Attempt to publish a content view containing Red Hat spin - i.e., @@ -1169,27 +995,6 @@ def test_positive_promote_rh(self, module_org, content_view, module_lce): ) assert len(content_view.read().version[0].read().environment) == 2 - @pytest.mark.upgrade - @pytest.mark.tier2 - def test_positive_promote_rh_custom_spin(self, content_view, module_lce, module_target_sat): - """Attempt to promote a content view containing Red Hat spin - i.e., - contains filters. - - :id: 8331ba11-1742-425f-83b1-6b06c5785572 - - :expectedresults: Content view can be promoted - - :CaseImportance: High - """ - content_view.repository = [self.repo] - content_view = content_view.update(['repository']) - module_target_sat.api.RPMContentViewFilter( - content_view=content_view, inclusion='true', name=gen_string('alphanumeric') - ).create() - content_view.publish() - content_view.read().version[0].promote(data={'environment_ids': module_lce.id}) - assert len(content_view.read().version[0].read().environment) == 2 - @pytest.mark.e2e @pytest.mark.tier2 def test_cv_audit_scenarios(self, module_product, target_sat): @@ -1277,127 +1082,6 @@ def test_cv_audit_scenarios(self, module_product, target_sat): assert not self.yumcv.read().needs_publish -@pytest.mark.tier2 -def test_positive_admin_user_actions( - target_sat, content_view, function_role, module_org, module_lce -): - """Attempt to manage content views - - :id: 75b638af-d132-4b5e-b034-a373565c72b4 - - :steps: with global admin account: - - 1. create a user with all content views permissions - 2. create lifecycle environment - 3. create 2 content views (one to delete, the other to manage) - - :setup: create a user with all content views permissions - - :expectedresults: The user can Read, Modify, Delete, Publish, Promote - the content views - - :CaseImportance: Critical - """ - user_login = gen_string('alpha') - user_password = gen_string('alphanumeric') - # create a role with all content views permissions - for res_type in ['Katello::ContentView', 'Katello::KTEnvironment']: - permission = target_sat.api.Permission().search( - query={'search': f'resource_type="{res_type}"'} - ) - target_sat.api.Filter( - organization=[module_org], permission=permission, role=function_role - ).create() - # create a user and assign the above created role - target_sat.api.User( - organization=[module_org], - role=[function_role], - login=user_login, - password=user_password, - ).create() - cfg = user_nailgun_config(user_login, user_password) - # Check that we cannot create random entity due permission restriction - with pytest.raises(HTTPError): - target_sat.api.Domain(server_config=cfg).create() - # Check Read functionality - content_view = target_sat.api.ContentView(server_config=cfg, id=content_view.id).read() - # Check Modify functionality - target_sat.api.ContentView( - server_config=cfg, id=content_view.id, name=gen_string('alpha') - ).update(['name']) - # Publish the content view. - content_view.publish() - content_view = content_view.read() - assert len(content_view.version) == 1 - # Promote the content view version. - content_view.version[0].promote(data={'environment_ids': module_lce.id}) - # Check Delete functionality - content_view = target_sat.api.ContentView(organization=module_org).create() - content_view = target_sat.api.ContentView(server_config=cfg, id=content_view.id).read() - content_view.delete() - with pytest.raises(HTTPError): - content_view.read() - - -@pytest.mark.tier2 -def test_positive_readonly_user_actions(target_sat, function_role, content_view, module_org): - """Attempt to view content views - - :id: cdfd6e51-cd46-4afa-807c-98b2195fcf0e - - :setup: - - 1. create a user with the Content View read-only role - 2. create content view - 3. add a custom repository to content view - - :expectedresults: User with read-only role for content view can view - the repository in the content view - - :CaseImportance: Critical - """ - user_login = gen_string('alpha') - user_password = gen_string('alphanumeric') - # create a role with content views read only permissions - target_sat.api.Filter( - organization=[module_org], - permission=target_sat.api.Permission().search( - filters={'name': 'view_content_views'}, - query={'search': 'resource_type="Katello::ContentView"'}, - ), - role=function_role, - ).create() - # create read only products permissions and assign it to our role - target_sat.api.Filter( - organization=[module_org], - permission=target_sat.api.Permission().search( - filters={'name': 'view_products'}, - query={'search': 'resource_type="Katello::Product"'}, - ), - role=function_role, - ).create() - # create a user and assign the above created role - target_sat.api.User( - organization=[module_org], - role=[function_role], - login=user_login, - password=user_password, - ).create() - # add repository to the created content view - product = target_sat.api.Product(organization=module_org).create() - yum_repo = target_sat.api.Repository(product=product).create() - yum_repo.sync() - content_view.repository = [yum_repo] - content_view = content_view.update(['repository']) - assert len(content_view.repository) == 1 - cfg = user_nailgun_config(user_login, user_password) - # Check that we can read content view repository information using user - # with read only permissions - content_view = target_sat.api.ContentView(server_config=cfg, id=content_view.id).read() - assert len(content_view.repository) == 1 - assert content_view.repository[0].read().name == yum_repo.name - - @pytest.mark.tier2 def test_negative_readonly_user_actions( target_sat, function_role, content_view, module_org, module_lce diff --git a/tests/foreman/api/test_contentviewfilter.py b/tests/foreman/api/test_contentviewfilter.py index 0516582ed5..be3dcc9835 100644 --- a/tests/foreman/api/test_contentviewfilter.py +++ b/tests/foreman/api/test_contentviewfilter.py @@ -16,18 +16,15 @@ """ -import http from random import randint from fauxfactory import gen_integer, gen_string -from nailgun import client import pytest from requests.exceptions import HTTPError -from robottelo.config import get_credentials, settings +from robottelo.config import settings from robottelo.constants import CONTAINER_REGISTRY_HUB from robottelo.utils.datafactory import ( - invalid_names_list, parametrized, valid_data_list, ) @@ -66,43 +63,6 @@ def content_view_module_stream(module_org, sync_repo_module_stream, module_targe class TestContentViewFilter: """Tests for content view filters.""" - @pytest.mark.tier2 - def test_negative_get_with_no_args(self, target_sat): - """Issue an HTTP GET to the base content view filters path. - - :id: da29fd90-cd96-49f9-b94e-71d4e3a35a57 - - :expectedresults: An HTTP 200 response is received if a GET request is - issued with no arguments specified. - - :CaseImportance: Low - """ - response = client.get( - target_sat.api.AbstractContentViewFilter().path(), - auth=get_credentials(), - verify=False, - ) - assert response.status_code == http.client.OK - - @pytest.mark.tier2 - def test_negative_get_with_bad_args(self, target_sat): - """Issue an HTTP GET to the base content view filters path. - - :id: e6fea726-930b-4b74-b784-41528811994f - - :expectedresults: An HTTP 200 response is received if a GET request is - issued with bad arguments specified. - - :CaseImportance: Low - """ - response = client.get( - target_sat.api.AbstractContentViewFilter().path(), - auth=get_credentials(), - verify=False, - data={'foo': 'bar'}, - ) - assert response.status_code == http.client.OK - @pytest.mark.tier2 @pytest.mark.parametrize('name', **parametrized(valid_data_list())) def test_positive_create_erratum_with_name(self, name, content_view, target_sat): @@ -271,65 +231,6 @@ def test_positive_create_with_docker_repos( for repo in cvf.repository: assert repo.id in (sync_repo.id, docker_repository.id) - @pytest.mark.tier2 - @pytest.mark.skipif( - (not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url' - ) - def test_positive_create_with_module_streams( - self, module_product, sync_repo, sync_repo_module_stream, content_view, target_sat - ): - """Verify Include and Exclude Filters creation for modulemd (module streams) - - :id: 4734dcca-ea5b-47d6-8f5f-239da0dc7629 - - :expectedresults: Content view filter created successfully for both - Include and Exclude Type - - """ - content_view.repository += [sync_repo_module_stream] - content_view.update(['repository']) - for inclusion in (True, False): - cvf = target_sat.api.ModuleStreamContentViewFilter( - content_view=content_view, - inclusion=inclusion, - repository=[sync_repo, sync_repo_module_stream], - ).create() - assert cvf.inclusion == inclusion - assert len(cvf.repository) == 2 - assert content_view.id == cvf.content_view.id - assert cvf.type == 'modulemd' - - @pytest.mark.tier2 - @pytest.mark.parametrize('name', **parametrized(invalid_names_list())) - def test_negative_create_with_invalid_name(self, name, content_view, target_sat): - """Try to create content view filter using invalid names only - - :id: 8cf4227b-75c4-4d6f-b94f-88e4eb586435 - - :parametrized: yes - - :expectedresults: Content view filter was not created - - :CaseImportance: Critical - """ - with pytest.raises(HTTPError): - target_sat.api.RPMContentViewFilter(content_view=content_view, name=name).create() - - @pytest.mark.tier2 - def test_negative_create_with_same_name(self, content_view, target_sat): - """Try to create content view filter using same name twice - - :id: 73a64ca7-07a3-49ee-8921-0474a16a23ff - - :expectedresults: Second content view filter was not created - - :CaseImportance: Low - """ - kwargs = {'content_view': content_view, 'name': gen_string('alpha')} - target_sat.api.RPMContentViewFilter(**kwargs).create() - with pytest.raises(HTTPError): - target_sat.api.RPMContentViewFilter(**kwargs).create() - @pytest.mark.tier2 def test_negative_create_without_cv(self, target_sat): """Try to create content view filter without providing content @@ -537,24 +438,6 @@ def test_positive_update_repo_with_docker( for repo in cvf.repository: assert repo.id in (sync_repo.id, docker_repository.id) - @pytest.mark.tier2 - @pytest.mark.parametrize('name', **parametrized(invalid_names_list())) - def test_negative_update_name(self, name, content_view, target_sat): - """Try to update content view filter using invalid names only - - :id: 9799648a-3900-4186-8271-6b2dedb547ab - - :parametrized: yes - - :expectedresults: Content view filter was not updated - - :CaseImportance: Low - """ - cvf = target_sat.api.RPMContentViewFilter(content_view=content_view).create() - cvf.name = name - with pytest.raises(HTTPError): - cvf.update(['name']) - @pytest.mark.tier2 def test_negative_update_same_name(self, content_view, target_sat): """Try to update content view filter's name to already used one diff --git a/tests/foreman/api/test_contentviewversion.py b/tests/foreman/api/test_contentviewversion.py index b870ffb19f..9f4b70f9a7 100644 --- a/tests/foreman/api/test_contentviewversion.py +++ b/tests/foreman/api/test_contentviewversion.py @@ -12,15 +12,12 @@ """ -from fauxfactory import gen_string import pytest from requests.exceptions import HTTPError from robottelo.config import settings from robottelo.constants import ( - CONTAINER_REGISTRY_HUB, DEFAULT_CV, - ENVIRONMENT, DataFile, ) @@ -37,82 +34,6 @@ def module_lce_cv(module_org, module_target_sat): return lce1, lce2, default_cvv -# Tests for content view version creation. - - -@pytest.mark.tier2 -def test_positive_create(module_cv): - """Create a content view version. - - :id: 627c84b3-e3f1-416c-a09b-5d2200d6429f - - :expectedresults: Content View Version is created. - - :CaseImportance: Critical - """ - # Fetch content view for latest information - cv = module_cv.read() - # No versions should be available yet - assert len(cv.version) == 0 - - # Publish existing content view - cv.publish() - # Fetch it again - cv = cv.read() - assert len(cv.version) > 0 - - -@pytest.mark.tier2 -def test_negative_create(module_org, module_target_sat): - """Attempt to create content view version using the 'Default Content View'. - - :id: 0afd49c6-f3a4-403e-9929-849f51ffa922 - - :expectedresults: Content View Version is not created - - :CaseImportance: Critical - """ - # The default content view cannot be published - cv = module_target_sat.api.ContentView(organization=module_org.id, name=DEFAULT_CV).search() - # There should be only 1 record returned - assert len(cv) == 1 - with pytest.raises(HTTPError): - cv[0].publish() - - -# Tests for content view version promotion. - - -@pytest.mark.tier2 -def test_positive_promote_valid_environment(module_lce_cv, module_org, module_target_sat): - """Promote a content view version to next in sequence lifecycle environment. - - :id: f205ca06-8ab5-4546-83bd-deac4363d487 - - :expectedresults: Promotion succeeds. - - :CaseImportance: Critical - """ - # Create a new content view... - cv = module_target_sat.api.ContentView(organization=module_org).create() - # ... and promote it. - cv.publish() - # Refresh the entity - cv = cv.read() - # Check that we have a new version - assert len(cv.version) == 1 - version = cv.version[0].read() - # Assert that content view version is found in 1 lifecycle - # environments (i.e. 'Library') - assert len(version.environment) == 1 - # Promote it to the next 'in sequence' lifecycle environment - version.promote(data={'environment_ids': module_lce_cv[0].id, 'force': False}) - # Assert that content view version is found in 2 lifecycle - # environments. - version = version.read() - assert len(version.environment) == 2 - - @pytest.mark.tier2 def test_positive_promote_out_of_sequence_environment(module_org, module_lce_cv, module_target_sat): """Promote a content view version to a lifecycle environment @@ -298,434 +219,6 @@ def test_positive_delete_composite_version(module_org, module_target_sat): assert len(composite_cv.read().version) == 0 -@pytest.mark.tier2 -def test_negative_delete(module_org, module_target_sat): - """Create content view and publish it. Try to delete content - view version while content view is still associated with lifecycle - environment - - :id: 21c35aae-2f9c-4679-b3ba-7cd9182bd880 - - :expectedresults: Content view version is not deleted - - :CaseImportance: Critical - """ - content_view = module_target_sat.api.ContentView(organization=module_org).create() - # Publish content view - content_view.publish() - content_view = content_view.read() - assert len(content_view.version) == 1 - with pytest.raises(HTTPError): - content_view.version[0].delete() - # Make sure that content view version is still present - assert len(content_view.read().version) == 1 - - -@pytest.mark.tier2 -@pytest.mark.skipif((not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url') -def test_positive_remove_renamed_cv_version_from_default_env(module_org, module_target_sat): - """Remove version of renamed content view from Library environment - - :id: 7d5961d0-6a9a-4610-979e-cbc4ddbc50ca - - :steps: - - 1. Create a content view - 2. Add a yum repo to the content view - 3. Publish the content view - 4. Rename the content view - 5. remove the published version from Library environment - - :expectedresults: content view version is removed from Library - environment - """ - new_name = gen_string('alpha') - # create yum product and repo - product = module_target_sat.api.Product(organization=module_org).create() - yum_repo = module_target_sat.api.Repository( - url=settings.repos.yum_1.url, product=product - ).create() - yum_repo.sync() - # create a content view and add the yum repo to it - content_view = module_target_sat.api.ContentView(organization=module_org).create() - content_view.repository = [yum_repo] - content_view = content_view.update(['repository']) - # publish the content view - content_view.publish() - content_view = content_view.read() - assert len(content_view.version) == 1 - content_view_version = content_view.version[0].read() - assert len(content_view_version.environment) == 1 - lce_library = module_target_sat.api.LifecycleEnvironment( - id=content_view_version.environment[0].id - ).read() - # ensure that the content view version is promoted to the Library - # lifecycle environment - assert lce_library.name == ENVIRONMENT - # rename the content view - content_view.name = new_name - content_view.update(['name']) - assert content_view.name == new_name - # delete the content view version from Library environment - content_view.delete_from_environment(lce_library.id) - # assert that the content view version does not exist in Library - # environment - assert len(content_view_version.read().environment) == 0 - - -@pytest.mark.tier2 -def test_positive_remove_qe_promoted_cv_version_from_default_env(module_org, module_target_sat): - """Remove QE promoted content view version from Library environment - - :id: c7795762-93bd-419c-ac49-d10dc26b842b - - :steps: - - 1. Create a content view - 2. Add docker repo(s) to it - 3. Publish content view - 4. Promote the content view version to multiple environments - Library -> DEV -> QE - 5. remove the content view version from Library environment - - :expectedresults: Content view version exist only in DEV, QE and not in - Library - """ - lce_dev = module_target_sat.api.LifecycleEnvironment(organization=module_org).create() - lce_qe = module_target_sat.api.LifecycleEnvironment( - organization=module_org, prior=lce_dev - ).create() - product = module_target_sat.api.Product(organization=module_org).create() - docker_repo = module_target_sat.api.Repository( - content_type='docker', - docker_upstream_name='busybox', - product=product, - url=CONTAINER_REGISTRY_HUB, - ).create() - docker_repo.sync() - # create a content view and add to it the docker repo - content_view = module_target_sat.api.ContentView(organization=module_org).create() - content_view.repository = [docker_repo] - content_view = content_view.update(['repository']) - # publish the content view - content_view.publish() - content_view = content_view.read() - assert len(content_view.version) == 1 - content_view_version = content_view.version[0].read() - assert len(content_view_version.environment) == 1 - lce_library = module_target_sat.api.LifecycleEnvironment( - id=content_view_version.environment[0].id - ).read() - assert lce_library.name == ENVIRONMENT - # promote content view version to DEV and QE lifecycle environments - for lce in [lce_dev, lce_qe]: - content_view_version.promote(data={'environment_ids': lce.id, 'force': False}) - assert {lce_library.id, lce_dev.id, lce_qe.id} == { - lce.id for lce in content_view_version.read().environment - } - # remove the content view version from Library environment - content_view.delete_from_environment(lce_library.id) - # assert that the content view version does not exist in Library - # environment - assert {lce_dev.id, lce_qe.id} == {lce.id for lce in content_view_version.read().environment} - - -@pytest.mark.tier2 -@pytest.mark.skipif((not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url') -def test_positive_remove_prod_promoted_cv_version_from_default_env(module_org, module_target_sat): - """Remove PROD promoted content view version from Library environment - - :id: 24911876-7c2a-4a12-a3aa-98051dfda29d - - :steps: - - 1. Create a content view - 2. Add yum repositories and docker repositories to CV - 3. Publish content view - 4. Promote the content view version to multiple environments - Library -> DEV -> QE -> PROD - 5. remove the content view version from Library environment - - :expectedresults: Content view version exist only in DEV, QE, PROD and - not in Library - """ - lce_dev = module_target_sat.api.LifecycleEnvironment(organization=module_org).create() - lce_qe = module_target_sat.api.LifecycleEnvironment( - organization=module_org, prior=lce_dev - ).create() - lce_prod = module_target_sat.api.LifecycleEnvironment( - organization=module_org, prior=lce_qe - ).create() - product = module_target_sat.api.Product(organization=module_org).create() - yum_repo = module_target_sat.api.Repository( - url=settings.repos.yum_1.url, product=product - ).create() - yum_repo.sync() - docker_repo = module_target_sat.api.Repository( - content_type='docker', - docker_upstream_name='busybox', - product=product, - url=CONTAINER_REGISTRY_HUB, - ).create() - docker_repo.sync() - # create a content view and add to it the yum and docker repos - content_view = module_target_sat.api.ContentView(organization=module_org).create() - content_view.repository = [yum_repo, docker_repo] - content_view = content_view.update(['repository']) - # publish the content view - content_view.publish() - content_view = content_view.read() - assert len(content_view.version) == 1 - content_view_version = content_view.version[0].read() - assert len(content_view_version.environment) == 1 - lce_library = module_target_sat.api.LifecycleEnvironment( - id=content_view_version.environment[0].id - ).read() - assert lce_library.name == ENVIRONMENT - # promote content view version to DEV QE PROD lifecycle environments - for lce in [lce_dev, lce_qe, lce_prod]: - content_view_version.promote(data={'environment_ids': lce.id, 'force': False}) - assert {lce_library.id, lce_dev.id, lce_qe.id, lce_prod.id} == { - lce.id for lce in content_view_version.read().environment - } - # remove the content view version from Library environment - content_view.delete_from_environment(lce_library.id) - # assert that the content view version exists only in DEV QE PROD and - # not in Library environment - assert {lce_dev.id, lce_qe.id, lce_prod.id} == { - lce.id for lce in content_view_version.read().environment - } - - -@pytest.mark.tier2 -@pytest.mark.skipif((not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url') -def test_positive_remove_cv_version_from_env(module_org, module_target_sat): - """Remove promoted content view version from environment - - :id: 17cf18bf-09d5-4641-b0e0-c50e628fa6c8 - - :steps: - - 1. Create a content view - 2. Add a yum repo and a docker repo to the content view - 3. Publish the content view - 4. Promote the content view version to multiple environments - Library -> DEV -> QE -> STAGE -> PROD - 5. remove the content view version from PROD environment - 6. Assert: content view version exists only in Library, DEV, QE, - STAGE and not in PROD - 7. Promote again from STAGE -> PROD - - :expectedresults: Content view version exist in Library, DEV, QE, - STAGE, PROD - """ - lce_dev = module_target_sat.api.LifecycleEnvironment(organization=module_org).create() - lce_qe = module_target_sat.api.LifecycleEnvironment( - organization=module_org, prior=lce_dev - ).create() - lce_stage = module_target_sat.api.LifecycleEnvironment( - organization=module_org, prior=lce_qe - ).create() - lce_prod = module_target_sat.api.LifecycleEnvironment( - organization=module_org, prior=lce_stage - ).create() - product = module_target_sat.api.Product(organization=module_org).create() - yum_repo = module_target_sat.api.Repository( - url=settings.repos.yum_1.url, product=product - ).create() - yum_repo.sync() - # docker repo - docker_repo = module_target_sat.api.Repository( - content_type='docker', - docker_upstream_name='busybox', - product=product, - url=CONTAINER_REGISTRY_HUB, - ).create() - docker_repo.sync() - # create a content view and add the yum and docker repo to it - content_view = module_target_sat.api.ContentView(organization=module_org).create() - content_view.repository = [yum_repo, docker_repo] - content_view = content_view.update(['repository']) - # publish the content view - content_view.publish() - content_view = content_view.read() - assert len(content_view.version) == 1 - content_view_version = content_view.version[0].read() - assert len(content_view_version.environment) == 1 - lce_library = module_target_sat.api.LifecycleEnvironment( - id=content_view_version.environment[0].id - ).read() - assert lce_library.name == ENVIRONMENT - # promote content view version to DEV QE STAGE PROD lifecycle - # environments - for lce in [lce_dev, lce_qe, lce_stage, lce_prod]: - content_view_version.promote(data={'environment_ids': lce.id, 'force': False}) - assert {lce_library.id, lce_dev.id, lce_qe.id, lce_stage.id, lce_prod.id} == { - lce.id for lce in content_view_version.read().environment - } - # remove the content view version from Library environment - content_view.delete_from_environment(lce_prod.id) - # assert that the content view version exists only in Library DEV QE - # STAGE and not in PROD environment - assert {lce_library.id, lce_dev.id, lce_qe.id, lce_stage.id} == { - lce.id for lce in content_view_version.read().environment - } - # promote content view version to PROD environment again - content_view_version.promote(data={'environment_ids': lce_prod.id, 'force': False}) - assert {lce_library.id, lce_dev.id, lce_qe.id, lce_stage.id, lce_prod.id} == { - lce.id for lce in content_view_version.read().environment - } - - -@pytest.mark.tier2 -@pytest.mark.skipif((not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url') -def test_positive_remove_cv_version_from_multi_env(module_org, module_target_sat): - """Remove promoted content view version from multiple environments - - :id: 18b86a68-8e6a-43ea-b95e-188fba125a26 - - :steps: - - 1. Create a content view - 2. Add a yum repo and a docker repo to the content view - 3. Publish the content view - 4. Promote the content view version to multiple environments - Library -> DEV -> QE -> STAGE -> PROD - 5. Remove content view version from QE, STAGE and PROD - - :expectedresults: Content view version exists only in Library, DEV - - :CaseImportance: Low - """ - lce_dev = module_target_sat.api.LifecycleEnvironment(organization=module_org).create() - lce_qe = module_target_sat.api.LifecycleEnvironment( - organization=module_org, prior=lce_dev - ).create() - lce_stage = module_target_sat.api.LifecycleEnvironment( - organization=module_org, prior=lce_qe - ).create() - lce_prod = module_target_sat.api.LifecycleEnvironment( - organization=module_org, prior=lce_stage - ).create() - product = module_target_sat.api.Product(organization=module_org).create() - yum_repo = module_target_sat.api.Repository( - url=settings.repos.yum_1.url, product=product - ).create() - yum_repo.sync() - docker_repo = module_target_sat.api.Repository( - content_type='docker', - docker_upstream_name='busybox', - product=product, - url=CONTAINER_REGISTRY_HUB, - ).create() - docker_repo.sync() - # create a content view and add the yum repo to it - content_view = module_target_sat.api.ContentView(organization=module_org).create() - content_view.repository = [yum_repo, docker_repo] - content_view = content_view.update(['repository']) - # publish the content view - content_view.publish() - content_view = content_view.read() - assert len(content_view.version) == 1 - content_view_version = content_view.version[0].read() - assert len(content_view_version.environment) == 1 - lce_library = module_target_sat.api.LifecycleEnvironment( - id=content_view_version.environment[0].id - ).read() - assert lce_library.name == ENVIRONMENT - # promote content view version to DEV QE STAGE PROD lifecycle - # environments - for lce in [lce_dev, lce_qe, lce_stage, lce_prod]: - content_view_version.promote(data={'environment_ids': lce.id, 'force': False}) - assert {lce_library.id, lce_dev.id, lce_qe.id, lce_stage.id, lce_prod.id} == { - lce.id for lce in content_view_version.read().environment - } - # remove the content view version from QE STAGE and PROD environments - for lce in [lce_qe, lce_stage, lce_prod]: - content_view.delete_from_environment(lce.id) - # assert that the content view version exists only in Library and DEV - # environments - assert {lce_library.id, lce_dev.id} == { - lce.id for lce in content_view_version.read().environment - } - - -@pytest.mark.upgrade -@pytest.mark.tier2 -@pytest.mark.skipif((not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url') -def test_positive_delete_cv_promoted_to_multi_env(module_org, module_target_sat): - """Delete published content view with version promoted to multiple - environments - - :id: c164bd97-e710-4a5a-9c9f-657e6bed804b - - :steps: - - 1. Create a content view - 2. Add a yum repo and a docker repo to the content view - 3. Publish the content view - 4. Promote the content view to multiple environment - Library -> DEV -> QE -> STAGE -> PROD - 5. Delete the content view, this should delete the content with all - it's published/promoted versions from all environments - - :expectedresults: The content view doesn't exist - - :CaseImportance: Critical - """ - lce_dev = module_target_sat.api.LifecycleEnvironment(organization=module_org).create() - lce_qe = module_target_sat.api.LifecycleEnvironment( - organization=module_org, prior=lce_dev - ).create() - lce_stage = module_target_sat.api.LifecycleEnvironment( - organization=module_org, prior=lce_qe - ).create() - lce_prod = module_target_sat.api.LifecycleEnvironment( - organization=module_org, prior=lce_stage - ).create() - product = module_target_sat.api.Product(organization=module_org).create() - yum_repo = module_target_sat.api.Repository( - url=settings.repos.yum_1.url, product=product - ).create() - yum_repo.sync() - docker_repo = module_target_sat.api.Repository( - content_type='docker', - docker_upstream_name='busybox', - product=product, - url=CONTAINER_REGISTRY_HUB, - ).create() - docker_repo.sync() - # create a content view and add the yum repo to it - content_view = module_target_sat.api.ContentView(organization=module_org).create() - content_view.repository = [yum_repo, docker_repo] - content_view = content_view.update(['repository']) - # publish the content view - content_view.publish() - content_view = content_view.read() - assert len(content_view.version) == 1 - content_view_version = content_view.version[0].read() - assert len(content_view_version.environment) == 1 - lce_library = module_target_sat.api.LifecycleEnvironment( - id=content_view_version.environment[0].id - ).read() - assert lce_library.name == ENVIRONMENT - # promote content view version to DEV QE STAGE PROD lifecycle - # environments - for lce in [lce_dev, lce_qe, lce_stage, lce_prod]: - content_view_version.promote(data={'environment_ids': lce.id, 'force': False}) - content_view_version = content_view_version.read() - assert {lce_library.id, lce_dev.id, lce_qe.id, lce_stage.id, lce_prod.id} == { - lce.id for lce in content_view_version.environment - } - # remove content view version from all lifecycle environments - for lce in content_view_version.environment: - content_view.delete_from_environment(lce.id) - # delete the content view - content_view.delete() - with pytest.raises(HTTPError): - content_view.read() - - @pytest.mark.stubbed @pytest.mark.tier3 def test_positive_remove_cv_version_from_env_with_host_registered(): diff --git a/tests/foreman/api/test_docker.py b/tests/foreman/api/test_docker.py index 6bebe5e81f..fe182dc44c 100644 --- a/tests/foreman/api/test_docker.py +++ b/tests/foreman/api/test_docker.py @@ -10,7 +10,7 @@ from random import choice, randint, shuffle -from fauxfactory import gen_string, gen_url +from fauxfactory import gen_url import pytest from requests.exceptions import HTTPError @@ -306,48 +306,6 @@ class TestDockerContentView: :team: Phoenix-content """ - @pytest.mark.tier2 - def test_positive_add_docker_repo(self, repo, content_view): - """Add one Docker-type repository to a non-composite content view - - :id: a065822f-bb41-4fc9-bf5c-65814ca11b2d - - :expectedresults: A repository is created with a Docker repository and - the product is added to a non-composite content view - """ - # Associate docker repo with the content view - content_view.repository = [repo] - content_view = content_view.update(['repository']) - assert repo.id in [repo_.id for repo_ in content_view.repository] - - @pytest.mark.tier2 - def test_positive_add_docker_repos(self, module_target_sat, module_product, content_view): - """Add multiple Docker-type repositories to a - non-composite content view. - - :id: 08eed081-2003-4475-95ac-553a56b83997 - - :expectedresults: Repositories are created with Docker upstream repos - and the product is added to a non-composite content view. - """ - repos = [ - _create_repository(module_target_sat, module_product, name=gen_string('alpha')) - for _ in range(randint(2, 5)) - ] - repo_ids = {r.id for r in repos} - assert repo_ids.issubset({r.id for r in module_product.read().repository}) - - content_view.repository = repos - content_view = content_view.update(['repository']) - - assert len(repos) == len(content_view.repository) - - for repo in content_view.repository: - r = repo.read() - assert r.id in repo_ids - assert r.content_type == 'docker' - assert r.docker_upstream_name == CONTAINER_UPSTREAM_NAME - @pytest.mark.tier2 def test_positive_add_synced_docker_repo(self, module_org, module_product, module_target_sat): """Create and sync a Docker-type repository @@ -370,43 +328,6 @@ def test_positive_add_synced_docker_repo(self, module_org, module_product, modul content_view = content_view.update(['repository']) assert repo.id in [repo_.id for repo_ in content_view.repository] - @pytest.mark.tier2 - def test_positive_add_docker_repo_to_ccv(self, module_org, module_target_sat): - """Add one Docker-type repository to a composite content view - - :id: fe278275-2bb2-4d68-8624-f0cfd63ecb57 - - :expectedresults: A repository is created with a Docker repository and - the product is added to a content view which is then added to a - composite content view. - """ - repo = _create_repository( - module_target_sat, module_target_sat.api.Product(organization=module_org).create() - ) - - # Create content view and associate docker repo - content_view = module_target_sat.api.ContentView( - composite=False, organization=module_org - ).create() - content_view.repository = [repo] - content_view = content_view.update(['repository']) - assert repo.id in [repo_.id for repo_ in content_view.repository] - - # Publish it and grab its version ID (there should only be one version) - content_view.publish() - content_view = content_view.read() - assert len(content_view.version) == 1 - - # Create composite content view and associate content view to it - comp_content_view = module_target_sat.api.ContentView( - composite=True, organization=module_org - ).create() - comp_content_view.component = content_view.version - comp_content_view = comp_content_view.update(['component']) - assert content_view.version[0].id in [ - component.id for component in comp_content_view.component - ] - @pytest.mark.tier2 def test_positive_add_docker_repos_to_ccv(self, module_org, module_target_sat): """Add multiple Docker-type repositories to a composite @@ -444,38 +365,6 @@ def test_positive_add_docker_repos_to_ccv(self, module_org, module_target_sat): comp_content_view = comp_content_view.update(['component']) assert cv_version.id in [component.id for component in comp_content_view.component] - @pytest.mark.tier2 - def test_positive_publish_with_docker_repo(self, module_org, module_target_sat): - """Add Docker-type repository to content view and publish it once. - - :id: 86a73e96-ead6-41fb-8095-154a0b83e344 - - :expectedresults: One repository is created with a Docker upstream - repository and the product is added to a content view which is then - published only once. - """ - repo = _create_repository( - module_target_sat, module_target_sat.api.Product(organization=module_org).create() - ) - - content_view = module_target_sat.api.ContentView( - composite=False, organization=module_org - ).create() - content_view.repository = [repo] - content_view = content_view.update(['repository']) - assert repo.id in [repo_.id for repo_ in content_view.repository] - - # Not published yet? - content_view = content_view.read() - assert content_view.last_published is None - assert float(content_view.next_version) == 1.0 - - # Publish it and check that it was indeed published. - content_view.publish() - content_view = content_view.read() - assert content_view.last_published is not None - assert float(content_view.next_version) > 1.0 - @pytest.mark.tier2 def test_positive_publish_with_docker_repo_composite(self, module_org, module_target_sat): """Add Docker-type repository to composite content view and @@ -527,109 +416,6 @@ def test_positive_publish_with_docker_repo_composite(self, module_org, module_ta assert comp_content_view.last_published is not None assert float(comp_content_view.next_version) > 1.0 - @pytest.mark.tier2 - def test_positive_publish_multiple_with_docker_repo(self, module_org, module_target_sat): - """Add Docker-type repository to content view and publish it - multiple times. - - :id: e2caad64-e9f4-422d-a1ab-f64c286d82ff - - :expectedresults: One repository is created with a Docker upstream - repository and the product is added to a content view which is then - published multiple times. - """ - repo = _create_repository( - module_target_sat, module_target_sat.api.Product(organization=module_org).create() - ) - content_view = module_target_sat.api.ContentView( - composite=False, organization=module_org - ).create() - content_view.repository = [repo] - content_view = content_view.update(['repository']) - assert [repo.id] == [repo_.id for repo_ in content_view.repository] - assert content_view.read().last_published is None - - publish_amount = randint(2, 5) - for _ in range(publish_amount): - content_view.publish() - content_view = content_view.read() - assert content_view.last_published is not None - assert len(content_view.version) == publish_amount - - @pytest.mark.tier2 - def test_positive_publish_multiple_with_docker_repo_composite( - self, module_org, module_target_sat - ): - """Add Docker-type repository to content view and publish it - multiple times. - - :id: 77a5957a-7415-41c3-be68-fa706fee7c98 - - :expectedresults: One repository is created with a Docker upstream - repository and the product is added to a content view which is then - added to a composite content view which is then published multiple - times. - """ - repo = _create_repository( - module_target_sat, module_target_sat.api.Product(organization=module_org).create() - ) - content_view = module_target_sat.api.ContentView( - composite=False, organization=module_org - ).create() - content_view.repository = [repo] - content_view = content_view.update(['repository']) - assert [repo.id] == [repo_.id for repo_ in content_view.repository] - assert content_view.read().last_published is None - - content_view.publish() - content_view = content_view.read() - assert content_view.last_published is not None - - comp_content_view = module_target_sat.api.ContentView( - composite=True, organization=module_org - ).create() - comp_content_view.component = [content_view.version[0]] - comp_content_view = comp_content_view.update(['component']) - assert [content_view.version[0].id] == [comp.id for comp in comp_content_view.component] - assert comp_content_view.last_published is None - - publish_amount = randint(2, 5) - for _ in range(publish_amount): - comp_content_view.publish() - comp_content_view = comp_content_view.read() - assert comp_content_view.last_published is not None - assert len(comp_content_view.version) == publish_amount - - @pytest.mark.tier2 - def test_positive_promote_with_docker_repo(self, module_org, module_target_sat): - """Add Docker-type repository to content view and publish it. - Then promote it to the next available lifecycle-environment. - - :id: 5ab7d7f1-fb13-4b83-b228-a6293be36195 - - :expectedresults: Docker-type repository is promoted to content view - found in the specific lifecycle-environment. - """ - lce = module_target_sat.api.LifecycleEnvironment(organization=module_org).create() - repo = _create_repository( - module_target_sat, module_target_sat.api.Product(organization=module_org).create() - ) - - content_view = module_target_sat.api.ContentView( - composite=False, organization=module_org - ).create() - content_view.repository = [repo] - content_view = content_view.update(['repository']) - assert [repo.id] == [repo_.id for repo_ in content_view.repository] - - content_view.publish() - content_view = content_view.read() - cvv = content_view.version[0].read() - assert len(cvv.environment) == 1 - - cvv.promote(data={'environment_ids': lce.id, 'force': False}) - assert len(cvv.read().environment) == 2 - @pytest.mark.tier2 def test_positive_promote_multiple_with_docker_repo(self, module_org, module_target_sat): """Add Docker-type repository to content view and publish it. @@ -660,45 +446,6 @@ def test_positive_promote_multiple_with_docker_repo(self, module_org, module_tar cvv.promote(data={'environment_ids': lce.id, 'force': False}) assert len(cvv.read().environment) == i + 1 - @pytest.mark.tier2 - def test_positive_promote_with_docker_repo_composite(self, module_org, module_target_sat): - """Add Docker-type repository to content view and publish it. - Then add that content view to composite one. Publish and promote that - composite content view to the next available lifecycle-environment. - - :id: e903c7b2-7722-4a9e-bb69-99bbd3c23946 - - :expectedresults: Docker-type repository is promoted to content view - found in the specific lifecycle-environment. - """ - lce = module_target_sat.api.LifecycleEnvironment(organization=module_org).create() - repo = _create_repository( - module_target_sat, module_target_sat.api.Product(organization=module_org).create() - ) - content_view = module_target_sat.api.ContentView( - composite=False, organization=module_org - ).create() - content_view.repository = [repo] - content_view = content_view.update(['repository']) - assert [repo.id] == [repo_.id for repo_ in content_view.repository] - - content_view.publish() - cvv = content_view.read().version[0].read() - - comp_content_view = module_target_sat.api.ContentView( - composite=True, organization=module_org - ).create() - comp_content_view.component = [cvv] - comp_content_view = comp_content_view.update(['component']) - assert cvv.id == comp_content_view.component[0].id - - comp_content_view.publish() - comp_cvv = comp_content_view.read().version[0] - assert len(comp_cvv.read().environment) == 1 - - comp_cvv.promote(data={'environment_ids': lce.id, 'force': False}) - assert len(comp_cvv.read().environment) == 2 - @pytest.mark.upgrade @pytest.mark.tier2 def test_positive_promote_multiple_with_docker_repo_composite( @@ -742,216 +489,6 @@ def test_positive_promote_multiple_with_docker_repo_composite( comp_cvv.promote(data={'environment_ids': lce.id, 'force': False}) assert len(comp_cvv.read().environment) == i + 1 - @pytest.mark.tier2 - @pytest.mark.upgrade - def test_positive_name_pattern_change(self, module_org, module_target_sat): - """Promote content view with Docker repository to lifecycle environment. - Change registry name pattern for that environment. Verify that repository - name on product changed according to new pattern. - - :id: cc78d82d-027b-4cb7-92c5-dcccf9b592ea - - :expectedresults: Container repository name is changed - according to new pattern. - """ - pattern_prefix = gen_string('alpha', 5) - docker_upstream_name = 'hello-world' - new_pattern = ( - f'{pattern_prefix}-<%= organization.label %>/<%= repository.docker_upstream_name %>' - ) - - repo = _create_repository( - module_target_sat, - module_target_sat.api.Product(organization=module_org).create(), - upstream_name=docker_upstream_name, - ) - repo.sync(timeout=600) - content_view = module_target_sat.api.ContentView( - composite=False, organization=module_org - ).create() - content_view.repository = [repo] - content_view = content_view.update(['repository']) - content_view.publish() - cvv = content_view.read().version[0] - lce = module_target_sat.api.LifecycleEnvironment(organization=module_org).create() - cvv.promote(data={'environment_ids': lce.id, 'force': False}) - lce.registry_name_pattern = new_pattern - lce = lce.update(['registry_name_pattern']) - repos = module_target_sat.api.Repository(organization=module_org).search( - query={'environment_id': lce.id} - ) - - expected_pattern = f'{pattern_prefix}-{module_org.label}/{docker_upstream_name}'.lower() - assert lce.registry_name_pattern == new_pattern - assert repos[0].container_repository_name == expected_pattern - - @pytest.mark.tier2 - def test_positive_product_name_change_after_promotion(self, module_org, module_target_sat): - """Promote content view with Docker repository to lifecycle environment. - Change product name. Verify that repository name on product changed - according to new pattern. - - :id: 4ff21344-9ee6-4e17-9a88-0230e7cdd586 - - :expectedresults: Container repository name is changed - according to new pattern. - """ - old_prod_name = gen_string('alpha', 5) - new_prod_name = gen_string('alpha', 5) - docker_upstream_name = 'hello-world' - new_pattern = "<%= organization.label %>/<%= product.name %>" - - prod = module_target_sat.api.Product(organization=module_org, name=old_prod_name).create() - repo = _create_repository(module_target_sat, prod, upstream_name=docker_upstream_name) - repo.sync(timeout=600) - content_view = module_target_sat.api.ContentView( - composite=False, organization=module_org - ).create() - content_view.repository = [repo] - content_view = content_view.update(['repository']) - content_view.publish() - cvv = content_view.read().version[0] - lce = module_target_sat.api.LifecycleEnvironment(organization=module_org).create() - lce.registry_name_pattern = new_pattern - lce = lce.update(['registry_name_pattern']) - cvv.promote(data={'environment_ids': lce.id, 'force': False}) - prod.name = new_prod_name - prod.update(['name']) - repos = module_target_sat.api.Repository(organization=module_org).search( - query={'environment_id': lce.id} - ) - - expected_pattern = f"{module_org.label}/{old_prod_name}".lower() - assert repos[0].container_repository_name == expected_pattern - - content_view.publish() - cvv = content_view.read().version[-1] - cvv.promote(data={'environment_ids': lce.id, 'force': False}) - repos = module_target_sat.api.Repository(organization=module_org).search( - query={'environment_id': lce.id} - ) - - expected_pattern = f"{module_org.label}/{new_prod_name}".lower() - assert repos[0].container_repository_name == expected_pattern - - @pytest.mark.tier2 - def test_positive_repo_name_change_after_promotion(self, module_org, module_target_sat): - """Promote content view with Docker repository to lifecycle environment. - Change repository name. Verify that Docker repository name on product - changed according to new pattern. - - :id: 304ae909-dc67-4a7e-80e1-96b45354e5a6 - - :expectedresults: Container repository name is changed - according to new pattern. - """ - old_repo_name = gen_string('alpha', 5) - new_repo_name = gen_string('alpha', 5) - docker_upstream_name = 'hello-world' - new_pattern = "<%= organization.label %>/<%= repository.name %>" - - repo = _create_repository( - module_target_sat, - module_target_sat.api.Product(organization=module_org).create(), - name=old_repo_name, - upstream_name=docker_upstream_name, - ) - repo.sync(timeout=600) - content_view = module_target_sat.api.ContentView( - composite=False, organization=module_org - ).create() - content_view.repository = [repo] - content_view = content_view.update(['repository']) - content_view.publish() - cvv = content_view.read().version[0] - lce = module_target_sat.api.LifecycleEnvironment(organization=module_org).create() - lce.registry_name_pattern = new_pattern - lce = lce.update(['registry_name_pattern']) - cvv.promote(data={'environment_ids': lce.id, 'force': False}) - repo.name = new_repo_name - repo.update(['name']) - repos = module_target_sat.api.Repository(organization=module_org).search( - query={'environment_id': lce.id} - ) - - expected_pattern = f"{module_org.label}/{old_repo_name}".lower() - assert repos[0].container_repository_name == expected_pattern - - content_view.publish() - cvv = content_view.read().version[-1] - cvv.promote(data={'environment_ids': lce.id, 'force': False}) - repos = module_target_sat.api.Repository(organization=module_org).search( - query={'environment_id': lce.id} - ) - - expected_pattern = f"{module_org.label}/{new_repo_name}".lower() - assert repos[0].container_repository_name == expected_pattern - - @pytest.mark.tier2 - def test_negative_set_non_unique_name_pattern_and_promote(self, module_org, module_target_sat): - """Set registry name pattern to one that does not guarantee uniqueness. - Try to promote content view with multiple Docker repositories to - lifecycle environment. Verify that content has not been promoted. - - :id: baae1ec2-35e8-4122-8fac-135c987139d3 - - :expectedresults: Content view is not promoted - """ - docker_upstream_names = ['hello-world', 'alpine'] - new_pattern = "<%= organization.label %>" - - lce = module_target_sat.api.LifecycleEnvironment(organization=module_org).create() - lce.registry_name_pattern = new_pattern - lce = lce.update(['registry_name_pattern']) - prod = module_target_sat.api.Product(organization=module_org).create() - repos = [] - for docker_name in docker_upstream_names: - repo = _create_repository(module_target_sat, prod, upstream_name=docker_name) - repo.sync(timeout=600) - repos.append(repo) - content_view = module_target_sat.api.ContentView( - composite=False, organization=module_org - ).create() - content_view.repository = repos - content_view = content_view.update(['repository']) - content_view.publish() - cvv = content_view.read().version[0] - with pytest.raises(HTTPError): - cvv.promote(data={'environment_ids': lce.id, 'force': False}) - - @pytest.mark.tier2 - def test_negative_promote_and_set_non_unique_name_pattern(self, module_org, module_target_sat): - """Promote content view with multiple Docker repositories to - lifecycle environment. Set registry name pattern to one that - does not guarantee uniqueness. Verify that pattern has not been - changed. - - :id: 945b3301-c523-4026-9753-df3577888319 - - :expectedresults: Registry name pattern is not changed - """ - docker_upstream_names = ['hello-world', 'alpine'] - new_pattern = "<%= organization.label %>" - - prod = module_target_sat.api.Product(organization=module_org).create() - repos = [] - for docker_name in docker_upstream_names: - repo = _create_repository(module_target_sat, prod, upstream_name=docker_name) - repo.sync(timeout=600) - repos.append(repo) - content_view = module_target_sat.api.ContentView( - composite=False, organization=module_org - ).create() - content_view.repository = repos - content_view = content_view.update(['repository']) - content_view.publish() - cvv = content_view.read().version[0] - lce = module_target_sat.api.LifecycleEnvironment(organization=module_org).create() - cvv.promote(data={'environment_ids': lce.id, 'force': False}) - lce.registry_name_pattern = new_pattern - with pytest.raises(HTTPError): - lce.update(['registry_name_pattern']) - class TestDockerActivationKey: """Tests specific to adding ``Docker`` repositories to Activation Keys. diff --git a/tests/foreman/cli/test_contentview.py b/tests/foreman/cli/test_contentview.py index 33a1814933..f9b6829f34 100644 --- a/tests/foreman/cli/test_contentview.py +++ b/tests/foreman/cli/test_contentview.py @@ -380,24 +380,6 @@ def test_negative_delete_version_by_id(self, module_org, module_target_sat): content_view = module_target_sat.cli.ContentView.info({'id': content_view['id']}) assert len(content_view['versions']) == 1 - @pytest.mark.tier1 - def test_positive_remove_lce_by_id(self, module_org, module_target_sat): - """Remove content view from lifecycle environment - - :id: 1bf8a647-d82e-4145-b13b-f92bf6642532 - - :expectedresults: Content view removed from environment successfully - - :CaseImportance: Critical - """ - new_cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) - module_target_sat.cli.ContentView.publish({'id': new_cv['id']}) - new_cv = module_target_sat.cli.ContentView.info({'id': new_cv['id']}) - env = new_cv['lifecycle-environments'][0] - module_target_sat.cli.ContentView.remove({'id': new_cv['id'], 'environment-ids': env['id']}) - new_cv = module_target_sat.cli.ContentView.info({'id': new_cv['id']}) - assert len(new_cv['lifecycle-environments']) == 0 - @pytest.mark.tier3 def test_positive_remove_lce_by_id_and_reassign_ak(self, module_org, module_target_sat): """Remove content view environment and re-assign activation key to @@ -648,98 +630,6 @@ def test_positive_remove_repository_by_name( new_cv = module_target_sat.cli.ContentView.info({'id': new_cv['id']}) assert len(new_cv['yum-repositories']) == 0 - @pytest.mark.tier2 - def test_positive_create_composite(self, module_org, module_target_sat): - """create a composite content view - - :id: bded6acd-8da3-45ea-9e39-19bdc6c06341 - - :setup: sync multiple content source/types (RH, custom, etc.) - - :expectedresults: Composite content views are created - - :CaseImportance: High - """ - # Create REPO - new_product = module_target_sat.cli_factory.make_product({'organization-id': module_org.id}) - new_repo = module_target_sat.cli_factory.make_repository( - {'content-type': 'yum', 'product-id': new_product['id']} - ) - # Sync REPO - module_target_sat.cli.Repository.synchronize({'id': new_repo['id']}) - # Create CV - new_cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) - # Associate repo to CV - module_target_sat.cli.ContentView.add_repository( - {'id': new_cv['id'], 'repository-id': new_repo['id']} - ) - # Publish a new version of CV - module_target_sat.cli.ContentView.publish({'id': new_cv['id']}) - new_cv = module_target_sat.cli.ContentView.info({'id': new_cv['id']}) - # Let us now store the version1 id - version1_id = new_cv['versions'][0]['id'] - # Create CV - con_view = module_target_sat.cli_factory.make_content_view( - {'composite': True, 'organization-id': module_org.id} - ) - # Associate version to composite CV - module_target_sat.cli.ContentView.add_version( - {'content-view-version-id': version1_id, 'id': con_view['id']} - ) - # Assert whether version was associated to composite CV - con_view = module_target_sat.cli.ContentView.info({'id': con_view['id']}) - assert con_view['components'][0]['id'] == version1_id - - @pytest.mark.tier2 - def test_positive_create_composite_by_name(self, module_org, module_target_sat): - """Create a composite content view and add non-composite content - view by its name - - :id: c91271d8-efb8-487e-ab11-2e9e87660d3c - - :expectedresults: Composite content view is created and has another - view associated to it - - :BZ: 1416857 - - :CaseImportance: High - """ - new_product = module_target_sat.cli_factory.make_product({'organization-id': module_org.id}) - # Create REPO - new_repo = module_target_sat.cli_factory.make_repository( - {'content-type': 'yum', 'product-id': new_product['id']} - ) - # Sync REPO - module_target_sat.cli.Repository.synchronize({'id': new_repo['id']}) - # Create CV - new_cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) - # Associate repo to CV - module_target_sat.cli.ContentView.add_repository( - {'id': new_cv['id'], 'repository-id': new_repo['id']} - ) - # Publish a new version of CV - module_target_sat.cli.ContentView.publish({'id': new_cv['id']}) - new_cv = module_target_sat.cli.ContentView.info({'id': new_cv['id']}) - cvv = new_cv['versions'][0] - # Create CV - cv = module_target_sat.cli_factory.make_content_view( - {'composite': True, 'organization-id': module_org.id} - ) - assert len(cv['components']) == 0 - # Associate version to composite CV - module_target_sat.cli.ContentView.add_version( - { - 'content-view-version': cvv['version'], - 'content-view': new_cv['name'], - 'name': cv['name'], - 'organization-id': module_org.id, - } - ) - # Assert whether version was associated to composite CV - cv = module_target_sat.cli.ContentView.info({'id': cv['id']}) - assert len(cv['components']) == 1 - assert cv['components'][0]['id'] == cvv['id'] - @pytest.mark.tier2 def test_positive_remove_version_by_id_from_composite( self, module_org, module_product, module_target_sat @@ -912,67 +802,36 @@ def test_negative_create_composite_with_component_ids(self, module_org, module_t ) assert 'Failed to create ContentView with data:' in str(context) - @pytest.mark.tier3 - def test_positive_update_composite_with_component_ids(module_org, module_target_sat): - """Update a composite content view with a component_ids option - - :id: e6106ff6-c526-40f2-bdc0-ae291f7b267e - - :expectedresults: Composite content view component ids are similar to - the nested content view versions ids - - :CaseImportance: Low - """ - # Create a CV to add to the composite one - cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) - # Publish a new version of the CV - module_target_sat.cli.ContentView.publish({'id': cv['id']}) - new_cv = module_target_sat.cli.ContentView.info({'id': cv['id']}) - # Let us now store the version ids - component_ids = new_cv['versions'][0]['id'] - # Create a composite CV - comp_cv = module_target_sat.cli_factory.make_content_view( - {'composite': True, 'organization-id': module_org.id} - ) - # Update a composite content view with a component id version - module_target_sat.cli.ContentView.update( - {'id': comp_cv['id'], 'component-ids': component_ids} - ) - # Assert whether the composite content view components IDs are equal - # to the component_ids input values - comp_cv = module_target_sat.cli.ContentView.info({'id': comp_cv['id']}) - assert comp_cv['components'][0]['id'] == component_ids - - @pytest.mark.run_in_one_thread - @pytest.mark.tier1 - def test_positive_add_rh_repo_by_id( - self, module_entitlement_manifest_org, module_rhel_content, module_target_sat - ): - """Associate Red Hat content to a content view - - :id: b31a85c3-aa56-461b-9e3a-f7754c742573 + @pytest.mark.tier3 + def test_positive_update_composite_with_component_ids(module_org, module_target_sat): + """Update a composite content view with a component_ids option - :setup: Sync RH content + :id: e6106ff6-c526-40f2-bdc0-ae291f7b267e - :expectedresults: RH Content can be seen in the content view + :expectedresults: Composite content view component ids are similar to + the nested content view versions ids - :CaseImportance: Critical + :CaseImportance: Low """ - # Create CV - new_cv = module_target_sat.cli_factory.make_content_view( - {'organization-id': module_entitlement_manifest_org.id} + # Create a CV to add to the composite one + cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) + # Publish a new version of the CV + module_target_sat.cli.ContentView.publish({'id': cv['id']}) + new_cv = module_target_sat.cli.ContentView.info({'id': cv['id']}) + # Let us now store the version ids + component_ids = new_cv['versions'][0]['id'] + # Create a composite CV + comp_cv = module_target_sat.cli_factory.make_content_view( + {'composite': True, 'organization-id': module_org.id} ) - # Associate repo to CV - module_target_sat.cli.ContentView.add_repository( - { - 'id': new_cv['id'], - 'organization-id': module_entitlement_manifest_org.id, - 'repository-id': module_rhel_content['id'], - } + # Update a composite content view with a component id version + module_target_sat.cli.ContentView.update( + {'id': comp_cv['id'], 'component-ids': component_ids} ) - new_cv = module_target_sat.cli.ContentView.info({'id': new_cv['id']}) - - assert new_cv['yum-repositories'][0]['name'] == module_rhel_content['name'] + # Assert whether the composite content view components IDs are equal + # to the component_ids input values + comp_cv = module_target_sat.cli.ContentView.info({'id': comp_cv['id']}) + assert comp_cv['components'][0]['id'] == component_ids @pytest.mark.run_in_one_thread @pytest.mark.tier3 @@ -1071,33 +930,6 @@ def test_positive_add_module_stream_filter_rule(self, module_org, target_sat): ) assert filter_info['rules'][0]['id'] == content_view_filter_rule['rule-id'] - @pytest.mark.tier2 - def test_positive_add_custom_repo_by_id(self, module_org, module_product, module_target_sat): - """Associate custom content to a Content view - - :id: b813b222-b984-47e0-8d9b-2daa43f9a221 - - :setup: Sync custom content - - :expectedresults: Custom content can be seen in a view - - :CaseImportance: High - - """ - new_repo = module_target_sat.cli_factory.make_repository( - {'content-type': 'yum', 'product-id': module_product.id} - ) - # Sync REPO - module_target_sat.cli.Repository.synchronize({'id': new_repo['id']}) - # Create CV - new_cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) - # Associate repo to CV - module_target_sat.cli.ContentView.add_repository( - {'id': new_cv['id'], 'repository-id': new_repo['id']} - ) - new_cv = module_target_sat.cli.ContentView.info({'id': new_cv['id']}) - assert new_cv['yum-repositories'][0]['name'] == new_repo['name'] - @pytest.mark.tier1 def test_positive_add_custom_repo_by_name(self, module_org, module_product, module_target_sat): """Associate custom content to a content view with name @@ -1129,44 +961,6 @@ def test_positive_add_custom_repo_by_name(self, module_org, module_product, modu new_cv = module_target_sat.cli.ContentView.info({'id': new_cv['id']}) assert new_cv['yum-repositories'][0]['name'] == new_repo['name'] - @pytest.mark.tier2 - def test_negative_add_component_in_non_composite_cv( - self, module_org, module_product, module_target_sat - ): - """attempt to associate components in a non-composite content - view - - :id: 2a6f150d-e012-47c1-9423-d73f5d620dc9 - - :expectedresults: User cannot add components to the view - - :CaseImportance: Low - - """ - # Create REPO - new_repo = module_target_sat.cli_factory.make_repository( - {'content-type': 'yum', 'product-id': module_product.id} - ) - # Sync REPO - module_target_sat.cli.Repository.synchronize({'id': new_repo['id']}) - # Create component CV - new_cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) - # Associate repo to CV - module_target_sat.cli.ContentView.add_repository( - {'id': new_cv['id'], 'repository-id': new_repo['id']} - ) - # Publish a new version of CV - module_target_sat.cli.ContentView.publish({'id': new_cv['id']}) - # Fetch version id - cv_version = module_target_sat.cli.ContentView.version_list( - {'content-view-id': new_cv['id']} - ) - # Create non-composite CV - with pytest.raises(CLIFactoryError): - module_target_sat.cli_factory.make_content_view( - {'component-ids': cv_version[0]['id'], 'organization-id': module_org.id} - ) - @pytest.mark.tier2 def test_negative_add_same_yum_repo_twice(self, module_org, module_product, module_target_sat): """attempt to associate the same repo multiple times within a @@ -1474,37 +1268,6 @@ def test_negative_promote_with_invalid_lce(self, module_org, module_product, mod # Content Views: publish # katello content definition publish --label=MyView - @pytest.mark.run_in_one_thread - @pytest.mark.tier2 - def test_positive_publish_rh_content( - self, module_entitlement_manifest_org, module_rhel_content, module_target_sat - ): - """attempt to publish a content view containing RH content - - :id: d4323759-d869-4d62-ab2e-f1ea3dbb38ba - - :setup: Multiple environments for an org; RH content synced - - :expectedresults: Content view can be published - - :CaseImportance: Critical - - """ - # Create CV - new_cv = module_target_sat.cli_factory.make_content_view( - {'organization-id': module_entitlement_manifest_org.id} - ) - # Associate repo to CV - module_target_sat.cli.ContentView.add_repository( - {'id': new_cv['id'], 'repository-id': module_rhel_content['id']} - ) - # Publish a new version of CV - module_target_sat.cli.ContentView.publish({'id': new_cv['id']}) - new_cv = module_target_sat.cli.ContentView.info({'id': new_cv['id']}) - assert new_cv['yum-repositories'][0]['name'] == module_rhel_content['name'] - - assert new_cv['versions'][0]['version'] == '1.0' - @pytest.mark.run_in_one_thread @pytest.mark.pit_server @pytest.mark.tier3 @@ -1563,36 +1326,6 @@ def test_positive_publish_rh_and_custom_content( ) assert new_cv['versions'][0]['version'] == '1.0' - @pytest.mark.tier2 - def test_positive_publish_custom_content(self, module_org, module_product, module_target_sat): - """attempt to publish a content view containing custom content - - :id: 84158023-3980-45c6-87d8-faacea3c942f - - :setup: Multiple environments for an org; custom content synced - - :expectedresults: Content view can be published - - :CaseImportance: Critical - - """ - new_repo = module_target_sat.cli_factory.make_repository( - {'content-type': 'yum', 'product-id': module_product.id} - ) - # Sync REPO - module_target_sat.cli.Repository.synchronize({'id': new_repo['id']}) - # Create CV - new_cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) - # Associate repo to CV - module_target_sat.cli.ContentView.add_repository( - {'id': new_cv['id'], 'repository-id': new_repo['id']} - ) - # Publish a new version of CV - module_target_sat.cli.ContentView.publish({'id': new_cv['id']}) - new_cv = module_target_sat.cli.ContentView.info({'id': new_cv['id']}) - assert new_cv['yum-repositories'][0]['name'] == new_repo['name'] - assert new_cv['versions'][0]['version'] == '1.0' - @pytest.mark.tier2 def test_positive_publish_custom_major_minor_cv_version(self, module_target_sat): """CV can published with custom major and minor versions @@ -1863,194 +1596,33 @@ def test_positive_publish_ccv(self, module_org, module_product, module_target_sa assert composite_cv['versions'][0]['version'] == '1.0' @pytest.mark.tier2 - @pytest.mark.upgrade - def test_positive_update_version_once(self, module_org, module_product, module_target_sat): - # Dev notes: - # If Dev has version x, then when I promote version y into - # Dev, version x goes away (ie when I promote version 1 to Dev, - # version 3 goes away) - """when publishing new version to environment, version - gets updated + def test_positive_auto_update_composite_to_latest_cv_version( + self, module_org, module_target_sat + ): + """Ensure that composite content view component is auto updated to the + latest content view version. - :id: cef62d34-c006-4bd0-950e-29e732388c00 + :id: c0726d16-1802-4b56-a850-d66948ab70e2 - :setup: Multiple environments for an org; multiple versions of a - content view created/published + :customerscenario: true :steps: - 1. publish a view to an environment noting the CV version - 2. edit and republish a new version of a CV + 1. Create a non composite content view and publish it + 2. Create a composite content view + 3. Add the non composite content view to composite one components + with latest option + 4. Ensure that the published non composite content view version 1 + is in composite content view components + 5. Publish a second time the non composite content view - :expectedresults: Content view version is updated in target - environment. + :expectedresults: The composite content view component was updated + to version 2 of the non composite one + :BZ: 1177766 - :CaseImportance: Critical + :CaseImportance: High """ - # Create REPO - new_repo = module_target_sat.cli_factory.make_repository( - {'content-type': 'yum', 'product-id': module_product.id} - ) - # Sync REPO - module_target_sat.cli.Repository.synchronize({'id': new_repo['id']}) - # Create lce - environment = module_target_sat.cli_factory.make_lifecycle_environment( - {'organization-id': module_org.id} - ) - # Create CV - new_cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) - # Associate repo to CV - module_target_sat.cli.ContentView.add_repository( - {'id': new_cv['id'], 'repository-id': new_repo['id']} - ) - # Publish a version1 of CV - module_target_sat.cli.ContentView.publish({'id': new_cv['id']}) - # Only after we publish version1 the info is populated. - new_cv = module_target_sat.cli.ContentView.info({'id': new_cv['id']}) - # Let us now store the version1 id - version1_id = new_cv['versions'][0]['id'] - # Actual assert for this test happens HERE - # Test whether the version1 now belongs to Library - version1 = module_target_sat.cli.ContentView.version_info({'id': version1_id}) - assert constants.ENVIRONMENT in [env['label'] for env in version1['lifecycle-environments']] - # Promotion of version1 to Dev env - module_target_sat.cli.ContentView.version_promote( - {'id': version1_id, 'to-lifecycle-environment-id': environment['id']} - ) - # The only way to validate whether env has the version is to - # validate that version has the env. - version1 = module_target_sat.cli.ContentView.version_info({'id': version1_id}) - assert environment['id'] in [env['id'] for env in version1['lifecycle-environments']] - # Now Publish version2 of CV - module_target_sat.cli.ContentView.publish({'id': new_cv['id']}) - # Only after we publish version2 the info is populated. - new_cv = module_target_sat.cli.ContentView.info({'id': new_cv['id']}) - new_cv['versions'].sort(key=lambda version: version['id']) - # Let us now store the version2 id - version2_id = new_cv['versions'][1]['id'] - # Test whether the version2 now belongs to Library - version2 = module_target_sat.cli.ContentView.version_info({'id': version2_id}) - assert constants.ENVIRONMENT in [env['label'] for env in version2['lifecycle-environments']] - # Promotion of version2 to Dev env - module_target_sat.cli.ContentView.version_promote( - {'id': version2_id, 'to-lifecycle-environment-id': environment['id']} - ) - # Actual assert for this test happens here. - # Test whether the version2 now belongs to next env - version2 = module_target_sat.cli.ContentView.version_info({'id': version2_id}) - assert environment['id'] in [env['id'] for env in version2['lifecycle-environments']] - - @pytest.mark.tier2 - def test_positive_update_version_multiple(self, module_org, module_product, module_target_sat): - # Dev notes: - # Similarly when I publish version y, version x goes away from - # Library (ie when I publish version 2, version 1 disappears) - """when publishing new version to environment, version - gets updated - - :id: e5704b86-9919-471b-8362-1831d1983e70 - - :setup: Multiple environments for an org; multiple versions of a - content view created/published - - :steps: - 1. publish a view to an environment - 2. edit and republish a new version of a CV - - :expectedresults: Content view version is updated in source - environment. - - :CaseImportance: Low - - """ - # Create REPO - new_repo = module_target_sat.cli_factory.make_repository( - {'content-type': 'yum', 'product-id': module_product.id} - ) - # Sync REPO - module_target_sat.cli.Repository.synchronize({'id': new_repo['id']}) - # Create lce - environment = module_target_sat.cli_factory.make_lifecycle_environment( - {'organization-id': module_org.id} - ) - # Create CV - new_cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) - # Associate repo to CV - module_target_sat.cli.ContentView.add_repository( - {'id': new_cv['id'], 'repository-id': new_repo['id']} - ) - # Publish a version1 of CV - module_target_sat.cli.ContentView.publish({'id': new_cv['id']}) - # Only after we publish version1 the info is populated. - new_cv = module_target_sat.cli.ContentView.info({'id': new_cv['id']}) - # Let us now store the version1 id - version1_id = new_cv['versions'][0]['id'] - # Test whether the version1 now belongs to Library - version = module_target_sat.cli.ContentView.version_info({'id': version1_id}) - assert constants.ENVIRONMENT in [env['label'] for env in version['lifecycle-environments']] - # Promotion of version1 to Dev env - module_target_sat.cli.ContentView.version_promote( - {'id': version1_id, 'to-lifecycle-environment-id': environment['id']} - ) - # The only way to validate whether env has the version is to - # validate that version has the env. - # Test whether the version1 now belongs to next env - version1 = module_target_sat.cli.ContentView.version_info({'id': version1_id}) - assert environment['id'] in [env['id'] for env in version1['lifecycle-environments']] - # Now Publish version2 of CV - module_target_sat.cli.ContentView.publish({'id': new_cv['id']}) - # As per Dev Notes: - # Similarly when I publish version y, version x goes away from Library. - # Actual assert for this test happens here. - # Test that version1 does not exist in Library after publishing v2 - version1 = module_target_sat.cli.ContentView.version_info({'id': version1_id}) - assert len(version1['lifecycle-environments']) == 1 - assert constants.ENVIRONMENT not in [ - env['label'] for env in version1['lifecycle-environments'] - ] - # Only after we publish version2 the info is populated. - new_cv = module_target_sat.cli.ContentView.info({'id': new_cv['id']}) - new_cv['versions'].sort(key=lambda version: version['id']) - # Let us now store the version2 id - version2_id = new_cv['versions'][1]['id'] - # Promotion of version2 to next env - module_target_sat.cli.ContentView.version_promote( - {'id': version2_id, 'to-lifecycle-environment-id': environment['id']} - ) - # Actual assert for this test happens here. - # Test that version1 does not exist in any/next env after, - # promoting version2 to next env - version1 = module_target_sat.cli.ContentView.version_info({'id': version1_id}) - assert len(version1['lifecycle-environments']) == 0 - - @pytest.mark.tier2 - def test_positive_auto_update_composite_to_latest_cv_version( - self, module_org, module_target_sat - ): - """Ensure that composite content view component is auto updated to the - latest content view version. - - :id: c0726d16-1802-4b56-a850-d66948ab70e2 - - :customerscenario: true - - :steps: - 1. Create a non composite content view and publish it - 2. Create a composite content view - 3. Add the non composite content view to composite one components - with latest option - 4. Ensure that the published non composite content view version 1 - is in composite content view components - 5. Publish a second time the non composite content view - - :expectedresults: The composite content view component was updated - to version 2 of the non composite one - - :BZ: 1177766 - - :CaseImportance: High - """ - content_view = module_target_sat.cli_factory.make_content_view( + content_view = module_target_sat.cli_factory.make_content_view( {'organization-id': module_org.id} ) module_target_sat.cli.ContentView.publish({'id': content_view['id']}) @@ -2093,42 +1665,6 @@ def test_positive_auto_update_composite_to_latest_cv_version( assert components[0]['version-id'] == f'{version_2_id} (Latest)' assert components[0]['current-version'] == '2.0' - @pytest.mark.tier3 - def test_positive_subscribe_chost_by_id(self, module_org, module_target_sat): - """Attempt to subscribe content host to content view - - :id: db0bfd9d-3150-427e-9683-a68af33813e7 - - :expectedresults: Content host can be subscribed to content view - - :CaseImportance: High - - """ - env = module_target_sat.cli_factory.make_lifecycle_environment( - {'organization-id': module_org.id} - ) - content_view = module_target_sat.cli_factory.make_content_view( - {'organization-id': module_org.id} - ) - module_target_sat.cli.ContentView.publish({'id': content_view['id']}) - content_view = module_target_sat.cli.ContentView.info({'id': content_view['id']}) - cvv = content_view['versions'][0] - module_target_sat.cli.ContentView.version_promote( - {'id': cvv['id'], 'to-lifecycle-environment-id': env['id']} - ) - content_view = module_target_sat.cli.ContentView.info({'id': content_view['id']}) - assert content_view['content-host-count'] == '0' - module_target_sat.cli_factory.make_fake_host( - { - 'content-view-id': content_view['id'], - 'lifecycle-environment-id': env['id'], - 'name': gen_alphanumeric(), - 'organization-id': module_org.id, - } - ) - content_view = module_target_sat.cli.ContentView.info({'id': content_view['id']}) - assert content_view['content-host-count'] == '1' - @pytest.mark.run_in_one_thread @pytest.mark.tier3 def test_positive_subscribe_chost_by_id_using_rh_content( @@ -2251,60 +1787,6 @@ def test_positive_subscribe_chost_by_id_using_rh_content_and_filters( content_view = module_target_sat.cli.ContentView.info({'id': content_view['id']}) assert content_view['content-host-count'] == '1' - @pytest.mark.tier3 - def test_positive_subscribe_chost_by_id_using_custom_content( - self, module_org, module_target_sat - ): - """Attempt to subscribe content host to content view that has - custom repository assigned to it - - :id: 9758756a-2536-4777-a6a9-ed618453ebe7 - - :expectedresults: Content Host can be subscribed to content view with - custom repository - - :CaseImportance: High - """ - new_product = module_target_sat.cli_factory.make_product({'organization-id': module_org.id}) - new_repo = module_target_sat.cli_factory.make_repository( - {'content-type': 'yum', 'product-id': new_product['id']} - ) - env = module_target_sat.cli_factory.make_lifecycle_environment( - {'organization-id': module_org.id} - ) - module_target_sat.cli.Repository.synchronize({'id': new_repo['id']}) - content_view = module_target_sat.cli_factory.make_content_view( - {'organization-id': module_org.id} - ) - module_target_sat.cli.ContentView.add_repository( - { - 'id': content_view['id'], - 'organization-id': module_org.id, - 'repository-id': new_repo['id'], - } - ) - - module_target_sat.cli.ContentView.publish({'id': content_view['id']}) - content_view = module_target_sat.cli.ContentView.info({'id': content_view['id']}) - cvv = content_view['versions'][0] - module_target_sat.cli.ContentView.version_promote( - {'id': cvv['id'], 'to-lifecycle-environment-id': env['id']} - ) - - content_view = module_target_sat.cli.ContentView.info({'id': content_view['id']}) - assert content_view['content-host-count'] == '0' - - module_target_sat.cli_factory.make_fake_host( - { - 'content-view-id': content_view['id'], - 'lifecycle-environment-id': env['id'], - 'name': gen_alphanumeric(), - 'organization-id': module_org.id, - } - ) - content_view = module_target_sat.cli.ContentView.info({'id': content_view['id']}) - assert content_view['content-host-count'] == '1' - @pytest.mark.tier3 def test_positive_subscribe_chost_by_id_using_ccv(self, module_org, module_target_sat): """Attempt to subscribe content host to composite content view @@ -2659,26 +2141,6 @@ def test_positive_sub_host_with_restricted_user_perm_at_default_loc( assert len(org_hosts) == 1 assert org_hosts[0]['name'] == rhel7_contenthost.hostname - @pytest.mark.tier1 - def test_positive_clone_by_id(self, module_org, module_target_sat): - """Clone existing content view by id - - :id: e3b63e6e-0964-45fb-a765-e1885c0ecbdd - - :expectedresults: Content view is cloned successfully - - :CaseImportance: Critical - """ - cloned_cv_name = gen_string('alpha') - content_view = module_target_sat.cli_factory.make_content_view( - {'organization-id': module_org.id} - ) - new_cv = module_target_sat.cli.ContentView.copy( - {'id': content_view['id'], 'new-name': cloned_cv_name} - )[0] - new_cv = module_target_sat.cli.ContentView.info({'id': new_cv['id']}) - assert new_cv['name'] == cloned_cv_name - @pytest.mark.tier1 def test_positive_clone_by_name(self, module_org, module_target_sat): """Clone existing content view by name @@ -2984,198 +2446,6 @@ def test_positive_remove_promoted_cv_version_from_default_env( } assert {lce_dev['name']} == content_view_version_lce_names - @pytest.mark.tier2 - def test_positive_remove_qe_promoted_cv_version_from_default_env( - self, module_org, module_target_sat - ): - """Remove QE promoted content view version from Library environment - - :id: e286697f-4113-40a3-b8e8-9ca50647e6d5 - - :steps: - - 1. Create a content view - 2. Add docker repo(s) to it - 3. Publish content view - 4. Promote the content view version to multiple environments - Library -> DEV -> QE - 5. remove the content view version from Library environment - - :expectedresults: Content view version exist only in DEV, QE and not in - Library - - :CaseImportance: High - """ - lce_dev = module_target_sat.cli_factory.make_lifecycle_environment( - {'organization-id': module_org.id} - ) - lce_qe = module_target_sat.cli_factory.make_lifecycle_environment( - {'organization-id': module_org.id, 'prior': lce_dev['name']} - ) - docker_product = module_target_sat.cli_factory.make_product( - {'organization-id': module_org.id} - ) - docker_repository = module_target_sat.cli_factory.make_repository( - { - 'content-type': 'docker', - 'docker-upstream-name': constants.CONTAINER_UPSTREAM_NAME, - 'name': gen_string('alpha', 20), - 'product-id': docker_product['id'], - 'url': constants.CONTAINER_REGISTRY_HUB, - } - ) - module_target_sat.cli.Repository.synchronize({'id': docker_repository['id']}) - content_view = module_target_sat.cli_factory.make_content_view( - {'organization-id': module_org.id} - ) - module_target_sat.cli.ContentView.add_repository( - { - 'id': content_view['id'], - 'organization-id': module_org.id, - 'repository-id': docker_repository['id'], - } - ) - module_target_sat.cli.ContentView.publish({'id': content_view['id']}) - content_view_versions = module_target_sat.cli.ContentView.info({'id': content_view['id']})[ - 'versions' - ] - assert len(content_view_versions) > 0 - content_view_version = content_view_versions[-1] - for lce in [lce_dev, lce_qe]: - module_target_sat.cli.ContentView.version_promote( - {'id': content_view_version['id'], 'to-lifecycle-environment-id': lce['id']} - ) - # ensure that the published content version is in Library, DEV and QE - # environments - assert { - constants.ENVIRONMENT, - lce_dev['name'], - lce_qe['name'], - } == _get_content_view_version_lce_names_set( - content_view['id'], content_view_version['id'], sat=module_target_sat - ) - # remove content view version from Library lifecycle environment - module_target_sat.cli.ContentView.remove_from_environment( - { - 'id': content_view['id'], - 'organization-id': module_org.id, - 'lifecycle-environment': constants.ENVIRONMENT, - } - ) - # ensure content view version is not in Library and only in DEV and QE - # environments - assert {lce_dev['name'], lce_qe['name']} == _get_content_view_version_lce_names_set( - content_view['id'], content_view_version['id'], sat=module_target_sat - ) - - @pytest.mark.tier2 - @pytest.mark.skipif( - (not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url' - ) - def test_positive_remove_prod_promoted_cv_version_from_default_env( - self, module_org, module_target_sat - ): - """Remove PROD promoted content view version from Library environment - - :id: ffe3d64e-c3d2-4889-9454-ccc6b10f4db7 - - :steps: - - 1. Create a content view - 2. Add yum repositories and docker repositories to CV - 3. Publish content view - 4. Promote the content view version to multiple environments - Library -> DEV -> QE -> PROD - 5. remove the content view version from Library environment - - :expectedresults: Content view version exist only in DEV, QE, PROD and - not in Library - - :CaseImportance: High - - """ - lce_dev = module_target_sat.cli_factory.make_lifecycle_environment( - {'organization-id': module_org.id} - ) - lce_qe = module_target_sat.cli_factory.make_lifecycle_environment( - {'organization-id': module_org.id, 'prior': lce_dev['name']} - ) - lce_prod = module_target_sat.cli_factory.make_lifecycle_environment( - {'organization-id': module_org.id, 'prior': lce_qe['name']} - ) - custom_yum_product = module_target_sat.cli_factory.make_product( - {'organization-id': module_org.id} - ) - custom_yum_repo = module_target_sat.cli_factory.make_repository( - { - 'content-type': 'yum', - 'product-id': custom_yum_product['id'], - 'url': settings.repos.yum_1.url, - } - ) - module_target_sat.cli.Repository.synchronize({'id': custom_yum_repo['id']}) - docker_product = module_target_sat.cli_factory.make_product( - {'organization-id': module_org.id} - ) - docker_repository = module_target_sat.cli_factory.make_repository( - { - 'content-type': 'docker', - 'docker-upstream-name': constants.CONTAINER_UPSTREAM_NAME, - 'name': gen_string('alpha', 20), - 'product-id': docker_product['id'], - 'url': constants.CONTAINER_REGISTRY_HUB, - } - ) - module_target_sat.cli.Repository.synchronize({'id': docker_repository['id']}) - content_view = module_target_sat.cli_factory.make_content_view( - {'organization-id': module_org.id} - ) - for repo in [custom_yum_repo, docker_repository]: - module_target_sat.cli.ContentView.add_repository( - { - 'id': content_view['id'], - 'organization-id': module_org.id, - 'repository-id': repo['id'], - } - ) - module_target_sat.cli.ContentView.publish({'id': content_view['id']}) - content_view_versions = module_target_sat.cli.ContentView.info({'id': content_view['id']})[ - 'versions' - ] - assert len(content_view_versions) > 0 - content_view_version = content_view_versions[-1] - for lce in [lce_dev, lce_qe, lce_prod]: - module_target_sat.cli.ContentView.version_promote( - {'id': content_view_version['id'], 'to-lifecycle-environment-id': lce['id']} - ) - # ensure that the published content version is in Library, DEV, QE and - # PROD environments - assert { - constants.ENVIRONMENT, - lce_dev['name'], - lce_qe['name'], - lce_prod['name'], - } == _get_content_view_version_lce_names_set( - content_view['id'], content_view_version['id'], sat=module_target_sat - ) - # remove content view version from Library lifecycle environment - module_target_sat.cli.ContentView.remove_from_environment( - { - 'id': content_view['id'], - 'organization-id': module_org.id, - 'lifecycle-environment': constants.ENVIRONMENT, - } - ) - # ensure content view version is not in Library and only in DEV, QE - # and PROD environments - assert { - lce_dev['name'], - lce_qe['name'], - lce_prod['name'], - } == _get_content_view_version_lce_names_set( - content_view['id'], content_view_version['id'], sat=module_target_sat - ) - @pytest.mark.tier2 @pytest.mark.skipif( (not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url' @@ -3408,114 +2678,6 @@ def test_positive_remove_cv_version_from_multi_env(self, module_org, module_targ content_view['id'], content_view_version['id'], sat=module_target_sat ) - @pytest.mark.tier3 - def test_positive_delete_cv_promoted_to_multi_env(self, module_org, module_target_sat): - """Delete published content view with version promoted to multiple - environments - - :id: 93dd7518-5901-4a71-a4c3-0f1215238b26 - - :steps: - - 1. Create a content view - 2. Add a yum repo and a docker to the content view - 3. Publish the content view - 4. Promote the content view to multiple environment Library -> DEV - -> QE -> STAGE -> PROD - 5. Delete the content view (may delete the published versions - environments prior this step) - - :expectedresults: The content view doesn't exists - - :CaseImportance: High - """ - lce_dev = module_target_sat.cli_factory.make_lifecycle_environment( - {'organization-id': module_org.id} - ) - lce_qe = module_target_sat.cli_factory.make_lifecycle_environment( - {'organization-id': module_org.id, 'prior': lce_dev['name']} - ) - lce_stage = module_target_sat.cli_factory.make_lifecycle_environment( - {'organization-id': module_org.id, 'prior': lce_qe['name']} - ) - lce_prod = module_target_sat.cli_factory.make_lifecycle_environment( - {'organization-id': module_org.id, 'prior': lce_stage['name']} - ) - custom_yum_product = module_target_sat.cli_factory.make_product( - {'organization-id': module_org.id} - ) - custom_yum_repo = module_target_sat.cli_factory.make_repository( - { - 'content-type': 'yum', - 'product-id': custom_yum_product['id'], - 'url': settings.repos.yum_1.url, - } - ) - module_target_sat.cli.Repository.synchronize({'id': custom_yum_repo['id']}) - docker_product = module_target_sat.cli_factory.make_product( - {'organization-id': module_org.id} - ) - docker_repository = module_target_sat.cli_factory.make_repository( - { - 'content-type': 'docker', - 'docker-upstream-name': constants.CONTAINER_UPSTREAM_NAME, - 'name': gen_string('alpha', 20), - 'product-id': docker_product['id'], - 'url': constants.CONTAINER_REGISTRY_HUB, - } - ) - module_target_sat.cli.Repository.synchronize({'id': docker_repository['id']}) - content_view = module_target_sat.cli_factory.make_content_view( - {'organization-id': module_org.id} - ) - for repo in [custom_yum_repo, docker_repository]: - module_target_sat.cli.ContentView.add_repository( - { - 'id': content_view['id'], - 'organization-id': module_org.id, - 'repository-id': repo['id'], - } - ) - module_target_sat.cli.ContentView.publish({'id': content_view['id']}) - content_view_versions = module_target_sat.cli.ContentView.info({'id': content_view['id']})[ - 'versions' - ] - assert len(content_view_versions) > 0 - content_view_version = content_view_versions[-1] - for lce in [lce_dev, lce_qe, lce_stage, lce_prod]: - module_target_sat.cli.ContentView.version_promote( - {'id': content_view_version['id'], 'to-lifecycle-environment-id': lce['id']} - ) - # ensure that the published content version is in Library, DEV, QE, - # STAGE and PROD environments - promoted_lce_names_set = _get_content_view_version_lce_names_set( - content_view['id'], content_view_version['id'], sat=module_target_sat - ) - assert { - constants.ENVIRONMENT, - lce_dev['name'], - lce_qe['name'], - lce_stage['name'], - lce_prod['name'], - } == promoted_lce_names_set - # remove from all promoted lifecycle environments - for lce_name in promoted_lce_names_set: - module_target_sat.cli.ContentView.remove_from_environment( - { - 'id': content_view['id'], - 'organization-id': module_org.id, - 'lifecycle-environment': lce_name, - } - ) - # ensure content view in content views list - content_views = module_target_sat.cli.ContentView.list({'organization-id': module_org.id}) - assert content_view['name'] in [cv['name'] for cv in content_views] - # delete the content view - module_target_sat.cli.ContentView.delete({'id': content_view['id']}) - # ensure the content view is not in content views list - content_views = module_target_sat.cli.ContentView.list({'organization-id': module_org.id}) - assert content_view['name'] not in [cv['name'] for cv in content_views] - @pytest.mark.stubbed @pytest.mark.tier3 @pytest.mark.upgrade @@ -4325,26 +3487,6 @@ def test_positive_arbitrary_file_repo_promotion( assert repo['name'] in expected_repo - @pytest.mark.tier3 - def test_positive_katello_repo_rpms_max_int(self, target_sat): - """Checking that datatype for katello_repository_rpms table is a - bigint for id for a closed loop bz. - - :id: e83b3a00-c851-4970-a70d-abd26b2d3593 - - :expectedresults: id datatype is bigint - - :CaseImportance: Medium - - :customerscenario: true - - :BZ: 1793701 - """ - result = target_sat.execute( - 'sudo -u postgres psql -d foreman -c "\\d katello_repository_rpms"' - ) - assert 'id|bigint' in result.stdout.splitlines()[3].replace(' ', '') - @pytest.mark.tier3 def test_positive_inc_update_should_not_fail(self, module_org, module_target_sat): """Incremental update after removing a package should not give a 400 error code diff --git a/tests/foreman/cli/test_contentviewfilter.py b/tests/foreman/cli/test_contentviewfilter.py index 0a198b2754..df9912be34 100644 --- a/tests/foreman/cli/test_contentviewfilter.py +++ b/tests/foreman/cli/test_contentviewfilter.py @@ -789,78 +789,6 @@ def test_negative_update_with_name(self, new_name, content_view, module_target_s {'content-view-id': content_view['id'], 'name': new_name} ) - @pytest.mark.tier1 - def test_negative_update_with_same_name(self, module_org, content_view, module_target_sat): - """Try to update content view filter using name of already - existing entity - - :id: 9c1b1c75-af57-4218-9e2d-e69d74f50e04 - - :expectedresults: Content view filter is not updated - - :CaseImportance: Critical - """ - cvf_name = gen_string('utf8') - module_target_sat.cli.ContentView.filter.create( - { - 'content-view-id': content_view['id'], - 'name': cvf_name, - 'organization-id': module_org.id, - 'type': 'rpm', - }, - ) - new_name = gen_string('alpha', 100) - module_target_sat.cli.ContentView.filter.create( - { - 'content-view-id': content_view['id'], - 'name': new_name, - 'organization-id': module_org.id, - 'type': 'rpm', - }, - ) - with pytest.raises(CLIReturnCodeError): - module_target_sat.cli.ContentView.filter.update( - { - 'content-view-id': content_view['id'], - 'name': new_name, - 'new-name': cvf_name, - } - ) - - @pytest.mark.tier1 - def test_negative_update_inclusion(self, module_org, content_view, module_target_sat): - """Try to update content view filter and assign incorrect inclusion - value for it - - :id: 760400a8-49a5-4a31-924c-c232cb22ddad - - :expectedresults: Content view filter is not updated - - :CaseImportance: Critical - """ - cvf_name = gen_string('utf8') - module_target_sat.cli.ContentView.filter.create( - { - 'content-view-id': content_view['id'], - 'inclusion': 'true', - 'name': cvf_name, - 'organization-id': module_org.id, - 'type': 'rpm', - }, - ) - with pytest.raises(CLIReturnCodeError): - module_target_sat.cli.ContentView.filter.update( - { - 'content-view-id': content_view['id'], - 'inclusion': 'wrong_value', - 'name': cvf_name, - } - ) - cvf = module_target_sat.cli.ContentView.filter.info( - {'content-view-id': content_view['id'], 'name': cvf_name} - ) - assert cvf['inclusion'] == 'true' - @pytest.mark.tier1 def test_negative_update_with_non_existent_repo_id( self, sync_repo, content_view, module_target_sat diff --git a/tests/foreman/cli/test_docker.py b/tests/foreman/cli/test_docker.py index 30f96d9212..381d0df3d2 100644 --- a/tests/foreman/cli/test_docker.py +++ b/tests/foreman/cli/test_docker.py @@ -400,24 +400,6 @@ class TestDockerContentView: :team: Phoenix-content """ - @pytest.mark.tier2 - def test_positive_add_docker_repo_by_id(self, module_org, repo, module_target_sat): - """Add one Docker-type repository to a non-composite content view - - :id: 87d6c7bb-92f8-4a32-8ad2-2a1af896500b - - :expectedresults: A repository is created with a Docker repository and - the product is added to a non-composite content view - """ - content_view = module_target_sat.cli_factory.make_content_view( - {'composite': False, 'organization-id': module_org.id} - ) - module_target_sat.cli.ContentView.add_repository( - {'id': content_view['id'], 'repository-id': repo['id']} - ) - content_view = module_target_sat.cli.ContentView.info({'id': content_view['id']}) - assert repo['id'] in [repo_['id'] for repo_ in content_view['container-image-repositories']] - @pytest.mark.tier2 def test_positive_add_docker_repos_by_id(self, module_org, module_product, module_target_sat): """Add multiple Docker-type repositories to a non-composite CV. @@ -442,115 +424,6 @@ def test_positive_add_docker_repos_by_id(self, module_org, module_product, modul repo['id'] for repo in content_view['container-image-repositories'] } - @pytest.mark.tier2 - def test_positive_add_synced_docker_repo_by_id(self, module_org, repo, module_target_sat): - """Create and sync a Docker-type repository - - :id: 6f51d268-ed23-48ab-9dea-cd3571daa647 - - :expectedresults: A repository is created with a Docker repository and - it is synchronized. - """ - module_target_sat.cli.Repository.synchronize({'id': repo['id']}) - repo = module_target_sat.cli.Repository.info({'id': repo['id']}) - assert int(repo['content-counts']['container-image-manifests']) > 0 - - content_view = module_target_sat.cli_factory.make_content_view( - {'composite': False, 'organization-id': module_org.id} - ) - module_target_sat.cli.ContentView.add_repository( - {'id': content_view['id'], 'repository-id': repo['id']} - ) - content_view = module_target_sat.cli.ContentView.info({'id': content_view['id']}) - assert repo['id'] in [repo_['id'] for repo_ in content_view['container-image-repositories']] - - @pytest.mark.tier2 - def test_positive_add_docker_repo_by_id_to_ccv( - self, module_org, content_view, module_target_sat - ): - """Add one Docker-type repository to a composite content view - - :id: 8e2ef5ba-3cdf-4ef9-a22a-f1701e20a5d5 - - :expectedresults: A repository is created with a Docker repository and - the product is added to a content view which is then added to a - composite content view. - - :BZ: 1359665 - """ - module_target_sat.cli.ContentView.publish({'id': content_view['id']}) - content_view = module_target_sat.cli.ContentView.info({'id': content_view['id']}) - assert len(content_view['versions']) == 1 - comp_content_view = module_target_sat.cli_factory.make_content_view( - {'composite': True, 'organization-id': module_org.id} - ) - module_target_sat.cli.ContentView.update( - { - 'id': comp_content_view['id'], - 'component-ids': content_view['versions'][0]['id'], - } - ) - comp_content_view = module_target_sat.cli.ContentView.info({'id': comp_content_view['id']}) - assert content_view['versions'][0]['id'] in [ - component['id'] for component in comp_content_view['components'] - ] - - @pytest.mark.tier2 - def test_positive_add_docker_repos_by_id_to_ccv( - self, module_org, module_product, module_target_sat - ): - """Add multiple Docker-type repositories to a composite content view. - - :id: b79cbc97-3dba-4059-907d-19316684d569 - - :expectedresults: One repository is created with a Docker upstream - repository and the product is added to a random number of content - views which are then added to a composite content view. - - :BZ: 1359665 - """ - cv_versions = [] - for _ in range(randint(2, 5)): - content_view = module_target_sat.cli_factory.make_content_view( - {'composite': False, 'organization-id': module_org.id} - ) - repo = _repo(module_target_sat, module_product.id) - module_target_sat.cli.ContentView.add_repository( - {'id': content_view['id'], 'repository-id': repo['id']} - ) - module_target_sat.cli.ContentView.publish({'id': content_view['id']}) - content_view = module_target_sat.cli.ContentView.info({'id': content_view['id']}) - assert len(content_view['versions']) == 1 - cv_versions.append(content_view['versions'][0]) - comp_content_view = module_target_sat.cli_factory.make_content_view( - {'composite': True, 'organization-id': module_org.id} - ) - module_target_sat.cli.ContentView.update( - { - 'component-ids': [cv_version['id'] for cv_version in cv_versions], - 'id': comp_content_view['id'], - } - ) - comp_content_view = module_target_sat.cli.ContentView.info({'id': comp_content_view['id']}) - comp_ids = [component['id'] for component in comp_content_view['components']] - for cv_version in cv_versions: - assert cv_version['id'] in comp_ids - - @pytest.mark.tier2 - def test_positive_publish_with_docker_repo(self, content_view, module_target_sat): - """Add Docker-type repository to content view and publish it once. - - :id: 28480de3-ffb5-4b8e-8174-fffffeef6af4 - - :expectedresults: One repository is created with a Docker upstream - repository and the product is added to a content view which is then - published only once. - """ - assert len(content_view['versions']) == 0 - module_target_sat.cli.ContentView.publish({'id': content_view['id']}) - content_view = module_target_sat.cli.ContentView.info({'id': content_view['id']}) - assert len(content_view['versions']) == 1 - @pytest.mark.tier2 def test_positive_publish_with_docker_repo_composite( self, content_view, module_org, module_target_sat @@ -590,182 +463,6 @@ def test_positive_publish_with_docker_repo_composite( comp_content_view = module_target_sat.cli.ContentView.info({'id': comp_content_view['id']}) assert len(comp_content_view['versions']) == 1 - @pytest.mark.tier2 - def test_positive_publish_multiple_with_docker_repo(self, content_view, module_target_sat): - """Add Docker-type repository to content view and publish it multiple - times. - - :id: 33c1b2ee-ae8a-4a7e-8254-123d97aaaa58 - - :expectedresults: One repository is created with a Docker upstream - repository and the product is added to a content view which is then - published multiple times. - """ - assert len(content_view['versions']) == 0 - - publish_amount = randint(2, 5) - for _ in range(publish_amount): - module_target_sat.cli.ContentView.publish({'id': content_view['id']}) - content_view = module_target_sat.cli.ContentView.info({'id': content_view['id']}) - assert len(content_view['versions']) == publish_amount - - @pytest.mark.tier2 - def test_positive_publish_multiple_with_docker_repo_composite( - self, module_org, content_view, module_target_sat - ): - """Add Docker-type repository to content view and publish it multiple - times. - - :id: 014adf90-d399-4a99-badb-76ee03a2c350 - - :expectedresults: One repository is created with a Docker upstream - repository and the product is added to a content view which is then - added to a composite content view which is then published multiple - times. - - :BZ: 1359665 - """ - assert len(content_view['versions']) == 0 - - module_target_sat.cli.ContentView.publish({'id': content_view['id']}) - content_view = module_target_sat.cli.ContentView.info({'id': content_view['id']}) - assert len(content_view['versions']) == 1 - - comp_content_view = module_target_sat.cli_factory.make_content_view( - {'composite': True, 'organization-id': module_org.id} - ) - module_target_sat.cli.ContentView.update( - { - 'component-ids': content_view['versions'][0]['id'], - 'id': comp_content_view['id'], - } - ) - comp_content_view = module_target_sat.cli.ContentView.info({'id': comp_content_view['id']}) - assert content_view['versions'][0]['id'] in [ - component['id'] for component in comp_content_view['components'] - ] - - publish_amount = randint(2, 5) - for _ in range(publish_amount): - module_target_sat.cli.ContentView.publish({'id': comp_content_view['id']}) - comp_content_view = module_target_sat.cli.ContentView.info({'id': comp_content_view['id']}) - assert len(comp_content_view['versions']) == publish_amount - - @pytest.mark.tier2 - def test_positive_promote_with_docker_repo( - self, module_org, module_lce, content_view, module_target_sat - ): - """Add Docker-type repository to content view and publish it. - Then promote it to the next available lifecycle-environment. - - :id: a7df98f4-0ec0-40f6-8941-3dbb776d47b9 - - :expectedresults: Docker-type repository is promoted to content view - found in the specific lifecycle-environment. - """ - module_target_sat.cli.ContentView.publish({'id': content_view['id']}) - content_view = module_target_sat.cli.ContentView.info({'id': content_view['id']}) - assert len(content_view['versions']) == 1 - - cvv = module_target_sat.cli.ContentView.version_info( - {'id': content_view['versions'][0]['id']} - ) - assert len(cvv['lifecycle-environments']) == 1 - - module_target_sat.cli.ContentView.version_promote( - {'id': cvv['id'], 'to-lifecycle-environment-id': module_lce.id} - ) - cvv = module_target_sat.cli.ContentView.version_info( - {'id': content_view['versions'][0]['id']} - ) - assert len(cvv['lifecycle-environments']) == 2 - - @pytest.mark.tier2 - @pytest.mark.upgrade - def test_positive_promote_multiple_with_docker_repo( - self, module_org, content_view, module_target_sat - ): - """Add Docker-type repository to content view and publish it. - Then promote it to multiple available lifecycle-environments. - - :id: e9432bc4-a709-44d7-8e1d-00ca466aa32d - - :expectedresults: Docker-type repository is promoted to content view - found in the specific lifecycle-environments. - """ - module_target_sat.cli.ContentView.publish({'id': content_view['id']}) - content_view = module_target_sat.cli.ContentView.info({'id': content_view['id']}) - assert len(content_view['versions']) == 1 - - cvv = module_target_sat.cli.ContentView.version_info( - {'id': content_view['versions'][0]['id']} - ) - assert len(cvv['lifecycle-environments']) == 1 - - lces = [ - module_target_sat.cli_factory.make_lifecycle_environment( - {'organization-id': module_org.id} - ) - for _ in range(1, randint(3, 6)) - ] - - for expected_lces, lce in enumerate(lces, start=2): - module_target_sat.cli.ContentView.version_promote( - {'id': cvv['id'], 'to-lifecycle-environment-id': lce['id']} - ) - cvv = module_target_sat.cli.ContentView.version_info({'id': cvv['id']}) - assert len(cvv['lifecycle-environments']) == expected_lces - - @pytest.mark.tier2 - def test_positive_promote_with_docker_repo_composite( - self, module_org, module_lce, content_view, module_target_sat - ): - """Add Docker-type repository to composite content view and publish it. - Then promote it to the next available lifecycle-environment. - - :id: fb7d132e-d7fa-4890-a0ec-746dd093513e - - :expectedresults: Docker-type repository is promoted to content view - found in the specific lifecycle-environment. - - :BZ: 1359665 - """ - module_target_sat.cli.ContentView.publish({'id': content_view['id']}) - content_view = module_target_sat.cli.ContentView.info({'id': content_view['id']}) - assert len(content_view['versions']) == 1 - - comp_content_view = module_target_sat.cli_factory.make_content_view( - {'composite': True, 'organization-id': module_org.id} - ) - module_target_sat.cli.ContentView.update( - { - 'component-ids': content_view['versions'][0]['id'], - 'id': comp_content_view['id'], - } - ) - comp_content_view = module_target_sat.cli.ContentView.info({'id': comp_content_view['id']}) - assert content_view['versions'][0]['id'] in [ - component['id'] for component in comp_content_view['components'] - ] - - module_target_sat.cli.ContentView.publish({'id': comp_content_view['id']}) - comp_content_view = module_target_sat.cli.ContentView.info({'id': comp_content_view['id']}) - cvv = module_target_sat.cli.ContentView.version_info( - {'id': comp_content_view['versions'][0]['id']} - ) - assert len(cvv['lifecycle-environments']) == 1 - - module_target_sat.cli.ContentView.version_promote( - { - 'id': comp_content_view['versions'][0]['id'], - 'to-lifecycle-environment-id': module_lce.id, - } - ) - cvv = module_target_sat.cli.ContentView.version_info( - {'id': comp_content_view['versions'][0]['id']} - ) - assert len(cvv['lifecycle-environments']) == 2 - @pytest.mark.tier2 @pytest.mark.upgrade def test_positive_promote_multiple_with_docker_repo_composite( @@ -823,69 +520,6 @@ def test_positive_promote_multiple_with_docker_repo_composite( cvv = module_target_sat.cli.ContentView.version_info({'id': cvv['id']}) assert len(cvv['lifecycle-environments']) == expected_lces - @pytest.mark.tier2 - @pytest.mark.upgrade - def test_positive_name_pattern_change(self, module_org, module_target_sat): - """Promote content view with Docker repository to lifecycle environment. - Change registry name pattern for that environment. Verify that repository - name on product changed according to new pattern. - - :id: 63c99ae7-238b-40ed-8cc1-d847eb4e6d65 - - :expectedresults: Container repository name is changed - according to new pattern. - """ - lce = module_target_sat.cli_factory.make_lifecycle_environment( - {'organization-id': module_org.id} - ) - pattern_prefix = gen_string('alpha', 5) - docker_upstream_name = 'hello-world' - new_pattern = ( - f'{pattern_prefix}-<%= content_view.label %>/<%= repository.docker_upstream_name %>' - ) - - repo = _repo( - module_target_sat, - module_target_sat.cli_factory.make_product_wait({'organization-id': module_org.id})[ - 'id' - ], - name=gen_string('alpha', 5), - upstream_name=docker_upstream_name, - ) - module_target_sat.cli.Repository.synchronize({'id': repo['id']}) - content_view = module_target_sat.cli_factory.make_content_view( - {'composite': False, 'organization-id': module_org.id} - ) - module_target_sat.cli.ContentView.add_repository( - {'id': content_view['id'], 'repository-id': repo['id']} - ) - module_target_sat.cli.ContentView.publish({'id': content_view['id']}) - content_view = module_target_sat.cli.ContentView.info({'id': content_view['id']}) - - module_target_sat.cli.ContentView.version_promote( - {'id': content_view['versions'][0]['id'], 'to-lifecycle-environment-id': lce['id']} - ) - module_target_sat.cli.LifecycleEnvironment.update( - { - 'registry-name-pattern': new_pattern, - 'id': lce['id'], - 'organization-id': module_org.id, - } - ) - lce = module_target_sat.cli.LifecycleEnvironment.info( - {'id': lce['id'], 'organization-id': module_org.id} - ) - assert lce['registry-name-pattern'] == new_pattern - - repo = module_target_sat.cli.Repository.list( - {'name': repo['name'], 'environment-id': lce['id'], 'organization-id': module_org.id} - )[0] - expected_name = f'{pattern_prefix}-{content_view["label"]}/{docker_upstream_name}'.lower() - assert ( - module_target_sat.cli.Repository.info({'id': repo['id']})['container-repository-name'] - == expected_name - ) - @pytest.mark.tier2 def test_positive_product_name_change_after_promotion(self, module_org, module_target_sat): """Promote content view with Docker repository to lifecycle environment. From bba4931f4aec31af9288f58e0bff3cbabc9cc6ca Mon Sep 17 00:00:00 2001 From: Samuel Bible Date: Fri, 3 May 2024 10:43:32 -0500 Subject: [PATCH 20/20] [Stream Fix] Remove escaped quotation mark from valid_name list (#14941) Remove escaped quotation character in CLI datafactory string --- robottelo/utils/datafactory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/robottelo/utils/datafactory.py b/robottelo/utils/datafactory.py index ae52d8fd74..3cefd71f45 100644 --- a/robottelo/utils/datafactory.py +++ b/robottelo/utils/datafactory.py @@ -408,7 +408,7 @@ def valid_names_list(): f"νέος χρήστης-{gen_string('utf8', 2)}", f"foo@!#$^&*( ) {gen_string('utf8')}", f"{gen_string('utf8')}", - f"bar+{{}}|\"?hi {gen_string('utf8')}", + f"bar+{{}}|?hi {gen_string('utf8')}", f" {gen_string('utf8')}", f"{gen_string('utf8')} ", ]