diff --git a/pytest_fixtures/component/host.py b/pytest_fixtures/component/host.py index 4f070a86a64..11645f89f84 100644 --- a/pytest_fixtures/component/host.py +++ b/pytest_fixtures/component/host.py @@ -3,7 +3,6 @@ from nailgun import entities import pytest -from robottelo.cli.factory import setup_org_for_a_rh_repo from robottelo.constants import DEFAULT_CV, ENVIRONMENT, PRDS, REPOS, REPOSET @@ -24,7 +23,7 @@ def module_model(): @pytest.mark.skip_if_not_set('clients', 'fake_manifest') @pytest.fixture(scope="module") -def setup_rhst_repo(): +def setup_rhst_repo(module_target_sat): """Prepare Satellite tools repository for usage in specified organization""" org = entities.Organization().create() cv = entities.ContentView(organization=org).create() @@ -34,7 +33,7 @@ def setup_rhst_repo(): organization=org, ).create() repo_name = 'rhst7' - setup_org_for_a_rh_repo( + module_target_sat.cli_factory.setup_org_for_a_rh_repo( { 'product': PRDS['rhel'], 'repository-set': REPOSET[repo_name], diff --git a/pytest_fixtures/component/oscap.py b/pytest_fixtures/component/oscap.py index 356050f94a7..6e72eee1d6b 100644 --- a/pytest_fixtures/component/oscap.py +++ b/pytest_fixtures/component/oscap.py @@ -4,7 +4,6 @@ from nailgun import entities import pytest -from robottelo.cli.factory import make_scapcontent from robottelo.config import robottelo_tmp_dir, settings from robottelo.constants import OSCAP_PROFILE, OSCAP_TAILORING_FILE, DataFile @@ -29,9 +28,11 @@ def oscap_content_path(session_target_sat): @pytest.fixture(scope="module") -def scap_content(import_ansible_roles): +def scap_content(import_ansible_roles, module_target_sat): title = f"rhel-content-{gen_string('alpha')}" - scap_info = make_scapcontent({'title': title, 'scap-file': f'{settings.oscap.content_path}'}) + scap_info = module_target_sat.cli_factory.make_scapcontent( + {'title': title, 'scap-file': f'{settings.oscap.content_path}'} + ) scap_id = scap_info['id'] scap_info = entities.ScapContents(id=scap_id).read() diff --git a/robottelo/cli/base.py b/robottelo/cli/base.py index d5ce2ae224f..2d3d7974696 100644 --- a/robottelo/cli/base.py +++ b/robottelo/cli/base.py @@ -6,59 +6,11 @@ from robottelo import ssh from robottelo.cli import hammer from robottelo.config import settings +from robottelo.exceptions import CLIDataBaseError, CLIError, CLIReturnCodeError from robottelo.logging import logger from robottelo.utils.ssh import get_client -class CLIError(Exception): - """Indicates that a CLI command could not be run.""" - - -class CLIBaseError(Exception): - """Indicates that a CLI command has finished with return code different - from zero. - - :param status: CLI command return code - :param stderr: contents of the ``stderr`` - :param msg: explanation of the error - - """ - - def __init__(self, status, stderr, msg): - self.status = status - self.stderr = stderr - self.msg = msg - super().__init__(msg) - self.message = msg - - def __str__(self): - """Include class name, status, stderr and msg to string repr so - assertRaisesRegexp can be used to assert error present on any - attribute - """ - return repr(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 - ) - - -class CLIReturnCodeError(CLIBaseError): - """Error to be raised when an error occurs due to some validation error - when execution hammer cli. - See: https://github.com/SatelliteQE/robottelo/issues/3790 for more details - """ - - -class CLIDataBaseError(CLIBaseError): - """Error to be raised when an error occurs due to some missing parameter - which cause a data base error on hammer - See: https://github.com/SatelliteQE/robottelo/issues/3790 for more details - """ - - class Base: """Base class for hammer CLI interaction @@ -84,7 +36,7 @@ def _handle_response(cls, response, ignore_stderr=None): :param ignore_stderr: indicates whether to throw a warning in logs if ``stderr`` is not empty. :returns: contents of ``stdout``. - :raises robottelo.cli.base.CLIReturnCodeError: If return code is + :raises robottelo.exceptions.CLIReturnCodeError: If return code is different from zero. """ if isinstance(response.stderr, tuple): diff --git a/robottelo/cli/report_template.py b/robottelo/cli/report_template.py index e8a60b9beb6..962c5929bc7 100644 --- a/robottelo/cli/report_template.py +++ b/robottelo/cli/report_template.py @@ -25,8 +25,9 @@ from tempfile import mkstemp from robottelo import ssh -from robottelo.cli.base import Base, CLIError +from robottelo.cli.base import Base from robottelo.constants import REPORT_TEMPLATE_FILE, DataFile +from robottelo.exceptions import CLIError class ReportTemplate(Base): diff --git a/robottelo/content_info.py b/robottelo/content_info.py index 1e8fd01ed64..fd404f5a7d9 100644 --- a/robottelo/content_info.py +++ b/robottelo/content_info.py @@ -5,7 +5,7 @@ import requests from robottelo import ssh -from robottelo.cli.base import CLIReturnCodeError +from robottelo.exceptions import CLIReturnCodeError def get_repo_files(repo_path, extension='rpm', hostname=None): diff --git a/robottelo/exceptions.py b/robottelo/exceptions.py index d1f9886dce0..83022dfcd6e 100644 --- a/robottelo/exceptions.py +++ b/robottelo/exceptions.py @@ -65,3 +65,56 @@ class ProxyError(Exception): class DownloadFileError(Exception): """Indicates an error when failure in downloading file from server.""" + + +class CLIFactoryError(Exception): + """Indicates an error occurred while creating an entity using hammer""" + + +class CLIError(Exception): + """Indicates that a CLI command could not be run.""" + + +class CLIBaseError(Exception): + """Indicates that a CLI command has finished with return code different + from zero. + + :param status: CLI command return code + :param stderr: contents of the ``stderr`` + :param msg: explanation of the error + + """ + + def __init__(self, status, stderr, msg): + self.status = status + self.stderr = stderr + self.msg = msg + super().__init__(msg) + self.message = msg + + def __str__(self): + """Include class name, status, stderr and msg to string repr so + assertRaisesRegexp can be used to assert error present on any + attribute + """ + return repr(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 + ) + + +class CLIReturnCodeError(CLIBaseError): + """Error to be raised when an error occurs due to some validation error + when execution hammer cli. + See: https://github.com/SatelliteQE/robottelo/issues/3790 for more details + """ + + +class CLIDataBaseError(CLIBaseError): + """Error to be raised when an error occurs due to some missing parameter + which cause a data base error on hammer + See: https://github.com/SatelliteQE/robottelo/issues/3790 for more details + """ diff --git a/robottelo/host_helpers/cli_factory.py b/robottelo/host_helpers/cli_factory.py index cf7d8a28058..b4461e6b844 100644 --- a/robottelo/host_helpers/cli_factory.py +++ b/robottelo/host_helpers/cli_factory.py @@ -26,17 +26,13 @@ ) from robottelo import constants -from robottelo.cli.base import CLIReturnCodeError from robottelo.cli.proxy import CapsuleTunnelError from robottelo.config import settings +from robottelo.exceptions import CLIFactoryError, CLIReturnCodeError from robottelo.host_helpers.repository_mixins import initiate_repo_helpers from robottelo.utils.manifest import clone -class CLIFactoryError(Exception): - """Indicates an error occurred while creating an entity using hammer""" - - def create_object(cli_object, options, values=None, credentials=None): """ Creates with dictionary of arguments. diff --git a/robottelo/host_helpers/satellite_mixins.py b/robottelo/host_helpers/satellite_mixins.py index 263510f6783..b17325a8492 100644 --- a/robottelo/host_helpers/satellite_mixins.py +++ b/robottelo/host_helpers/satellite_mixins.py @@ -7,7 +7,6 @@ import requests -from robottelo.cli.base import CLIReturnCodeError from robottelo.cli.proxy import CapsuleTunnelError from robottelo.config import settings from robottelo.constants import ( @@ -16,6 +15,7 @@ PUPPET_COMMON_INSTALLER_OPTS, PUPPET_SATELLITE_INSTALLER, ) +from robottelo.exceptions import CLIReturnCodeError from robottelo.host_helpers.api_factory import APIFactory from robottelo.host_helpers.cli_factory import CLIFactory from robottelo.host_helpers.ui_factory import UIFactory diff --git a/robottelo/hosts.py b/robottelo/hosts.py index aa72002146f..9e40bc62596 100644 --- a/robottelo/hosts.py +++ b/robottelo/hosts.py @@ -30,7 +30,6 @@ from robottelo import constants from robottelo.cli.base import Base -from robottelo.cli.factory import CLIFactoryError from robottelo.config import ( configure_airgun, configure_nailgun, @@ -53,7 +52,7 @@ RHSSO_USER_UPDATE, SATELLITE_VERSION, ) -from robottelo.exceptions import DownloadFileError, HostPingFailed +from robottelo.exceptions import CLIFactoryError, DownloadFileError, HostPingFailed from robottelo.host_helpers import CapsuleMixins, ContentHostMixins, SatelliteMixins from robottelo.logging import logger from robottelo.utils import validate_ssh_pub_key diff --git a/tests/foreman/api/test_errata.py b/tests/foreman/api/test_errata.py index ba64ce1c9a0..ac76fbff809 100644 --- a/tests/foreman/api/test_errata.py +++ b/tests/foreman/api/test_errata.py @@ -24,7 +24,6 @@ import pytest from robottelo import constants -from robottelo.cli.factory import setup_org_for_a_custom_repo, setup_org_for_a_rh_repo from robottelo.cli.host import Host from robottelo.config import settings from robottelo.constants import DEFAULT_SUBSCRIPTION_NAME @@ -49,8 +48,10 @@ def activation_key(module_org, module_lce): @pytest.fixture(scope='module') -def rh_repo(module_entitlement_manifest_org, module_lce, module_cv, activation_key): - return setup_org_for_a_rh_repo( +def rh_repo( + module_entitlement_manifest_org, module_lce, module_cv, activation_key, module_target_sat +): + return module_target_sat.cli_factory.setup_org_for_a_rh_repo( { 'product': constants.PRDS['rhel'], 'repository-set': constants.REPOSET['rhst7'], @@ -64,8 +65,8 @@ def rh_repo(module_entitlement_manifest_org, module_lce, module_cv, activation_k @pytest.fixture(scope='module') -def custom_repo(module_org, module_lce, module_cv, activation_key): - return setup_org_for_a_custom_repo( +def custom_repo(module_org, module_lce, module_cv, activation_key, module_target_sat): + return module_target_sat.cli_factory.setup_org_for_a_custom_repo( { 'url': settings.repos.yum_9.url, 'organization-id': module_org.id, @@ -471,7 +472,7 @@ def test_positive_get_applicable_for_host(setup_content_rhel6, rhel6_contenthost @pytest.mark.tier3 -def test_positive_get_diff_for_cv_envs(): +def test_positive_get_diff_for_cv_envs(module_target_sat): """Generate a difference in errata between a set of environments for a content view @@ -494,7 +495,7 @@ def test_positive_get_diff_for_cv_envs(): content_view = entities.ContentView(organization=org).create() activation_key = entities.ActivationKey(environment=env, organization=org).create() for repo_url in [settings.repos.yum_9.url, CUSTOM_REPO_URL]: - setup_org_for_a_custom_repo( + module_target_sat.cli_factory.setup_org_for_a_custom_repo( { 'url': repo_url, 'organization-id': org.id, @@ -739,9 +740,9 @@ def rh_repo_module_manifest(module_entitlement_manifest_org, module_target_sat): @pytest.fixture(scope='module') -def rhel8_custom_repo_cv(module_entitlement_manifest_org): +def rhel8_custom_repo_cv(module_entitlement_manifest_org, module_target_sat): """Create repo and publish CV so that packages are in Library""" - return setup_org_for_a_custom_repo( + return module_target_sat.cli_factory.setup_org_for_a_custom_repo( { 'url': settings.repos.module_stream_1.url, 'organization-id': module_entitlement_manifest_org.id, diff --git a/tests/foreman/api/test_repositories.py b/tests/foreman/api/test_repositories.py index 58cbd9792b2..ce4110ec3e6 100644 --- a/tests/foreman/api/test_repositories.py +++ b/tests/foreman/api/test_repositories.py @@ -23,9 +23,9 @@ from requests.exceptions import HTTPError from robottelo import constants -from robottelo.cli.base import CLIReturnCodeError from robottelo.config import settings from robottelo.constants import DEFAULT_ARCHITECTURE, MIRRORING_POLICIES, REPOS +from robottelo.exceptions import CLIReturnCodeError from robottelo.utils.datafactory import parametrized diff --git a/tests/foreman/cli/test_acs.py b/tests/foreman/cli/test_acs.py index 39ba1701dee..37750aed9bf 100644 --- a/tests/foreman/cli/test_acs.py +++ b/tests/foreman/cli/test_acs.py @@ -19,8 +19,8 @@ from fauxfactory import gen_alphanumeric import pytest -from robottelo.cli.base import CLIReturnCodeError from robottelo.constants.repos import PULP_FIXTURE_ROOT, PULP_SUBPATHS_COMBINED +from robottelo.exceptions import CLIReturnCodeError ACS_UPDATED = 'Alternate Content Source updated.' ACS_DELETED = 'Alternate Content Source deleted.' diff --git a/tests/foreman/cli/test_activationkey.py b/tests/foreman/cli/test_activationkey.py index 126b4144d3c..99edb59020d 100644 --- a/tests/foreman/cli/test_activationkey.py +++ b/tests/foreman/cli/test_activationkey.py @@ -24,27 +24,15 @@ import pytest from robottelo.cli.activationkey import ActivationKey -from robottelo.cli.base import CLIReturnCodeError from robottelo.cli.contentview import ContentView from robottelo.cli.defaults import Defaults -from robottelo.cli.factory import ( - CLIFactoryError, - add_role_permissions, - make_activation_key, - make_content_view, - make_host_collection, - make_lifecycle_environment, - make_role, - make_user, - setup_org_for_a_custom_repo, - setup_org_for_a_rh_repo, -) from robottelo.cli.lifecycleenvironment import LifecycleEnvironment from robottelo.cli.repository import Repository from robottelo.cli.subscription import Subscription from robottelo.cli.user import User from robottelo.config import settings from robottelo.constants import PRDS, REPOS, REPOSET +from robottelo.exceptions import CLIFactoryError, CLIReturnCodeError from robottelo.hosts import ContentHost from robottelo.utils.datafactory import ( invalid_values_list, @@ -82,7 +70,7 @@ def test_positive_create_with_name(module_target_sat, module_entitlement_manifes @pytest.mark.tier1 @pytest.mark.parametrize('desc', **parametrized(valid_data_list())) -def test_positive_create_with_description(desc, module_org): +def test_positive_create_with_description(desc, module_org, module_target_sat): """Create Activation key for all variations of Description :id: 5a5ca7f9-1449-4365-ac8a-978605620bf2 @@ -93,12 +81,14 @@ def test_positive_create_with_description(desc, module_org): :parametrized: yes """ - new_ak = make_activation_key({'organization-id': module_org.id, 'description': desc}) + new_ak = module_target_sat.cli_factory.make_activation_key( + {'organization-id': module_org.id, 'description': desc} + ) assert new_ak['description'] == desc @pytest.mark.tier1 -def test_positive_create_with_default_lce_by_id(module_org, get_default_env): +def test_positive_create_with_default_lce_by_id(module_org, get_default_env, target_sat): """Create Activation key with associated default environment :id: 9171adb2-c9ac-4cda-978f-776826668aa3 @@ -108,14 +98,14 @@ def test_positive_create_with_default_lce_by_id(module_org, get_default_env): :CaseImportance: Critical """ lce = get_default_env - new_ak_env = make_activation_key( + new_ak_env = target_sat.cli_factory.make_activation_key( {'organization-id': module_org.id, 'lifecycle-environment-id': lce['id']} ) assert new_ak_env['lifecycle-environment'] == lce['name'] @pytest.mark.tier1 -def test_positive_create_with_non_default_lce(module_org): +def test_positive_create_with_non_default_lce(module_org, module_target_sat): """Create Activation key with associated custom environment :id: ad4d4611-3fb5-4449-ae47-305f9931350e @@ -125,15 +115,17 @@ def test_positive_create_with_non_default_lce(module_org): :CaseImportance: Critical """ - env = make_lifecycle_environment({'organization-id': module_org.id}) - new_ak_env = make_activation_key( + env = module_target_sat.cli_factory.make_lifecycle_environment( + {'organization-id': module_org.id} + ) + new_ak_env = module_target_sat.cli_factory.make_activation_key( {'organization-id': module_org.id, 'lifecycle-environment-id': env['id']} ) assert new_ak_env['lifecycle-environment'] == env['name'] @pytest.mark.tier1 -def test_positive_create_with_default_lce_by_name(module_org, get_default_env): +def test_positive_create_with_default_lce_by_name(module_org, get_default_env, module_target_sat): """Create Activation key with associated environment by name :id: 7410f7c4-e8b5-4080-b6d2-65dbcedffe8a @@ -143,7 +135,7 @@ def test_positive_create_with_default_lce_by_name(module_org, get_default_env): :CaseImportance: Critical """ lce = get_default_env - new_ak_env = make_activation_key( + new_ak_env = module_target_sat.cli_factory.make_activation_key( {'organization-id': module_org.id, 'lifecycle-environment': lce['name']} ) assert new_ak_env['lifecycle-environment'] == lce['name'] @@ -151,7 +143,7 @@ def test_positive_create_with_default_lce_by_name(module_org, get_default_env): @pytest.mark.tier2 @pytest.mark.parametrize('name', **parametrized(valid_data_list())) -def test_positive_create_with_cv(name, module_org, get_default_env): +def test_positive_create_with_cv(name, module_org, get_default_env, module_target_sat): """Create Activation key for all variations of Content Views :id: ec7b1af5-c3f4-40c3-b1df-c69c02a3b9a7 @@ -163,8 +155,10 @@ def test_positive_create_with_cv(name, module_org, get_default_env): :parametrized: yes """ - new_cv = make_content_view({'name': name, 'organization-id': module_org.id}) - new_ak_cv = make_activation_key( + new_cv = module_target_sat.cli_factory.make_content_view( + {'name': name, 'organization-id': module_org.id} + ) + new_ak_cv = module_target_sat.cli_factory.make_activation_key( { 'content-view': new_cv['name'], 'environment': get_default_env['name'], @@ -175,7 +169,7 @@ def test_positive_create_with_cv(name, module_org, get_default_env): @pytest.mark.tier1 -def test_positive_create_with_usage_limit_default(module_org): +def test_positive_create_with_usage_limit_default(module_org, module_target_sat): """Create Activation key with default Usage limit (Unlimited) :id: cba13c72-9845-486d-beff-e0fb55bb762c @@ -184,12 +178,12 @@ def test_positive_create_with_usage_limit_default(module_org): :CaseImportance: Critical """ - new_ak = make_activation_key({'organization-id': module_org.id}) + new_ak = module_target_sat.cli_factory.make_activation_key({'organization-id': module_org.id}) assert new_ak['host-limit'] == 'Unlimited' @pytest.mark.tier1 -def test_positive_create_with_usage_limit_finite(module_org): +def test_positive_create_with_usage_limit_finite(module_org, module_target_sat): """Create Activation key with finite Usage limit :id: 529a0f9e-977f-4e9d-a1af-88bb98c28a6a @@ -198,13 +192,15 @@ def test_positive_create_with_usage_limit_finite(module_org): :CaseImportance: Critical """ - new_ak = make_activation_key({'organization-id': module_org.id, 'max-hosts': '10'}) + new_ak = module_target_sat.cli_factory.make_activation_key( + {'organization-id': module_org.id, 'max-hosts': '10'} + ) assert new_ak['host-limit'] == '10' @pytest.mark.tier2 @pytest.mark.skipif((not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url') -def test_positive_create_content_and_check_enabled(module_org): +def test_positive_create_content_and_check_enabled(module_org, module_target_sat): """Create activation key and add content to it. Check enabled state. :id: abfc6c6e-acd1-4761-b309-7e68e1d17172 @@ -216,7 +212,7 @@ def test_positive_create_content_and_check_enabled(module_org): :CaseLevel: Integration """ - result = setup_org_for_a_custom_repo( + result = module_target_sat.cli_factory.setup_org_for_a_custom_repo( {'url': settings.repos.yum_0.url, 'organization-id': module_org.id} ) content = ActivationKey.product_content( @@ -227,7 +223,7 @@ def test_positive_create_content_and_check_enabled(module_org): @pytest.mark.tier2 @pytest.mark.parametrize('name', **parametrized(invalid_values_list())) -def test_negative_create_with_invalid_name(name, module_org): +def test_negative_create_with_invalid_name(name, module_org, module_target_sat): """Create Activation key with invalid Name :id: d9b7e3a9-1d24-4e47-bd4a-dce75772d829 @@ -240,7 +236,9 @@ def test_negative_create_with_invalid_name(name, module_org): :parametrized: yes """ with pytest.raises(CLIFactoryError) as raise_ctx: - make_activation_key({'organization-id': module_org.id, 'name': name}) + module_target_sat.cli_factory.make_activation_key( + {'organization-id': module_org.id, 'name': name} + ) if name in ['', ' ', '\t']: assert 'Name must contain at least 1 character' in str(raise_ctx) if len(name) > 255: @@ -252,7 +250,7 @@ def test_negative_create_with_invalid_name(name, module_org): 'limit', **parametrized([value for value in invalid_values_list() if not value.isdigit()] + [0.5]), ) -def test_negative_create_with_usage_limit_with_not_integers(module_org, limit): +def test_negative_create_with_usage_limit_with_not_integers(module_org, limit, module_target_sat): """Create Activation key with non integers Usage Limit :id: 247ebc2e-c80f-488b-aeaf-6bf5eba55375 @@ -268,7 +266,9 @@ def test_negative_create_with_usage_limit_with_not_integers(module_org, limit): # invalid_values = [value for value in invalid_values_list() if not value.isdigit()] # invalid_values.append(0.5) with pytest.raises(CLIFactoryError) as raise_ctx: - make_activation_key({'organization-id': module_org.id, 'max-hosts': limit}) + module_target_sat.cli_factory.make_activation_key( + {'organization-id': module_org.id, 'max-hosts': limit} + ) if type(limit) is int: if limit < 1: assert 'Max hosts cannot be less than one' in str(raise_ctx) @@ -278,7 +278,9 @@ def test_negative_create_with_usage_limit_with_not_integers(module_org, limit): @pytest.mark.tier3 @pytest.mark.parametrize('invalid_values', ('-1', '-500', 0)) -def test_negative_create_with_usage_limit_with_invalid_integers(module_org, invalid_values): +def test_negative_create_with_usage_limit_with_invalid_integers( + module_org, invalid_values, module_target_sat +): """Create Activation key with invalid integers Usage Limit :id: 9089f756-fda8-4e28-855c-cf8273f7c6cd @@ -291,13 +293,15 @@ def test_negative_create_with_usage_limit_with_invalid_integers(module_org, inva :parametrized: yes """ with pytest.raises(CLIFactoryError) as raise_ctx: - make_activation_key({'organization-id': module_org.id, 'max-hosts': invalid_values}) + module_target_sat.cli_factory.make_activation_key( + {'organization-id': module_org.id, 'max-hosts': invalid_values} + ) assert 'Failed to create ActivationKey with data:' in str(raise_ctx) @pytest.mark.tier1 @pytest.mark.parametrize('name', **parametrized(valid_data_list())) -def test_positive_delete_by_name(name, module_org): +def test_positive_delete_by_name(name, module_org, module_target_sat): """Create Activation key and delete it for all variations of Activation key name @@ -309,14 +313,16 @@ def test_positive_delete_by_name(name, module_org): :parametrized: yes """ - new_ak = make_activation_key({'name': name, 'organization-id': module_org.id}) + new_ak = module_target_sat.cli_factory.make_activation_key( + {'name': name, 'organization-id': module_org.id} + ) ActivationKey.delete({'name': new_ak['name'], 'organization-id': module_org.id}) with pytest.raises(CLIReturnCodeError): ActivationKey.info({'id': new_ak['id']}) @pytest.mark.tier1 -def test_positive_delete_by_org_name(module_org): +def test_positive_delete_by_org_name(module_org, module_target_sat): """Create Activation key and delete it using organization name for which that key was created @@ -326,14 +332,14 @@ def test_positive_delete_by_org_name(module_org): :CaseImportance: High """ - new_ak = make_activation_key({'organization-id': module_org.id}) + new_ak = module_target_sat.cli_factory.make_activation_key({'organization-id': module_org.id}) ActivationKey.delete({'name': new_ak['name'], 'organization-id': module_org.id}) with pytest.raises(CLIReturnCodeError): ActivationKey.info({'id': new_ak['id']}) @pytest.mark.tier1 -def test_positive_delete_by_org_label(module_org): +def test_positive_delete_by_org_label(module_org, module_target_sat): """Create Activation key and delete it using organization label for which that key was created @@ -343,7 +349,7 @@ def test_positive_delete_by_org_label(module_org): :CaseImportance: High """ - new_ak = make_activation_key({'organization-id': module_org.id}) + new_ak = module_target_sat.cli_factory.make_activation_key({'organization-id': module_org.id}) ActivationKey.delete({'name': new_ak['name'], 'organization-label': module_org.label}) with pytest.raises(CLIReturnCodeError): ActivationKey.info({'id': new_ak['id']}) @@ -351,7 +357,7 @@ def test_positive_delete_by_org_label(module_org): @pytest.mark.tier2 @pytest.mark.upgrade -def test_positive_delete_with_cv(module_org): +def test_positive_delete_with_cv(module_org, module_target_sat): """Create activation key with content view assigned to it and delete it using activation key id @@ -361,15 +367,17 @@ def test_positive_delete_with_cv(module_org): :CaseLevel: Integration """ - new_cv = make_content_view({'organization-id': module_org.id}) - new_ak = make_activation_key({'organization-id': module_org.id, 'content-view': new_cv['name']}) + new_cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) + new_ak = module_target_sat.cli_factory.make_activation_key( + {'organization-id': module_org.id, 'content-view': new_cv['name']} + ) ActivationKey.delete({'id': new_ak['id']}) with pytest.raises(CLIReturnCodeError): ActivationKey.info({'id': new_ak['id']}) @pytest.mark.tier2 -def test_positive_delete_with_lce(module_org, get_default_env): +def test_positive_delete_with_lce(module_org, get_default_env, module_target_sat): """Create activation key with lifecycle environment assigned to it and delete it using activation key id @@ -379,7 +387,7 @@ def test_positive_delete_with_lce(module_org, get_default_env): :CaseLevel: Integration """ - new_ak = make_activation_key( + new_ak = module_target_sat.cli_factory.make_activation_key( {'organization-id': module_org.id, 'lifecycle-environment': get_default_env['name']} ) ActivationKey.delete({'id': new_ak['id']}) @@ -389,7 +397,7 @@ def test_positive_delete_with_lce(module_org, get_default_env): @pytest.mark.tier1 @pytest.mark.parametrize('name', **parametrized(valid_data_list())) -def test_positive_update_name_by_id(module_org, name): +def test_positive_update_name_by_id(module_org, name, module_target_sat): """Update Activation Key Name in Activation key searching by ID :id: bc304894-fd9b-4622-96e3-57c2257e26ca @@ -400,7 +408,9 @@ def test_positive_update_name_by_id(module_org, name): :parametrized: yes """ - activation_key = make_activation_key({'organization-id': module_org.id}) + activation_key = module_target_sat.cli_factory.make_activation_key( + {'organization-id': module_org.id} + ) ActivationKey.update( {'id': activation_key['id'], 'new-name': name, 'organization-id': module_org.id} ) @@ -409,7 +419,7 @@ def test_positive_update_name_by_id(module_org, name): @pytest.mark.tier1 -def test_positive_update_name_by_name(module_org): +def test_positive_update_name_by_name(module_org, module_target_sat): """Update Activation Key Name in an Activation key searching by name @@ -420,7 +430,9 @@ def test_positive_update_name_by_name(module_org): :CaseImportance: Critical """ new_name = gen_string('alpha') - activation_key = make_activation_key({'organization-id': module_org.id}) + activation_key = module_target_sat.cli_factory.make_activation_key( + {'organization-id': module_org.id} + ) ActivationKey.update( {'name': activation_key['name'], 'new-name': new_name, 'organization-id': module_org.id} ) @@ -430,7 +442,7 @@ def test_positive_update_name_by_name(module_org): @pytest.mark.tier1 @pytest.mark.parametrize('description', **parametrized(valid_data_list())) -def test_positive_update_description(description, module_org): +def test_positive_update_description(description, module_org, module_target_sat): """Update Description in an Activation key :id: 60a4e860-d99c-431e-b70b-9b0fa90d839b @@ -441,7 +453,9 @@ def test_positive_update_description(description, module_org): :parametrized: yes """ - activation_key = make_activation_key({'organization-id': module_org.id}) + activation_key = module_target_sat.cli_factory.make_activation_key( + {'organization-id': module_org.id} + ) ActivationKey.update( { 'description': description, @@ -454,7 +468,7 @@ def test_positive_update_description(description, module_org): @pytest.mark.tier2 -def test_positive_update_lce(module_org, get_default_env): +def test_positive_update_lce(module_org, get_default_env, module_target_sat): """Update Environment in an Activation key :id: 55aaee60-b8c8-49f0-995a-6c526b9b653b @@ -463,11 +477,13 @@ def test_positive_update_lce(module_org, get_default_env): :CaseLevel: Integration """ - ak_env = make_activation_key( + ak_env = module_target_sat.cli_factory.make_activation_key( {'organization-id': module_org.id, 'lifecycle-environment-id': get_default_env['id']} ) - env = make_lifecycle_environment({'organization-id': module_org.id}) - new_cv = make_content_view({'organization-id': module_org.id}) + env = module_target_sat.cli_factory.make_lifecycle_environment( + {'organization-id': module_org.id} + ) + new_cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) ContentView.publish({'id': new_cv['id']}) cvv = ContentView.info({'id': new_cv['id']})['versions'][0] ContentView.version_promote({'id': cvv['id'], 'to-lifecycle-environment-id': env['id']}) @@ -484,7 +500,7 @@ def test_positive_update_lce(module_org, get_default_env): @pytest.mark.tier2 -def test_positive_update_cv(module_org): +def test_positive_update_cv(module_org, module_target_sat): """Update Content View in an Activation key :id: aa94997d-fc9b-4532-aeeb-9f27b9834914 @@ -493,9 +509,11 @@ def test_positive_update_cv(module_org): :CaseLevel: Integration """ - cv = make_content_view({'organization-id': module_org.id}) - ak_cv = make_activation_key({'organization-id': module_org.id, 'content-view-id': cv['id']}) - new_cv = make_content_view({'organization-id': module_org.id}) + cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) + ak_cv = module_target_sat.cli_factory.make_activation_key( + {'organization-id': module_org.id, 'content-view-id': cv['id']} + ) + new_cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) ActivationKey.update( {'content-view': new_cv['name'], 'name': ak_cv['name'], 'organization-id': module_org.id} ) @@ -504,7 +522,7 @@ def test_positive_update_cv(module_org): @pytest.mark.tier1 -def test_positive_update_usage_limit_to_finite_number(module_org): +def test_positive_update_usage_limit_to_finite_number(module_org, module_target_sat): """Update Usage limit from Unlimited to a finite number :id: a55bb8dc-c7d8-4a6a-ac0f-1d5a377da543 @@ -513,7 +531,7 @@ def test_positive_update_usage_limit_to_finite_number(module_org): :CaseImportance: Critical """ - new_ak = make_activation_key({'organization-id': module_org.id}) + new_ak = module_target_sat.cli_factory.make_activation_key({'organization-id': module_org.id}) assert new_ak['host-limit'] == 'Unlimited' ActivationKey.update( {'max-hosts': '2147483647', 'name': new_ak['name'], 'organization-id': module_org.id} @@ -523,7 +541,7 @@ def test_positive_update_usage_limit_to_finite_number(module_org): @pytest.mark.tier1 -def test_positive_update_usage_limit_to_unlimited(module_org): +def test_positive_update_usage_limit_to_unlimited(module_org, module_target_sat): """Update Usage limit from definite number to Unlimited :id: 0b83657b-41d1-4fb2-9c23-c36011322b83 @@ -532,7 +550,9 @@ def test_positive_update_usage_limit_to_unlimited(module_org): :CaseImportance: Critical """ - new_ak = make_activation_key({'organization-id': module_org.id, 'max-hosts': '10'}) + new_ak = module_target_sat.cli_factory.make_activation_key( + {'organization-id': module_org.id, 'max-hosts': '10'} + ) assert new_ak['host-limit'] == '10' ActivationKey.update( {'unlimited-hosts': True, 'name': new_ak['name'], 'organization-id': module_org.id} @@ -543,7 +563,7 @@ def test_positive_update_usage_limit_to_unlimited(module_org): @pytest.mark.tier2 @pytest.mark.parametrize('name', **parametrized(invalid_values_list())) -def test_negative_update_name(module_org, name): +def test_negative_update_name(module_org, name, module_target_sat): """Try to update Activation Key using invalid value for its name :id: b75e7c38-fde2-4110-ba65-4157319fc159 @@ -555,7 +575,7 @@ def test_negative_update_name(module_org, name): :parametrized: yes """ - new_ak = make_activation_key({'organization-id': module_org.id}) + new_ak = module_target_sat.cli_factory.make_activation_key({'organization-id': module_org.id}) with pytest.raises(CLIReturnCodeError) as raise_ctx: ActivationKey.update( {'id': new_ak['id'], 'new-name': name, 'organization-id': module_org.id} @@ -564,7 +584,7 @@ def test_negative_update_name(module_org, name): @pytest.mark.tier2 -def test_negative_update_usage_limit(module_org): +def test_negative_update_usage_limit(module_org, module_target_sat): """Try to update Activation Key using invalid value for its usage limit attribute @@ -575,7 +595,7 @@ def test_negative_update_usage_limit(module_org): :CaseImportance: Low """ - new_ak = make_activation_key({'organization-id': module_org.id}) + new_ak = module_target_sat.cli_factory.make_activation_key({'organization-id': module_org.id}) with pytest.raises(CLIReturnCodeError) as raise_ctx: ActivationKey.update( {'max-hosts': int('9' * 20), 'id': new_ak['id'], 'organization-id': module_org.id} @@ -606,12 +626,12 @@ def test_positive_usage_limit(module_org, target_sat): :CaseLevel: System """ - env = make_lifecycle_environment({'organization-id': module_org.id}) - new_cv = make_content_view({'organization-id': module_org.id}) + env = target_sat.cli_factory.make_lifecycle_environment({'organization-id': module_org.id}) + new_cv = target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) ContentView.publish({'id': new_cv['id']}) cvv = ContentView.info({'id': new_cv['id']})['versions'][0] ContentView.version_promote({'id': cvv['id'], 'to-lifecycle-environment-id': env['id']}) - new_ak = make_activation_key( + new_ak = target_sat.cli_factory.make_activation_key( { 'lifecycle-environment-id': env['id'], 'content-view': new_cv['name'], @@ -633,7 +653,7 @@ def test_positive_usage_limit(module_org, target_sat): @pytest.mark.tier2 @pytest.mark.parametrize('host_col_name', **parametrized(valid_data_list())) -def test_positive_update_host_collection(module_org, host_col_name): +def test_positive_update_host_collection(module_org, host_col_name, module_target_sat): """Test that host collections can be associated to Activation Keys @@ -648,8 +668,10 @@ def test_positive_update_host_collection(module_org, host_col_name): :parametrized: yes """ - activation_key = make_activation_key({'organization-id': module_org.id}) - new_host_col_name = make_host_collection( + activation_key = module_target_sat.cli_factory.make_activation_key( + {'organization-id': module_org.id} + ) + new_host_col_name = module_target_sat.cli_factory.make_host_collection( {'name': host_col_name, 'organization-id': module_org.id} )['name'] # Assert that name matches data passed @@ -667,7 +689,7 @@ def test_positive_update_host_collection(module_org, host_col_name): @pytest.mark.run_in_one_thread @pytest.mark.tier2 -def test_positive_update_host_collection_with_default_org(module_org): +def test_positive_update_host_collection_with_default_org(module_org, module_target_sat): """Test that host collection can be associated to Activation Keys with specified default organization setting in config @@ -680,8 +702,10 @@ def test_positive_update_host_collection_with_default_org(module_org): """ Defaults.add({'param-name': 'organization_id', 'param-value': module_org.id}) try: - activation_key = make_activation_key({'organization-id': module_org.id}) - host_col = make_host_collection() + activation_key = module_target_sat.cli_factory.make_activation_key( + {'organization-id': module_org.id} + ) + host_col = module_target_sat.cli_factory.make_host_collection() ActivationKey.add_host_collection( {'host-collection': host_col['name'], 'name': activation_key['name']} ) @@ -693,7 +717,7 @@ def test_positive_update_host_collection_with_default_org(module_org): @pytest.mark.run_in_one_thread @pytest.mark.tier3 -def test_positive_add_redhat_product(function_entitlement_manifest_org): +def test_positive_add_redhat_product(function_entitlement_manifest_org, target_sat): """Test that RH product can be associated to Activation Keys :id: 7b15de8e-edde-41aa-937b-ad6aa529891a @@ -707,7 +731,7 @@ def test_positive_add_redhat_product(function_entitlement_manifest_org): # Using CDN as we need this repo to be RH one no matter are we in # downstream or cdn - result = setup_org_for_a_rh_repo( + result = target_sat.cli_factory.setup_org_for_a_rh_repo( { 'product': PRDS['rhel'], 'repository-set': REPOSET['rhst7'], @@ -724,7 +748,7 @@ def test_positive_add_redhat_product(function_entitlement_manifest_org): @pytest.mark.tier3 @pytest.mark.skipif((not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url') -def test_positive_add_custom_product(module_org): +def test_positive_add_custom_product(module_org, module_target_sat): """Test that custom product can be associated to Activation Keys :id: 96ace967-e165-4069-8ff7-f54c4c822de0 @@ -736,7 +760,7 @@ def test_positive_add_custom_product(module_org): :BZ: 1426386 """ - result = setup_org_for_a_custom_repo( + result = module_target_sat.cli_factory.setup_org_for_a_custom_repo( {'url': settings.repos.yum_0.url, 'organization-id': module_org.id} ) repo = Repository.info({'id': result['repository-id']}) @@ -773,7 +797,7 @@ def test_positive_add_redhat_and_custom_products( org = function_entitlement_manifest_org # Using CDN as we need this repo to be RH one no matter are we in # downstream or cdn - result = setup_org_for_a_rh_repo( + result = module_target_sat.cli_factory.setup_org_for_a_rh_repo( { 'product': PRDS['rhel'], 'repository-set': REPOSET['rhst7'], @@ -782,7 +806,7 @@ def test_positive_add_redhat_and_custom_products( }, force_use_cdn=True, ) - result = setup_org_for_a_custom_repo( + result = module_target_sat.cli_factory.setup_org_for_a_custom_repo( { 'url': settings.repos.yum_0.url, 'organization-id': org.id, @@ -818,7 +842,7 @@ def test_positive_delete_manifest(function_entitlement_manifest_org, target_sat) :CaseAutomation: Automated """ org = function_entitlement_manifest_org - new_ak = make_activation_key({'organization-id': org.id}) + new_ak = target_sat.cli_factory.make_activation_key({'organization-id': org.id}) ak_subs = target_sat.cli.ActivationKey.subscriptions( {'id': new_ak['id'], 'organization-id': org.id} ) @@ -850,7 +874,7 @@ def test_positive_delete_subscription(function_entitlement_manifest_org, module_ :CaseLevel: Integration """ org = function_entitlement_manifest_org - new_ak = make_activation_key({'organization-id': org.id}) + new_ak = module_target_sat.cli_factory.make_activation_key({'organization-id': org.id}) subscription_result = Subscription.list( {'organization-id': org.id, 'order': 'id desc'}, per_page=False ) @@ -886,13 +910,13 @@ def test_positive_update_aks_to_chost(module_org, rhel7_contenthost, target_sat) :CaseLevel: System """ - env = make_lifecycle_environment({'organization-id': module_org.id}) - new_cv = make_content_view({'organization-id': module_org.id}) + env = target_sat.make_lifecycle_environment({'organization-id': module_org.id}) + new_cv = target_sat.make_content_view({'organization-id': module_org.id}) ContentView.publish({'id': new_cv['id']}) cvv = ContentView.info({'id': new_cv['id']})['versions'][0] ContentView.version_promote({'id': cvv['id'], 'to-lifecycle-environment-id': env['id']}) new_aks = [ - make_activation_key( + target_sat.cli_factory.make_activation_key( { 'lifecycle-environment-id': env['id'], 'content-view': new_cv['name'], @@ -948,7 +972,9 @@ def test_positive_list_by_name(module_org, name, module_target_sat): :parametrized: yes """ - make_activation_key({'organization-id': module_org.id, 'name': name}) + module_target_sat.cli_factory.make_activation_key( + {'organization-id': module_org.id, 'name': name} + ) result = module_target_sat.cli.ActivationKey.list( {'name': name, 'organization-id': module_org.id} ) @@ -966,8 +992,10 @@ def test_positive_list_by_cv_id(module_org, module_target_sat): :CaseImportance: High """ - cv = make_content_view({'organization-id': module_org.id}) - make_activation_key({'organization-id': module_org.id, 'content-view-id': cv['id']}) + cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) + module_target_sat.cli_factory.make_activation_key( + {'organization-id': module_org.id, 'content-view-id': cv['id']} + ) result = module_target_sat.cli.ActivationKey.list( {'content-view-id': cv['id'], 'organization-id': module_org.id} ) @@ -987,14 +1015,18 @@ def test_positive_create_using_old_name(module_org, module_target_sat): :CaseImportance: High """ name = gen_string('utf8') - activation_key = make_activation_key({'organization-id': module_org.id, 'name': name}) + activation_key = module_target_sat.cli_factory.make_activation_key( + {'organization-id': module_org.id, 'name': name} + ) new_name = gen_string('utf8') module_target_sat.cli.ActivationKey.update( {'id': activation_key['id'], 'new-name': new_name, 'organization-id': module_org.id} ) activation_key = module_target_sat.cli.ActivationKey.info({'id': activation_key['id']}) assert activation_key['name'] == new_name - new_activation_key = make_activation_key({'name': name, 'organization-id': module_org.id}) + new_activation_key = module_target_sat.cli_factory.make_activation_key( + {'name': name, 'organization-id': module_org.id} + ) assert new_activation_key['name'] == name @@ -1022,8 +1054,10 @@ def test_positive_remove_host_collection_by_id(module_org, module_target_sat): :BZ: 1336716 """ - activation_key = make_activation_key({'organization-id': module_org.id}) - new_host_col = make_host_collection( + activation_key = module_target_sat.cli_factory.make_activation_key( + {'organization-id': module_org.id} + ) + new_host_col = module_target_sat.cli_factory.make_host_collection( {'name': gen_string('alpha'), 'organization-id': module_org.id} ) module_target_sat.cli.ActivationKey.add_host_collection( @@ -1071,8 +1105,12 @@ def test_positive_remove_host_collection_by_name(module_org, host_col, module_ta :parametrized: yes """ - activation_key = make_activation_key({'organization-id': module_org.id}) - new_host_col = make_host_collection({'name': host_col, 'organization-id': module_org.id}) + activation_key = module_target_sat.cli_factory.make_activation_key( + {'organization-id': module_org.id} + ) + new_host_col = module_target_sat.cli_factory.make_host_collection( + {'name': host_col, 'organization-id': module_org.id} + ) # Assert that name matches data passed assert new_host_col['name'] == host_col module_target_sat.cli.ActivationKey.add_host_collection( @@ -1113,7 +1151,7 @@ def test_create_ak_with_syspurpose_set(module_entitlement_manifest_org, module_t :BZ: 1789028 """ # Requires Cls org and manifest. Manifest is for self-support values. - new_ak = make_activation_key( + new_ak = module_target_sat.cli_factory.make_activation_key( { 'purpose-addons': "test-addon1, test-addon2", 'purpose-role': "test-role", @@ -1169,7 +1207,7 @@ def test_update_ak_with_syspurpose_values(module_entitlement_manifest_org, modul # Requires Cls org and manifest. Manifest is for self-support values. # Create an AK with no system purpose values set org = module_entitlement_manifest_org - new_ak = make_activation_key({'organization-id': org.id}) + new_ak = module_target_sat.cli_factory.make_activation_key({'organization-id': org.id}) # Assert system purpose values are null after creating the AK and adding the manifest. assert new_ak['system-purpose']['purpose-addons'] == '' assert new_ak['system-purpose']['purpose-role'] == '' @@ -1236,7 +1274,7 @@ def test_positive_add_subscription_by_id(module_entitlement_manifest_org, module :BZ: 1463685 """ org_id = module_entitlement_manifest_org.id - ackey_id = make_activation_key({'organization-id': org_id})['id'] + ackey_id = module_target_sat.cli_factory.make_activation_key({'organization-id': org_id})['id'] subs_id = module_target_sat.cli.Subscription.list({'organization-id': org_id}, per_page=False) result = module_target_sat.cli.ActivationKey.add_subscription( {'id': ackey_id, 'subscription-id': subs_id[0]['id']} @@ -1246,7 +1284,7 @@ def test_positive_add_subscription_by_id(module_entitlement_manifest_org, module @pytest.mark.tier1 @pytest.mark.parametrize('new_name', **parametrized(valid_data_list())) -def test_positive_copy_by_parent_id(module_org, new_name): +def test_positive_copy_by_parent_id(module_org, new_name, module_target_sat): """Copy Activation key for all valid Activation Key name variations @@ -1258,7 +1296,9 @@ def test_positive_copy_by_parent_id(module_org, new_name): :parametrized: yes """ - parent_ak = make_activation_key({'organization-id': module_org.id}) + parent_ak = module_target_sat.cli_factory.make_activation_key( + {'organization-id': module_org.id} + ) result = ActivationKey.copy( {'id': parent_ak['id'], 'new-name': new_name, 'organization-id': module_org.id} ) @@ -1266,7 +1306,7 @@ def test_positive_copy_by_parent_id(module_org, new_name): @pytest.mark.tier1 -def test_positive_copy_by_parent_name(module_org): +def test_positive_copy_by_parent_name(module_org, module_target_sat): """Copy Activation key by passing name of parent :id: 5d5405e6-3b26-47a3-96ff-f6c0f6c32607 @@ -1275,7 +1315,9 @@ def test_positive_copy_by_parent_name(module_org): :CaseImportance: Critical """ - parent_ak = make_activation_key({'organization-id': module_org.id}) + parent_ak = module_target_sat.cli_factory.make_activation_key( + {'organization-id': module_org.id} + ) result = ActivationKey.copy( { 'name': parent_ak['name'], @@ -1287,7 +1329,7 @@ def test_positive_copy_by_parent_name(module_org): @pytest.mark.tier1 -def test_negative_copy_with_same_name(module_org): +def test_negative_copy_with_same_name(module_org, module_target_sat): """Copy activation key with duplicate name :id: f867c468-4155-495c-a1e5-c04d9868a2e0 @@ -1295,7 +1337,9 @@ def test_negative_copy_with_same_name(module_org): :expectedresults: Activation key is not successfully copied """ - parent_ak = make_activation_key({'organization-id': module_org.id}) + parent_ak = module_target_sat.cli_factory.make_activation_key( + {'organization-id': module_org.id} + ) with pytest.raises(CLIReturnCodeError) as raise_ctx: ActivationKey.copy( { @@ -1312,7 +1356,7 @@ def test_negative_copy_with_same_name(module_org): @pytest.mark.skip_if_not_set('fake_manifest') @pytest.mark.tier2 @pytest.mark.upgrade -def test_positive_copy_subscription(module_entitlement_manifest_org): +def test_positive_copy_subscription(module_entitlement_manifest_org, module_target_sat): """Copy Activation key and verify contents :id: f4ee8096-4120-4d06-8c9a-57ac1eaa8f68 @@ -1329,7 +1373,7 @@ def test_positive_copy_subscription(module_entitlement_manifest_org): """ # Begin test setup org = module_entitlement_manifest_org - parent_ak = make_activation_key({'organization-id': org.id}) + parent_ak = module_target_sat.cli_factory.make_activation_key({'organization-id': org.id}) subscription_result = Subscription.list({'organization-id': org.id}, per_page=False) ActivationKey.add_subscription( {'id': parent_ak['id'], 'subscription-id': subscription_result[0]['id']} @@ -1346,7 +1390,7 @@ def test_positive_copy_subscription(module_entitlement_manifest_org): @pytest.mark.tier1 -def test_positive_update_autoattach_toggle(module_org): +def test_positive_update_autoattach_toggle(module_org, module_target_sat): """Update Activation key with inverse auto-attach value :id: de3b5fb7-7963-420a-b4c9-c66e78a111dc @@ -1361,7 +1405,7 @@ def test_positive_update_autoattach_toggle(module_org): :CaseImportance: Critical """ - new_ak = make_activation_key({'organization-id': module_org.id}) + new_ak = module_target_sat.cli_factory.make_activation_key({'organization-id': module_org.id}) attach_value = new_ak['auto-attach'] # invert value new_value = 'false' if attach_value == 'true' else 'true' @@ -1373,7 +1417,7 @@ def test_positive_update_autoattach_toggle(module_org): @pytest.mark.tier1 -def test_positive_update_autoattach(module_org): +def test_positive_update_autoattach(module_org, module_target_sat): """Update Activation key with valid auto-attach values :id: 9e18b950-6f0f-4f82-a3ac-ef6aba950a78 @@ -1382,7 +1426,7 @@ def test_positive_update_autoattach(module_org): :CaseImportance: Critical """ - new_ak = make_activation_key({'organization-id': module_org.id}) + new_ak = module_target_sat.cli_factory.make_activation_key({'organization-id': module_org.id}) for new_value in ('1', '0', 'true', 'false', 'yes', 'no'): result = ActivationKey.update( {'auto-attach': new_value, 'id': new_ak['id'], 'organization-id': module_org.id} @@ -1391,7 +1435,7 @@ def test_positive_update_autoattach(module_org): @pytest.mark.tier2 -def test_negative_update_autoattach(module_org): +def test_negative_update_autoattach(module_org, module_target_sat): """Attempt to update Activation key with bad auto-attach value :id: 54b6f808-ff54-4e69-a54d-e1f99a4652f9 @@ -1406,7 +1450,7 @@ def test_negative_update_autoattach(module_org): :CaseImportance: Low """ - new_ak = make_activation_key({'organization-id': module_org.id}) + new_ak = module_target_sat.cli_factory.make_activation_key({'organization-id': module_org.id}) with pytest.raises(CLIReturnCodeError) as exe: ActivationKey.update( { @@ -1420,7 +1464,7 @@ def test_negative_update_autoattach(module_org): @pytest.mark.tier3 @pytest.mark.skipif((not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url') -def test_positive_content_override(module_org): +def test_positive_content_override(module_org, module_target_sat): """Positive content override :id: a4912cc0-3bf7-4e90-bb51-ec88b2fad227 @@ -1436,7 +1480,7 @@ def test_positive_content_override(module_org): :CaseLevel: System """ - result = setup_org_for_a_custom_repo( + result = module_target_sat.cli_factory.setup_org_for_a_custom_repo( {'url': settings.repos.yum_0.url, 'organization-id': module_org.id} ) content = ActivationKey.product_content( @@ -1459,7 +1503,7 @@ def test_positive_content_override(module_org): @pytest.mark.tier2 -def test_positive_remove_user(module_org): +def test_positive_remove_user(module_org, module_target_sat): """Delete any user who has previously created an activation key and check that activation key still exists @@ -1470,7 +1514,7 @@ def test_positive_remove_user(module_org): :BZ: 1291271 """ password = gen_string('alpha') - user = make_user({'password': password, 'admin': 'true'}) + user = module_target_sat.cli_factory.make_user({'password': password, 'admin': 'true'}) ak = ActivationKey.with_user(username=user['login'], password=password).create( {'name': gen_string('alpha'), 'organization-id': module_org.id} ) @@ -1483,7 +1527,9 @@ def test_positive_remove_user(module_org): @pytest.mark.run_in_one_thread @pytest.mark.tier3 -def test_positive_view_subscriptions_by_non_admin_user(module_entitlement_manifest_org): +def test_positive_view_subscriptions_by_non_admin_user( + module_entitlement_manifest_org, module_target_sat +): """Attempt to read activation key subscriptions by non admin user :id: af75b640-97be-431b-8ac0-a6367f8f1996 @@ -1529,14 +1575,16 @@ def test_positive_view_subscriptions_by_non_admin_user(module_entitlement_manife assert len(available_subscriptions) > 0 available_subscription_ids = [subscription['id'] for subscription in available_subscriptions] subscription_id = choice(available_subscription_ids) - activation_key = make_activation_key({'name': ak_name, 'organization-id': org.id}) + activation_key = module_target_sat.cli_factory.make_activation_key( + {'name': ak_name, 'organization-id': org.id} + ) ActivationKey.add_subscription({'id': activation_key['id'], 'subscription-id': subscription_id}) subscriptions = ActivationKey.subscriptions( {'organization-id': org.id, 'id': activation_key['id']}, output_format='csv', ) assert len(subscriptions) == 1 - role = make_role({'organization-id': org.id}) + role = module_target_sat.cli_factory.make_role({'organization-id': org.id}) resource_permissions = { 'Katello::ActivationKey': { 'permissions': [ @@ -1560,8 +1608,8 @@ def test_positive_view_subscriptions_by_non_admin_user(module_entitlement_manife ] }, } - add_role_permissions(role['id'], resource_permissions) - user = make_user( + module_target_sat.cli_factory.add_role_permissions(role['id'], resource_permissions) + user = module_target_sat.cli_factory.make_user( { 'admin': False, 'default-organization-id': org.id, @@ -1602,7 +1650,7 @@ def test_positive_subscription_quantity_attached(function_org, rhel7_contenthost :BZ: 1633094 """ org = function_org - result = setup_org_for_a_rh_repo( + result = target_sat.cli_factory.setup_org_for_a_rh_repo( { 'product': PRDS['rhel'], 'repository-set': REPOSET['rhst7'], @@ -1612,7 +1660,7 @@ def test_positive_subscription_quantity_attached(function_org, rhel7_contenthost force_use_cdn=True, ) ak = ActivationKey.info({'id': result['activationkey-id']}) - setup_org_for_a_custom_repo( + target_sat.cli_factory.setup_org_for_a_custom_repo( { 'url': settings.repos.yum_0.url, 'organization-id': org['id'], diff --git a/tests/foreman/cli/test_architecture.py b/tests/foreman/cli/test_architecture.py index ec212894310..a8185de5796 100644 --- a/tests/foreman/cli/test_architecture.py +++ b/tests/foreman/cli/test_architecture.py @@ -20,8 +20,7 @@ import pytest from robottelo.cli.architecture import Architecture -from robottelo.cli.base import CLIReturnCodeError -from robottelo.cli.factory import make_architecture +from robottelo.exceptions import CLIReturnCodeError from robottelo.utils.datafactory import ( invalid_id_list, invalid_values_list, @@ -34,12 +33,12 @@ class TestArchitecture: """Architecture CLI related tests.""" @pytest.fixture(scope='class') - def class_architecture(self): + def class_architecture(self, class_target_sat): """Shared architecture for tests""" - return make_architecture() + return class_target_sat.cli_factory.make_architecture() @pytest.mark.tier1 - def test_positive_CRUD(self): + def test_positive_CRUD(self, module_target_sat): """Create a new Architecture, update the name and delete the Architecture itself. :id: cd8654b8-e603-11ea-adc1-0242ac120002 @@ -52,7 +51,7 @@ def test_positive_CRUD(self): name = gen_choice(list(valid_data_list().values())) new_name = gen_choice(list(valid_data_list().values())) - architecture = make_architecture({'name': name}) + architecture = module_target_sat.cli_factory.make_architecture({'name': name}) assert architecture['name'] == name Architecture.update({'id': architecture['id'], 'new-name': new_name}) architecture = Architecture.info({'id': architecture['id']}) diff --git a/tests/foreman/cli/test_auth.py b/tests/foreman/cli/test_auth.py index 51945a6445a..33a5d3e7889 100644 --- a/tests/foreman/cli/test_auth.py +++ b/tests/foreman/cli/test_auth.py @@ -22,13 +22,12 @@ import pytest from robottelo.cli.auth import Auth, AuthLogin -from robottelo.cli.base import CLIReturnCodeError -from robottelo.cli.factory import make_user from robottelo.cli.org import Org from robottelo.cli.settings import Settings from robottelo.cli.user import User from robottelo.config import settings from robottelo.constants import HAMMER_CONFIG +from robottelo.exceptions import CLIReturnCodeError LOGEDIN_MSG = "Session exists, currently logged in as '{0}'" NOTCONF_MSG = "Credentials are not configured." @@ -52,17 +51,19 @@ def configure_sessions(satellite, enable=True, add_default_creds=False): @pytest.fixture(scope='module') -def admin_user(): +def admin_user(module_target_sat): """create the admin role user for tests""" uname_admin = gen_string('alpha') - return make_user({'login': uname_admin, 'password': password, 'admin': '1'}) + return module_target_sat.cli_factory.make_user( + {'login': uname_admin, 'password': password, 'admin': '1'} + ) @pytest.fixture(scope='module') -def non_admin_user(): +def non_admin_user(module_target_sat): """create the non-admin role user for tests""" uname_viewer = gen_string('alpha') - user = make_user({'login': uname_viewer, 'password': password}) + user = module_target_sat.cli_factory.make_user({'login': uname_viewer, 'password': password}) User.add_role({'login': uname_viewer, 'role': 'Viewer'}) return user diff --git a/tests/foreman/cli/test_classparameters.py b/tests/foreman/cli/test_classparameters.py index f48019c4963..bfa07d4b8c2 100644 --- a/tests/foreman/cli/test_classparameters.py +++ b/tests/foreman/cli/test_classparameters.py @@ -18,8 +18,8 @@ """ import pytest -from robottelo.cli.base import CLIReturnCodeError from robottelo.config import settings +from robottelo.exceptions import CLIReturnCodeError from robottelo.utils.datafactory import gen_string diff --git a/tests/foreman/cli/test_computeresource_ec2.py b/tests/foreman/cli/test_computeresource_ec2.py index e0f3d8cc4c3..3654f1f0f9f 100644 --- a/tests/foreman/cli/test_computeresource_ec2.py +++ b/tests/foreman/cli/test_computeresource_ec2.py @@ -16,17 +16,16 @@ from fauxfactory import gen_string import pytest -from robottelo.cli.factory import make_compute_resource, make_location, make_org from robottelo.cli.org import Org from robottelo.config import settings from robottelo.constants import EC2_REGION_CA_CENTRAL_1, FOREMAN_PROVIDERS @pytest.fixture(scope='module') -def aws(): +def aws(module_target_sat): aws = type('rhev', (object,), {})() - aws.org = make_org() - aws.loc = make_location() + aws.org = module_target_sat.cli_factory.make_org() + aws.loc = module_target_sat.cli_factory.make_location() Org.add_location({'id': aws.org['id'], 'location-id': aws.loc['id']}) aws.aws_access_key = settings.ec2.access_key aws.aws_secret_key = settings.ec2.secret_key @@ -41,7 +40,7 @@ def aws(): @pytest.mark.tier1 @pytest.mark.upgrade -def test_positive_create_ec2_with_custom_region(aws): +def test_positive_create_ec2_with_custom_region(aws, module_target_sat): """Create a new ec2 compute resource with custom region :id: 28eb592d-ebf0-4659-900a-87112b3b2ad7 @@ -60,7 +59,7 @@ def test_positive_create_ec2_with_custom_region(aws): """ cr_name = gen_string(str_type='alpha') cr_description = gen_string(str_type='alpha') - cr = make_compute_resource( + cr = module_target_sat.cli_factory.make_compute_resource( { 'name': cr_name, 'description': cr_description, diff --git a/tests/foreman/cli/test_computeresource_libvirt.py b/tests/foreman/cli/test_computeresource_libvirt.py index e5e1997fa3b..bb0dd74dac4 100644 --- a/tests/foreman/cli/test_computeresource_libvirt.py +++ b/tests/foreman/cli/test_computeresource_libvirt.py @@ -39,11 +39,10 @@ import pytest from wait_for import wait_for -from robottelo.cli.base import CLIReturnCodeError from robottelo.cli.computeresource import ComputeResource -from robottelo.cli.factory import make_compute_resource, make_location from robottelo.config import settings from robottelo.constants import FOREMAN_PROVIDERS, LIBVIRT_RESOURCE_URL +from robottelo.exceptions import CLIReturnCodeError from robottelo.utils.datafactory import parametrized LIBVIRT_URL = LIBVIRT_RESOURCE_URL % settings.libvirt.libvirt_hostname @@ -134,7 +133,7 @@ def test_positive_create_with_name(libvirt_url): @pytest.mark.tier1 -def test_positive_info(libvirt_url): +def test_positive_info(libvirt_url, module_target_sat): """Test Compute Resource Info :id: f54af041-4471-4d8e-9429-45d821df0440 @@ -146,7 +145,7 @@ def test_positive_info(libvirt_url): :CaseLevel: Component """ name = gen_string('utf8') - compute_resource = make_compute_resource( + compute_resource = module_target_sat.cli_factory.make_compute_resource( { 'name': name, 'provider': FOREMAN_PROVIDERS['libvirt'], @@ -158,7 +157,7 @@ def test_positive_info(libvirt_url): @pytest.mark.tier1 -def test_positive_list(libvirt_url): +def test_positive_list(libvirt_url, module_target_sat): """Test Compute Resource List :id: 11123361-ffbc-4c59-a0df-a4af3408af7a @@ -169,7 +168,9 @@ def test_positive_list(libvirt_url): :CaseLevel: Component """ - comp_res = make_compute_resource({'provider': FOREMAN_PROVIDERS['libvirt'], 'url': libvirt_url}) + comp_res = module_target_sat.cli_factory.make_compute_resource( + {'provider': FOREMAN_PROVIDERS['libvirt'], 'url': libvirt_url} + ) assert comp_res['name'] result_list = ComputeResource.list({'search': 'name=%s' % comp_res['name']}) assert len(result_list) > 0 @@ -179,7 +180,7 @@ def test_positive_list(libvirt_url): @pytest.mark.tier1 @pytest.mark.upgrade -def test_positive_delete_by_name(libvirt_url): +def test_positive_delete_by_name(libvirt_url, module_target_sat): """Test Compute Resource delete :id: 7fcc0b66-f1c1-4194-8a4b-7f04b1dd439a @@ -190,7 +191,9 @@ def test_positive_delete_by_name(libvirt_url): :CaseLevel: Component """ - comp_res = make_compute_resource({'provider': FOREMAN_PROVIDERS['libvirt'], 'url': libvirt_url}) + comp_res = module_target_sat.cli_factory.make_compute_resource( + {'provider': FOREMAN_PROVIDERS['libvirt'], 'url': libvirt_url} + ) assert comp_res['name'] ComputeResource.delete({'name': comp_res['name']}) result = ComputeResource.exists(search=('name', comp_res['name'])) @@ -225,7 +228,7 @@ def test_positive_create_with_libvirt(libvirt_url, options): @pytest.mark.tier2 -def test_positive_create_with_loc(libvirt_url): +def test_positive_create_with_loc(libvirt_url, module_target_sat): """Create Compute Resource with location :id: 224c7cbc-6bac-4a94-8141-d6249896f5a2 @@ -236,14 +239,16 @@ def test_positive_create_with_loc(libvirt_url): :CaseLevel: Integration """ - location = make_location() - comp_resource = make_compute_resource({'location-ids': location['id']}) + location = module_target_sat.cli_factory.make_location() + comp_resource = module_target_sat.cli_factory.make_compute_resource( + {'location-ids': location['id']} + ) assert len(comp_resource['locations']) == 1 assert comp_resource['locations'][0] == location['name'] @pytest.mark.tier2 -def test_positive_create_with_locs(libvirt_url): +def test_positive_create_with_locs(libvirt_url, module_target_sat): """Create Compute Resource with multiple locations :id: f665c586-39bf-480a-a0fc-81d9e1eb7c54 @@ -256,8 +261,8 @@ def test_positive_create_with_locs(libvirt_url): :CaseLevel: Integration """ locations_amount = random.randint(3, 5) - locations = [make_location() for _ in range(locations_amount)] - comp_resource = make_compute_resource( + locations = [module_target_sat.cli_factory.make_location() for _ in range(locations_amount)] + comp_resource = module_target_sat.cli_factory.make_compute_resource( {'location-ids': [location['id'] for location in locations]} ) assert len(comp_resource['locations']) == locations_amount @@ -294,7 +299,7 @@ def test_negative_create_with_name_url(libvirt_url, options): @pytest.mark.tier2 -def test_negative_create_with_same_name(libvirt_url): +def test_negative_create_with_same_name(libvirt_url, module_target_sat): """Compute Resource negative create with the same name :id: ddb5c45b-1ea3-46d0-b248-56c0388d2e4b @@ -305,7 +310,7 @@ def test_negative_create_with_same_name(libvirt_url): :CaseLevel: Component """ - comp_res = make_compute_resource() + comp_res = module_target_sat.cli_factory.make_compute_resource() with pytest.raises(CLIReturnCodeError): ComputeResource.create( { @@ -321,7 +326,7 @@ def test_negative_create_with_same_name(libvirt_url): @pytest.mark.tier1 @pytest.mark.parametrize('options', **parametrized(valid_update_data())) -def test_positive_update_name(libvirt_url, options): +def test_positive_update_name(libvirt_url, options, module_target_sat): """Compute Resource positive update :id: 213d7f04-4c54-4985-8ca0-d2a1a9e3b305 @@ -334,7 +339,7 @@ def test_positive_update_name(libvirt_url, options): :parametrized: yes """ - comp_res = make_compute_resource() + comp_res = module_target_sat.cli_factory.make_compute_resource() options.update({'name': comp_res['name']}) # update Compute Resource ComputeResource.update(options) @@ -351,7 +356,7 @@ def test_positive_update_name(libvirt_url, options): @pytest.mark.tier2 @pytest.mark.parametrize('options', **parametrized(invalid_update_data())) -def test_negative_update(libvirt_url, options): +def test_negative_update(libvirt_url, options, module_target_sat): """Compute Resource negative update :id: e7aa9b39-dd01-4f65-8e89-ff5a6f4ee0e3 @@ -364,7 +369,7 @@ def test_negative_update(libvirt_url, options): :parametrized: yes """ - comp_res = make_compute_resource() + comp_res = module_target_sat.cli_factory.make_compute_resource() with pytest.raises(CLIReturnCodeError): ComputeResource.update(dict({'name': comp_res['name']}, **options)) result = ComputeResource.info({'id': comp_res['id']}) diff --git a/tests/foreman/cli/test_computeresource_osp.py b/tests/foreman/cli/test_computeresource_osp.py index c9018995dc2..42cffe0b7b9 100644 --- a/tests/foreman/cli/test_computeresource_osp.py +++ b/tests/foreman/cli/test_computeresource_osp.py @@ -19,8 +19,8 @@ from fauxfactory import gen_string import pytest -from robottelo.cli.factory import CLIReturnCodeError from robottelo.config import settings +from robottelo.exceptions import CLIReturnCodeError OSP_SETTINGS = Box( username=settings.osp.username, diff --git a/tests/foreman/cli/test_computeresource_rhev.py b/tests/foreman/cli/test_computeresource_rhev.py index 12e2fe9b345..8b9d02aa901 100644 --- a/tests/foreman/cli/test_computeresource_rhev.py +++ b/tests/foreman/cli/test_computeresource_rhev.py @@ -21,13 +21,9 @@ from wrapanapi import RHEVMSystem from robottelo.cli.computeresource import ComputeResource -from robottelo.cli.factory import ( - CLIFactoryError, - CLIReturnCodeError, - make_compute_resource, -) from robottelo.cli.host import Host from robottelo.config import settings +from robottelo.exceptions import CLIFactoryError, CLIReturnCodeError @pytest.fixture(scope='module') @@ -71,7 +67,7 @@ def test_positive_create_rhev_with_valid_name(rhev): @pytest.mark.tier1 -def test_positive_rhev_info(rhev): +def test_positive_rhev_info(rhev, module_target_sat): """List the info of RHEV compute resource :id: 1b18f6e8-c431-41ab-ae49-a2bbb74712f2 @@ -83,7 +79,7 @@ def test_positive_rhev_info(rhev): :BZ: 1602835 """ name = gen_string('utf8') - compute_resource = make_compute_resource( + compute_resource = module_target_sat.cli_factory.make_compute_resource( { 'name': name, 'provider': 'Ovirt', @@ -97,7 +93,7 @@ def test_positive_rhev_info(rhev): @pytest.mark.tier1 -def test_positive_delete_by_name(rhev): +def test_positive_delete_by_name(rhev, module_target_sat): """Delete the RHEV compute resource by name :id: ac84acbe-3e02-4f49-9695-b668df28b353 @@ -108,7 +104,7 @@ def test_positive_delete_by_name(rhev): :BZ: 1602835 """ - comp_res = make_compute_resource( + comp_res = module_target_sat.cli_factory.make_compute_resource( { 'provider': 'Ovirt', 'user': rhev.username, @@ -124,7 +120,7 @@ def test_positive_delete_by_name(rhev): @pytest.mark.tier1 -def test_positive_delete_by_id(rhev): +def test_positive_delete_by_id(rhev, module_target_sat): """Delete the RHEV compute resource by id :id: 4bcd4fa3-df8b-4773-b142-e47458116552 @@ -135,7 +131,7 @@ def test_positive_delete_by_id(rhev): :BZ: 1602835 """ - comp_res = make_compute_resource( + comp_res = module_target_sat.cli_factory.make_compute_resource( { 'provider': 'Ovirt', 'user': rhev.username, @@ -173,7 +169,7 @@ def test_negative_create_rhev_with_url(rhev): @pytest.mark.tier2 -def test_negative_create_with_same_name(rhev): +def test_negative_create_with_same_name(rhev, module_target_sat): """RHEV compute resource negative create with the same name :id: f00813ef-df31-462c-aa87-479b8272aea3 @@ -188,7 +184,7 @@ def test_negative_create_with_same_name(rhev): :CaseImportance: High """ name = gen_string('alpha') - compute_resource = make_compute_resource( + compute_resource = module_target_sat.cli_factory.make_compute_resource( { 'name': name, 'provider': 'Ovirt', @@ -200,7 +196,7 @@ def test_negative_create_with_same_name(rhev): ) assert compute_resource['name'] == name with pytest.raises(CLIFactoryError): - make_compute_resource( + module_target_sat.cli_factory.make_compute_resource( { 'name': name, 'provider': 'Ovirt', @@ -214,7 +210,7 @@ def test_negative_create_with_same_name(rhev): @pytest.mark.tier1 @pytest.mark.upgrade -def test_positive_update_name(rhev): +def test_positive_update_name(rhev, module_target_sat): """RHEV compute resource positive update :id: 5ca29b81-d1f0-409f-843d-aa5daf957d7f @@ -231,7 +227,7 @@ def test_positive_update_name(rhev): :BZ: 1602835 """ new_name = gen_string('alpha') - comp_res = make_compute_resource( + comp_res = module_target_sat.cli_factory.make_compute_resource( { 'provider': 'Ovirt', 'user': rhev.username, @@ -246,7 +242,7 @@ def test_positive_update_name(rhev): @pytest.mark.tier2 -def test_positive_add_image_rhev_with_name(rhev, module_os): +def test_positive_add_image_rhev_with_name(rhev, module_os, module_target_sat): """Add images to the RHEV compute resource :id: 2da84165-a56f-4282-9343-94828fa69c13 @@ -265,7 +261,7 @@ def test_positive_add_image_rhev_with_name(rhev, module_os): if rhev.image_uuid is None: pytest.skip('Missing configuration for rhev.image_uuid') - comp_res = make_compute_resource( + comp_res = module_target_sat.cli_factory.make_compute_resource( { 'provider': 'Ovirt', 'user': rhev.username, @@ -291,7 +287,7 @@ def test_positive_add_image_rhev_with_name(rhev, module_os): @pytest.mark.skip_if_open("BZ:1829239") @pytest.mark.tier2 -def test_negative_add_image_rhev_with_invalid_uuid(rhev, module_os): +def test_negative_add_image_rhev_with_invalid_uuid(rhev, module_os, module_target_sat): """Attempt to add invalid image to the RHEV compute resource :id: e8a653f9-9749-4c76-95ed-2411a7c0a117 @@ -309,7 +305,7 @@ def test_negative_add_image_rhev_with_invalid_uuid(rhev, module_os): :BZ: 1829239 """ - comp_res = make_compute_resource( + comp_res = module_target_sat.cli_factory.make_compute_resource( { 'provider': 'Ovirt', 'user': rhev.username, @@ -333,7 +329,7 @@ def test_negative_add_image_rhev_with_invalid_uuid(rhev, module_os): @pytest.mark.tier2 -def test_negative_add_image_rhev_with_invalid_name(rhev, module_os): +def test_negative_add_image_rhev_with_invalid_name(rhev, module_os, module_target_sat): """Attempt to add invalid image name to the RHEV compute resource :id: 873a7d79-1e89-4e4f-81ca-b6db1e0246da @@ -353,7 +349,7 @@ def test_negative_add_image_rhev_with_invalid_name(rhev, module_os): if rhev.image_uuid is None: pytest.skip('Missing configuration for rhev.image_uuid') - comp_res = make_compute_resource( + comp_res = module_target_sat.cli_factory.make_compute_resource( { 'provider': 'Ovirt', 'user': rhev.username, diff --git a/tests/foreman/cli/test_container_management.py b/tests/foreman/cli/test_container_management.py index 70de242f8ac..b16ee65ab05 100644 --- a/tests/foreman/cli/test_container_management.py +++ b/tests/foreman/cli/test_container_management.py @@ -16,15 +16,9 @@ import pytest from wait_for import wait_for -from robottelo.cli.factory import ( - ContentView, - LifecycleEnvironment, - Repository, - make_content_view, - make_lifecycle_environment, - make_product_wait, - make_repository, -) +from robottelo.cli.contentview import ContentView +from robottelo.cli.lifecycleenvironment import LifecycleEnvironment +from robottelo.cli.repository import Repository from robottelo.config import settings from robottelo.constants import ( CONTAINER_REGISTRY_HUB, @@ -34,7 +28,7 @@ from robottelo.logging import logger -def _repo(product_id, name=None, upstream_name=None, url=None): +def _repo(sat, product_id, name=None, upstream_name=None, url=None): """Creates a Docker-based repository. :param product_id: ID of the ``Product``. @@ -46,7 +40,7 @@ def _repo(product_id, name=None, upstream_name=None, url=None): CONTAINER_REGISTRY_HUB constant. :return: A ``Repository`` object. """ - return make_repository( + return sat.cli_factory.make_repository( { 'content-type': REPO_TYPE['docker'], 'docker-upstream-name': upstream_name or CONTAINER_UPSTREAM_NAME, @@ -82,8 +76,8 @@ def test_positive_pull_image(self, module_org, container_contenthost, target_sat :parametrized: yes """ - product = make_product_wait({'organization-id': module_org.id}) - repo = _repo(product['id']) + product = target_sat.cli_factory.make_product_wait({'organization-id': module_org.id}) + repo = _repo(target_sat, product['id']) Repository.synchronize({'id': repo['id']}) repo = Repository.info({'id': repo['id']}) try: @@ -155,11 +149,13 @@ def test_positive_container_admin_end_to_end_search( # Satellite setup: create product and add Docker repository; # create content view and add Docker repository; # create lifecycle environment and promote content view to it - lce = make_lifecycle_environment({'organization-id': module_org.id}) - product = make_product_wait({'organization-id': module_org.id}) - repo = _repo(product['id'], upstream_name=CONTAINER_UPSTREAM_NAME) + lce = target_sat.cli_factory.make_lifecycle_environment({'organization-id': module_org.id}) + product = target_sat.cli_factory.make_product_wait({'organization-id': module_org.id}) + repo = _repo(target_sat, product['id'], upstream_name=CONTAINER_UPSTREAM_NAME) Repository.synchronize({'id': repo['id']}) - content_view = make_content_view({'composite': False, 'organization-id': module_org.id}) + content_view = target_sat.cli_factory.make_content_view( + {'composite': False, 'organization-id': module_org.id} + ) ContentView.add_repository({'id': content_view['id'], 'repository-id': repo['id']}) ContentView.publish({'id': content_view['id']}) content_view = ContentView.info({'id': content_view['id']}) @@ -259,11 +255,13 @@ def test_positive_container_admin_end_to_end_pull( # Satellite setup: create product and add Docker repository; # create content view and add Docker repository; # create lifecycle environment and promote content view to it - lce = make_lifecycle_environment({'organization-id': module_org.id}) - product = make_product_wait({'organization-id': module_org.id}) - repo = _repo(product['id'], upstream_name=docker_upstream_name) + lce = target_sat.cli_factory.make_lifecycle_environment({'organization-id': module_org.id}) + product = target_sat.cli_factory.make_product_wait({'organization-id': module_org.id}) + repo = _repo(target_sat, product['id'], upstream_name=docker_upstream_name) Repository.synchronize({'id': repo['id']}) - content_view = make_content_view({'composite': False, 'organization-id': module_org.id}) + content_view = target_sat.cli_factory.make_content_view( + {'composite': False, 'organization-id': module_org.id} + ) ContentView.add_repository({'id': content_view['id'], 'repository-id': repo['id']}) ContentView.publish({'id': content_view['id']}) content_view = ContentView.info({'id': content_view['id']}) @@ -364,7 +362,9 @@ def test_negative_pull_content_with_longer_name( {'name': product_name, 'organization-id': module_org.id} ) - repo = _repo(product['id'], name=repo_name, upstream_name=CONTAINER_UPSTREAM_NAME) + repo = _repo( + target_sat, product['id'], name=repo_name, upstream_name=CONTAINER_UPSTREAM_NAME + ) # 2. Sync the repos target_sat.cli.Repository.synchronize({'id': repo['id']}) diff --git a/tests/foreman/cli/test_contentcredentials.py b/tests/foreman/cli/test_contentcredentials.py index 269170ffdc1..8541ce0f718 100644 --- a/tests/foreman/cli/test_contentcredentials.py +++ b/tests/foreman/cli/test_contentcredentials.py @@ -23,9 +23,8 @@ from fauxfactory import gen_alphanumeric, gen_choice, gen_integer, gen_string import pytest -from robottelo.cli.base import CLIReturnCodeError from robottelo.constants import DataFile -from robottelo.host_helpers.cli_factory import CLIFactoryError +from robottelo.exceptions import CLIFactoryError, CLIReturnCodeError from robottelo.utils.datafactory import ( invalid_values_list, parametrized, diff --git a/tests/foreman/cli/test_contentview.py b/tests/foreman/cli/test_contentview.py index 4effe29ecf4..2aa27fb13f4 100644 --- a/tests/foreman/cli/test_contentview.py +++ b/tests/foreman/cli/test_contentview.py @@ -24,9 +24,7 @@ from wrapanapi.entities.vm import VmState from robottelo import constants -from robottelo.cli import factory as cli_factory from robottelo.cli.activationkey import ActivationKey -from robottelo.cli.base import CLIReturnCodeError from robottelo.cli.capsule import Capsule from robottelo.cli.contentview import ContentView from robottelo.cli.filter import Filter @@ -46,6 +44,7 @@ FAKE_2_CUSTOM_PACKAGE_NAME, DataFile, ) +from robottelo.exceptions import CLIFactoryError, CLIReturnCodeError from robottelo.utils.datafactory import ( generate_strings_list, invalid_names_list, @@ -97,7 +96,7 @@ class TestContentView: @pytest.mark.parametrize('name', **parametrized(valid_names_list())) @pytest.mark.tier1 - def test_positive_create_with_name(self, module_org, name): + def test_positive_create_with_name(self, module_org, module_target_sat, name): """create content views with different names :id: a154308c-3982-4cf1-a236-3051e740970e @@ -108,14 +107,14 @@ def test_positive_create_with_name(self, module_org, name): :parametrized: yes """ - content_view = cli_factory.make_content_view( + content_view = module_target_sat.cli_factory.make_content_view( {'name': name, 'organization-id': module_org.id} ) assert content_view['name'] == name.strip() @pytest.mark.parametrize('name', **parametrized(invalid_names_list())) @pytest.mark.tier1 - def test_negative_create_with_invalid_name(self, module_org, name): + def test_negative_create_with_invalid_name(self, module_org, module_target_sat, name): """create content views with invalid names :id: 83046271-76f9-4cda-b579-a2fe63493295 @@ -127,8 +126,10 @@ def test_negative_create_with_invalid_name(self, module_org, name): :parametrized: yes """ - with pytest.raises(cli_factory.CLIFactoryError): - cli_factory.make_content_view({'name': name, 'organization-id': module_org.id}) + with pytest.raises(CLIFactoryError): + module_target_sat.cli_factory.make_content_view( + {'name': name, 'organization-id': module_org.id} + ) @pytest.mark.tier1 def test_negative_create_with_org_name(self): @@ -145,7 +146,7 @@ def test_negative_create_with_org_name(self): ContentView.create({'organization-id': gen_string('alpha')}) @pytest.mark.tier2 - def test_positive_create_with_repo_id(self, module_org, module_product): + def test_positive_create_with_repo_id(self, module_org, module_product, module_target_sat): """Create content view providing repository id :id: bb91affe-f8d4-4724-8b61-41f3cb898fd3 @@ -156,15 +157,15 @@ def test_positive_create_with_repo_id(self, module_org, module_product): :CaseImportance: High :BZ: 1213097 """ - repo = cli_factory.make_repository({'product-id': module_product.id}) - cv = cli_factory.make_content_view( + repo = module_target_sat.cli_factory.make_repository({'product-id': module_product.id}) + cv = module_target_sat.cli_factory.make_content_view( {'organization-id': module_org.id, 'repository-ids': [repo['id']]} ) assert cv['yum-repositories'][0]['id'] == repo['id'] @pytest.mark.parametrize('new_name', **parametrized(valid_names_list())) @pytest.mark.tier1 - def test_positive_update_name_by_id(self, module_org, new_name): + def test_positive_update_name_by_id(self, module_org, module_target_sat, new_name): """Find content view by its id and update its name afterwards :id: 35fccf2c-abc4-4ca8-a565-a7a6adaaf429 @@ -177,7 +178,7 @@ def test_positive_update_name_by_id(self, module_org, new_name): :parametrized: yes """ - cv = cli_factory.make_content_view( + cv = module_target_sat.cli_factory.make_content_view( {'name': gen_string('utf8'), 'organization-id': module_org.id} ) ContentView.update({'id': cv['id'], 'new-name': new_name}) @@ -186,7 +187,7 @@ def test_positive_update_name_by_id(self, module_org, new_name): @pytest.mark.parametrize('new_name', **parametrized(valid_names_list())) @pytest.mark.tier1 - def test_positive_update_name_by_name(self, module_org, new_name): + def test_positive_update_name_by_name(self, module_org, module_target_sat, new_name): """Find content view by its name and update it :id: aa9bced6-ee6c-4a18-90ac-874ab4979711 @@ -199,7 +200,7 @@ def test_positive_update_name_by_name(self, module_org, new_name): :parametrized: yes """ - cv = cli_factory.make_content_view({'organization-id': module_org.id}) + cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) ContentView.update( {'name': cv['name'], 'organization-label': module_org.label, 'new-name': new_name} ) @@ -208,7 +209,7 @@ def test_positive_update_name_by_name(self, module_org, new_name): @pytest.mark.run_in_one_thread @pytest.mark.tier2 - def test_positive_update_filter(self, repo_setup): + def test_positive_update_filter(self, repo_setup, module_target_sat): """Edit content views for a rh content, add a filter and update filter :id: 4beab1e4-fc58-460e-af24-cdd2c3d283e6 @@ -221,7 +222,9 @@ def test_positive_update_filter(self, repo_setup): :CaseImportance: High """ # Create CV - new_cv = cli_factory.make_content_view({'organization-id': repo_setup['org'].id}) + new_cv = module_target_sat.cli_factory.make_content_view( + {'organization-id': repo_setup['org'].id} + ) # Associate repo to CV ContentView.add_repository( { @@ -233,10 +236,10 @@ def test_positive_update_filter(self, repo_setup): Repository.synchronize({'id': repo_setup['repo'].id}) new_cv = ContentView.info({'id': new_cv['id']}) assert new_cv['yum-repositories'][0]['name'] == repo_setup['repo'].name - cvf = cli_factory.make_content_view_filter( + cvf = module_target_sat.cli_factory.make_content_view_filter( {'content-view-id': new_cv['id'], 'inclusion': 'true', 'type': 'erratum'} ) - cvf_rule = cli_factory.make_content_view_filter_rule( + cvf_rule = module_target_sat.cli_factory.content_view_filter_rule( {'content-view-filter-id': cvf['filter-id'], 'types': ['bugfix', 'enhancement']} ) cvf = ContentView.filter.info({'id': cvf['filter-id']}) @@ -252,7 +255,7 @@ def test_positive_update_filter(self, repo_setup): assert 'security' == cvf['rules'][0]['types'] @pytest.mark.tier1 - def test_positive_delete_by_id(self, module_org): + def test_positive_delete_by_id(self, module_org, module_target_sat): """delete content view by its id :id: e96d6d47-8be4-4705-979f-e5c320eca293 @@ -261,13 +264,13 @@ def test_positive_delete_by_id(self, module_org): :CaseImportance: Critical """ - cv = cli_factory.make_content_view({'organization-id': module_org.id}) + cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) ContentView.delete({'id': cv['id']}) with pytest.raises(CLIReturnCodeError): ContentView.info({'id': cv['id']}) @pytest.mark.tier1 - def test_positive_delete_by_name(self, module_org): + def test_positive_delete_by_name(self, module_org, module_target_sat): """delete content view by its name :id: 014b85f3-003b-42d9-bbfe-21620e8eb84b @@ -278,13 +281,13 @@ def test_positive_delete_by_name(self, module_org): :CaseImportance: Critical """ - cv = cli_factory.make_content_view({'organization-id': module_org.id}) + cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) ContentView.delete({'name': cv['name'], 'organization': module_org.name}) with pytest.raises(CLIReturnCodeError): ContentView.info({'id': cv['id']}) @pytest.mark.tier2 - def test_positive_delete_version_by_name(self, module_org): + def test_positive_delete_version_by_name(self, module_org, module_target_sat): """Create content view and publish it. After that try to disassociate content view from 'Library' environment through 'remove-from-environment' command and delete content view version from @@ -298,7 +301,9 @@ def test_positive_delete_version_by_name(self, module_org): :CaseLevel: Integration """ - content_view = cli_factory.make_content_view({'organization-id': module_org.id}) + content_view = module_target_sat.cli_factory.make_content_view( + {'organization-id': module_org.id} + ) ContentView.publish({'id': content_view['id']}) content_view = ContentView.info({'id': content_view['id']}) assert len(content_view['versions']) == 1 @@ -319,7 +324,7 @@ def test_positive_delete_version_by_name(self, module_org): @pytest.mark.tier2 @pytest.mark.upgrade - def test_positive_delete_version_by_id(self, module_org, module_product): + def test_positive_delete_version_by_id(self, module_org, module_product, module_target_sat): """Create content view and publish it. After that try to disassociate content view from 'Library' environment through 'remove-from-environment' command and delete content view version from @@ -333,11 +338,11 @@ def test_positive_delete_version_by_id(self, module_org, module_product): :CaseImportance: High """ # Create new organization, product and repository - new_repo = cli_factory.make_repository({'product-id': module_product.id}) + new_repo = module_target_sat.cli_factory.make_repository({'product-id': module_product.id}) # Sync REPO Repository.synchronize({'id': new_repo['id']}) # Create new content-view and add repository to view - new_cv = cli_factory.make_content_view({'organization-id': module_org.id}) + new_cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) ContentView.add_repository( { 'id': new_cv['id'], @@ -364,7 +369,7 @@ def test_positive_delete_version_by_id(self, module_org, module_product): assert len(new_cv['versions']) == 0 @pytest.mark.tier2 - def test_negative_delete_version_by_id(self, module_org): + def test_negative_delete_version_by_id(self, 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 @@ -377,7 +382,9 @@ def test_negative_delete_version_by_id(self, module_org): :CaseLevel: Integration """ - content_view = cli_factory.make_content_view({'organization-id': module_org.id}) + content_view = module_target_sat.cli_factory.make_content_view( + {'organization-id': module_org.id} + ) ContentView.publish({'id': content_view['id']}) content_view = ContentView.info({'id': content_view['id']}) assert len(content_view['versions']) == 1 @@ -390,7 +397,7 @@ def test_negative_delete_version_by_id(self, module_org): assert len(content_view['versions']) == 1 @pytest.mark.tier1 - def test_positive_remove_lce_by_id(self, module_org): + 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 @@ -399,7 +406,7 @@ def test_positive_remove_lce_by_id(self, module_org): :CaseImportance: Critical """ - new_cv = cli_factory.make_content_view({'organization-id': module_org.id}) + new_cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) ContentView.publish({'id': new_cv['id']}) new_cv = ContentView.info({'id': new_cv['id']}) env = new_cv['lifecycle-environments'][0] @@ -408,7 +415,7 @@ def test_positive_remove_lce_by_id(self, module_org): assert len(new_cv['lifecycle-environments']) == 0 @pytest.mark.tier3 - def test_positive_remove_lce_by_id_and_reassign_ak(self, module_org): + 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 another environment and content view @@ -421,23 +428,29 @@ def test_positive_remove_lce_by_id_and_reassign_ak(self, module_org): :CaseLevel: Integration """ env = [ - cli_factory.make_lifecycle_environment({'organization-id': module_org.id}) + module_target_sat.cli_factory.make_lifecycle_environment( + {'organization-id': module_org.id} + ) for _ in range(2) ] - source_cv = cli_factory.make_content_view({'organization-id': module_org.id}) + source_cv = module_target_sat.cli_factory.make_content_view( + {'organization-id': module_org.id} + ) ContentView.publish({'id': source_cv['id']}) source_cv = ContentView.info({'id': source_cv['id']}) cvv = source_cv['versions'][0] ContentView.version_promote({'id': cvv['id'], 'to-lifecycle-environment-id': env[0]['id']}) - destination_cv = cli_factory.make_content_view({'organization-id': module_org.id}) + destination_cv = module_target_sat.cli_factory.make_content_view( + {'organization-id': module_org.id} + ) ContentView.publish({'id': destination_cv['id']}) destination_cv = ContentView.info({'id': destination_cv['id']}) cvv = destination_cv['versions'][0] ContentView.version_promote({'id': cvv['id'], 'to-lifecycle-environment-id': env[1]['id']}) - ac_key = cli_factory.make_activation_key( + ac_key = module_target_sat.cli_factory.make_activation_key( { 'content-view-id': source_cv['id'], 'lifecycle-environment-id': env[0]['id'], @@ -465,7 +478,7 @@ def test_positive_remove_lce_by_id_and_reassign_ak(self, module_org): @pytest.mark.tier3 @pytest.mark.upgrade - def test_positive_remove_lce_by_id_and_reassign_chost(self, module_org): + def test_positive_remove_lce_by_id_and_reassign_chost(self, module_org, module_target_sat): """Remove content view environment and re-assign content host to another environment and content view @@ -478,17 +491,23 @@ def test_positive_remove_lce_by_id_and_reassign_chost(self, module_org): :CaseLevel: Integration """ env = [ - cli_factory.make_lifecycle_environment({'organization-id': module_org.id}) + module_target_sat.cli_factory.make_lifecycle_environment( + {'organization-id': module_org.id} + ) for _ in range(2) ] - source_cv = cli_factory.make_content_view({'organization-id': module_org.id}) + source_cv = module_target_sat.cli_factory.make_content_view( + {'organization-id': module_org.id} + ) ContentView.publish({'id': source_cv['id']}) source_cv = ContentView.info({'id': source_cv['id']}) cvv = source_cv['versions'][0] ContentView.version_promote({'id': cvv['id'], 'to-lifecycle-environment-id': env[0]['id']}) - destination_cv = cli_factory.make_content_view({'organization-id': module_org.id}) + destination_cv = module_target_sat.cli_factory.make_content_view( + {'organization-id': module_org.id} + ) ContentView.publish({'id': destination_cv['id']}) destination_cv = ContentView.info({'id': destination_cv['id']}) cvv = destination_cv['versions'][0] @@ -497,7 +516,7 @@ def test_positive_remove_lce_by_id_and_reassign_chost(self, module_org): source_cv = ContentView.info({'id': source_cv['id']}) assert source_cv['content-host-count'] == '0' - cli_factory.make_fake_host( + module_target_sat.cli_factory.make_fake_host( { 'content-view-id': source_cv['id'], 'lifecycle-environment-id': env[0]['id'], @@ -525,7 +544,7 @@ def test_positive_remove_lce_by_id_and_reassign_chost(self, module_org): assert destination_cv['content-host-count'] == '1' @pytest.mark.tier1 - def test_positive_remove_version_by_id(self, module_org): + def test_positive_remove_version_by_id(self, module_org, module_target_sat): """Delete content view version using 'remove' command by id :id: e8664353-6601-4566-8478-440be20a089d @@ -534,7 +553,7 @@ def test_positive_remove_version_by_id(self, module_org): :CaseImportance: Critical """ - new_cv = cli_factory.make_content_view({'organization-id': module_org.id}) + new_cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) ContentView.publish({'id': new_cv['id']}) new_cv = ContentView.info({'id': new_cv['id']}) assert len(new_cv['versions']) == 1 @@ -549,7 +568,7 @@ def test_positive_remove_version_by_id(self, module_org): assert len(new_cv['versions']) == 0 @pytest.mark.tier1 - def test_positive_remove_version_by_name(self, module_org): + def test_positive_remove_version_by_name(self, module_org, module_target_sat): """Delete content view version using 'remove' command by name :id: 2c838716-dcd3-4017-bffc-da53727c22a3 @@ -560,7 +579,7 @@ def test_positive_remove_version_by_name(self, module_org): :CaseImportance: Critical """ - new_cv = cli_factory.make_content_view({'organization-id': module_org.id}) + new_cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) ContentView.publish({'id': new_cv['id']}) new_cv = ContentView.info({'id': new_cv['id']}) assert len(new_cv['versions']) == 1 @@ -574,7 +593,7 @@ def test_positive_remove_version_by_name(self, module_org): assert len(new_cv['versions']) == 0 @pytest.mark.tier1 - def test_positive_remove_repository_by_id(self, module_org, module_product): + def test_positive_remove_repository_by_id(self, module_org, module_product, module_target_sat): """Remove associated repository from content view by id :id: 90703181-b3f8-44f6-959a-b65c79b6b6ee @@ -585,9 +604,9 @@ def test_positive_remove_repository_by_id(self, module_org, module_product): :CaseImportance: Critical """ - new_repo = cli_factory.make_repository({'product-id': module_product.id}) + new_repo = module_target_sat.cli_factory.make_repository({'product-id': module_product.id}) # Create CV - new_cv = cli_factory.make_content_view({'organization-id': module_org.id}) + new_cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) # Associate repo to CV ContentView.add_repository({'id': new_cv['id'], 'repository-id': new_repo['id']}) new_cv = ContentView.info({'id': new_cv['id']}) @@ -598,7 +617,9 @@ def test_positive_remove_repository_by_id(self, module_org, module_product): assert len(new_cv['yum-repositories']) == 0 @pytest.mark.tier1 - def test_positive_remove_repository_by_name(self, module_org, module_product): + def test_positive_remove_repository_by_name( + self, module_org, module_product, module_target_sat + ): """Remove associated repository from content view by name :id: dc952fe7-eb89-4760-889b-6a3fa17c3e75 @@ -609,9 +630,9 @@ def test_positive_remove_repository_by_name(self, module_org, module_product): :CaseImportance: Critical """ - new_repo = cli_factory.make_repository({'product-id': module_product.id}) + new_repo = module_target_sat.cli_factory.make_repository({'product-id': module_product.id}) # Create CV - new_cv = cli_factory.make_content_view({'organization-id': module_org.id}) + new_cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) # Associate repo to CV ContentView.add_repository({'id': new_cv['id'], 'repository-id': new_repo['id']}) new_cv = ContentView.info({'id': new_cv['id']}) @@ -622,7 +643,7 @@ def test_positive_remove_repository_by_name(self, module_org, module_product): assert len(new_cv['yum-repositories']) == 0 @pytest.mark.tier2 - def test_positive_create_composite(self, module_org): + def test_positive_create_composite(self, module_org, module_target_sat): """create a composite content view :id: bded6acd-8da3-45ea-9e39-19bdc6c06341 @@ -636,12 +657,12 @@ def test_positive_create_composite(self, module_org): :CaseImportance: High """ # Create REPO - new_product = cli_factory.make_product({'organization-id': module_org.id}) - new_repo = cli_factory.make_repository({'product-id': new_product['id']}) + new_product = module_target_sat.cli_factory.make_product({'organization-id': module_org.id}) + new_repo = module_target_sat.cli_factory.make_repository({'product-id': new_product['id']}) # Sync REPO Repository.synchronize({'id': new_repo['id']}) # Create CV - new_cv = cli_factory.make_content_view({'organization-id': module_org.id}) + new_cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) # Associate repo to CV ContentView.add_repository({'id': new_cv['id'], 'repository-id': new_repo['id']}) # Publish a new version of CV @@ -650,7 +671,7 @@ def test_positive_create_composite(self, module_org): # Let us now store the version1 id version1_id = new_cv['versions'][0]['id'] # Create CV - con_view = cli_factory.make_content_view( + con_view = module_target_sat.cli_factory.make_content_view( {'composite': True, 'organization-id': module_org.id} ) # Associate version to composite CV @@ -660,7 +681,7 @@ def test_positive_create_composite(self, module_org): assert con_view['components'][0]['id'] == version1_id @pytest.mark.tier2 - def test_positive_create_composite_by_name(self, module_org): + 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 @@ -675,13 +696,13 @@ def test_positive_create_composite_by_name(self, module_org): :CaseImportance: High """ - new_product = cli_factory.make_product({'organization-id': module_org.id}) + new_product = module_target_sat.cli_factory.make_product({'organization-id': module_org.id}) # Create REPO - new_repo = cli_factory.make_repository({'product-id': new_product['id']}) + new_repo = module_target_sat.cli_factory.make_repository({'product-id': new_product['id']}) # Sync REPO Repository.synchronize({'id': new_repo['id']}) # Create CV - new_cv = cli_factory.make_content_view({'organization-id': module_org.id}) + new_cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) # Associate repo to CV ContentView.add_repository({'id': new_cv['id'], 'repository-id': new_repo['id']}) # Publish a new version of CV @@ -689,7 +710,9 @@ def test_positive_create_composite_by_name(self, module_org): new_cv = ContentView.info({'id': new_cv['id']}) cvv = new_cv['versions'][0] # Create CV - cv = cli_factory.make_content_view({'composite': True, 'organization-id': module_org.id}) + 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 ContentView.add_version( @@ -706,7 +729,9 @@ def test_positive_create_composite_by_name(self, module_org): assert cv['components'][0]['id'] == cvv['id'] @pytest.mark.tier2 - def test_positive_remove_version_by_id_from_composite(self, module_org, module_product): + def test_positive_remove_version_by_id_from_composite( + self, module_org, module_product, module_target_sat + ): """Create a composite content view and remove its content version by id :id: 0ff675d0-45d6-4f15-9e84-3b5ce98ce7de @@ -719,11 +744,11 @@ def test_positive_remove_version_by_id_from_composite(self, module_org, module_p :CaseImportance: High """ # Create new repository - new_repo = cli_factory.make_repository({'product-id': module_product.id}) + new_repo = module_target_sat.cli_factory.make_repository({'product-id': module_product.id}) # Sync REPO Repository.synchronize({'id': new_repo['id']}) # Create new content-view and add repository to view - new_cv = cli_factory.make_content_view({'organization-id': module_org.id}) + new_cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) ContentView.add_repository( { 'id': new_cv['id'], @@ -736,7 +761,7 @@ def test_positive_remove_version_by_id_from_composite(self, module_org, module_p # Get the CV info new_cv = ContentView.info({'id': new_cv['id']}) # Create a composite CV - comp_cv = cli_factory.make_content_view( + comp_cv = module_target_sat.cli_factory.make_content_view( { 'composite': True, 'organization-id': module_org.id, @@ -755,7 +780,7 @@ def test_positive_remove_version_by_id_from_composite(self, module_org, module_p assert len(new_cv['versions']) == 0 @pytest.mark.tier2 - def test_positive_remove_component_by_name(self, module_org, module_product): + def test_positive_remove_component_by_name(self, module_org, module_product, module_target_sat): """Create a composite content view and remove component from it by name :id: 908f9cad-b985-4bae-96c0-037ea1d395a6 @@ -770,11 +795,11 @@ def test_positive_remove_component_by_name(self, module_org, module_product): :CaseImportance: High """ # Create new repository - new_repo = cli_factory.make_repository({'product-id': module_product.id}) + new_repo = module_target_sat.cli_factory.make_repository({'product-id': module_product.id}) # Sync REPO Repository.synchronize({'id': new_repo['id']}) # Create new content-view and add repository to view - new_cv = cli_factory.make_content_view({'organization-id': module_org.id}) + new_cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) ContentView.add_repository( { 'id': new_cv['id'], @@ -787,7 +812,7 @@ def test_positive_remove_component_by_name(self, module_org, module_product): # Get the CV info new_cv = ContentView.info({'id': new_cv['id']}) # Create a composite CV - comp_cv = cli_factory.make_content_view( + comp_cv = module_target_sat.cli_factory.make_content_view( { 'composite': True, 'organization-id': module_org.id, @@ -807,7 +832,7 @@ def test_positive_remove_component_by_name(self, module_org, module_product): assert len(comp_cv['components']) == 0 @pytest.mark.tier3 - def test_positive_create_composite_with_component_ids(self, module_org): + def test_positive_create_composite_with_component_ids(self, module_org, module_target_sat): """Create a composite content view with a component_ids option which ids are from different content views @@ -822,19 +847,19 @@ def test_positive_create_composite_with_component_ids(self, module_org): :CaseImportance: High """ # Create first CV - cv1 = cli_factory.make_content_view({'organization-id': module_org.id}) + cv1 = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) # Publish a new version of CV ContentView.publish({'id': cv1['id']}) cv1 = ContentView.info({'id': cv1['id']}) # Create second CV - cv2 = cli_factory.make_content_view({'organization-id': module_org.id}) + cv2 = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) # Publish a new version of CV ContentView.publish({'id': cv2['id']}) cv2 = ContentView.info({'id': cv2['id']}) # Let us now store the version ids component_ids = [cv1['versions'][0]['id'], cv2['versions'][0]['id']] # Create CV - comp_cv = cli_factory.make_content_view( + comp_cv = module_target_sat.cli_factory.make_content_view( {'composite': True, 'organization-id': module_org.id, 'component-ids': component_ids} ) # Assert whether the composite content view components IDs are equal @@ -844,7 +869,7 @@ def test_positive_create_composite_with_component_ids(self, module_org): assert {comp['id'] for comp in comp_cv['components']} == set(component_ids) @pytest.mark.tier3 - def test_negative_create_composite_with_component_ids(self, module_org): + def test_negative_create_composite_with_component_ids(self, module_org, module_target_sat): """Attempt to create a composite content view with a component_ids option which ids are from the same content view @@ -859,7 +884,7 @@ def test_negative_create_composite_with_component_ids(self, module_org): :CaseImportance: Low """ # Create CV - new_cv = cli_factory.make_content_view({'organization-id': module_org.id}) + new_cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) # Publish a new version of CV twice for _ in range(2): ContentView.publish({'id': new_cv['id']}) @@ -867,8 +892,8 @@ def test_negative_create_composite_with_component_ids(self, module_org): # Let us now store the version ids component_ids = [version['id'] for version in new_cv['versions']] # Try create CV - with pytest.raises(cli_factory.CLIFactoryError) as context: - cli_factory.make_content_view( + with pytest.raises(CLIFactoryError) as context: + module_target_sat.cli_factory.make_content_view( { 'composite': True, 'organization-id': module_org.id, @@ -878,7 +903,7 @@ def test_negative_create_composite_with_component_ids(self, module_org): assert 'Failed to create ContentView with data:' in str(context) @pytest.mark.tier3 - def test_positive_update_composite_with_component_ids(module_org): + 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 @@ -891,14 +916,14 @@ def test_positive_update_composite_with_component_ids(module_org): :CaseImportance: Low """ # Create a CV to add to the composite one - cv = cli_factory.make_content_view({'organization-id': module_org.id}) + cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) # Publish a new version of the CV ContentView.publish({'id': cv['id']}) new_cv = 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 = cli_factory.make_content_view( + 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 @@ -910,7 +935,9 @@ def test_positive_update_composite_with_component_ids(module_org): @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): + 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 @@ -924,7 +951,7 @@ def test_positive_add_rh_repo_by_id(self, module_entitlement_manifest_org, modul :CaseImportance: Critical """ # Create CV - new_cv = cli_factory.make_content_view( + new_cv = module_target_sat.cli_factory.make_content_view( {'organization-id': module_entitlement_manifest_org.id} ) # Associate repo to CV @@ -943,7 +970,7 @@ def test_positive_add_rh_repo_by_id(self, module_entitlement_manifest_org, modul @pytest.mark.tier3 @pytest.mark.upgrade def test_positive_add_rh_repo_by_id_and_create_filter( - self, module_entitlement_manifest_org, module_rhel_content + self, module_entitlement_manifest_org, module_rhel_content, module_target_sat ): """Associate Red Hat content to a content view and create filter @@ -963,7 +990,7 @@ def test_positive_add_rh_repo_by_id_and_create_filter( :BZ: 1359665 """ # Create CV - new_cv = cli_factory.make_content_view( + new_cv = module_target_sat.cli_factory.make_content_view( {'organization-id': module_entitlement_manifest_org.id} ) # Associate repo to CV @@ -1038,7 +1065,7 @@ 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): + 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 @@ -1051,18 +1078,18 @@ def test_positive_add_custom_repo_by_id(self, module_org, module_product): :CaseLevel: Integration """ - new_repo = cli_factory.make_repository({'product-id': module_product.id}) + new_repo = module_target_sat.cli_factory.make_repository({'product-id': module_product.id}) # Sync REPO Repository.synchronize({'id': new_repo['id']}) # Create CV - new_cv = cli_factory.make_content_view({'organization-id': module_org.id}) + new_cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) # Associate repo to CV ContentView.add_repository({'id': new_cv['id'], 'repository-id': new_repo['id']}) new_cv = 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): + 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 :id: 62431e11-bec6-4444-abb0-e3758ba25fd8 @@ -1073,11 +1100,11 @@ def test_positive_add_custom_repo_by_name(self, module_org, module_product): :BZ: 1343006 """ - new_repo = cli_factory.make_repository({'product-id': module_product.id}) + new_repo = module_target_sat.cli_factory.make_repository({'product-id': module_product.id}) # Sync REPO Repository.synchronize({'id': new_repo['id']}) # Create CV - new_cv = cli_factory.make_content_view({'organization-id': module_org.id}) + new_cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) # Associate repo to CV with names. ContentView.add_repository( { @@ -1091,7 +1118,9 @@ def test_positive_add_custom_repo_by_name(self, module_org, module_product): 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): + 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 @@ -1104,11 +1133,11 @@ def test_negative_add_component_in_non_composite_cv(self, module_org, module_pro :CaseLevel: Integration """ # Create REPO - new_repo = cli_factory.make_repository({'product-id': module_product.id}) + new_repo = module_target_sat.cli_factory.make_repository({'product-id': module_product.id}) # Sync REPO Repository.synchronize({'id': new_repo['id']}) # Create component CV - new_cv = cli_factory.make_content_view({'organization-id': module_org.id}) + new_cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) # Associate repo to CV ContentView.add_repository({'id': new_cv['id'], 'repository-id': new_repo['id']}) # Publish a new version of CV @@ -1116,13 +1145,13 @@ def test_negative_add_component_in_non_composite_cv(self, module_org, module_pro # Fetch version id cv_version = ContentView.version_list({'content-view-id': new_cv['id']}) # Create non-composite CV - with pytest.raises(cli_factory.CLIFactoryError): - cli_factory.make_content_view( + 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): + 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 content view @@ -1134,11 +1163,11 @@ def test_negative_add_same_yum_repo_twice(self, module_org, module_product): :CaseLevel: Integration """ - new_repo = cli_factory.make_repository({'product-id': module_product.id}) + new_repo = module_target_sat.cli_factory.make_repository({'product-id': module_product.id}) # Sync REPO Repository.synchronize({'id': new_repo['id']}) # Create CV - new_cv = cli_factory.make_content_view({'organization-id': module_org.id}) + new_cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) # Associate repo to CV ContentView.add_repository({'id': new_cv['id'], 'repository-id': new_repo['id']}) new_cv = ContentView.info({'id': new_cv['id']}) @@ -1152,7 +1181,7 @@ def test_negative_add_same_yum_repo_twice(self, module_org, module_product): @pytest.mark.run_in_one_thread @pytest.mark.tier2 def test_positive_promote_rh_content( - self, module_entitlement_manifest_org, module_rhel_content + self, module_entitlement_manifest_org, module_rhel_content, module_target_sat ): """attempt to promote a content view containing RH content @@ -1167,7 +1196,7 @@ def test_positive_promote_rh_content( :CaseLevel: Integration """ # Create CV - new_cv = cli_factory.make_content_view( + new_cv = module_target_sat.cli_factory.make_content_view( {'organization-id': module_entitlement_manifest_org.id} ) # Associate repo to CV @@ -1175,7 +1204,7 @@ def test_positive_promote_rh_content( # Publish a new version of CV ContentView.publish({'id': new_cv['id']}) new_cv = ContentView.info({'id': new_cv['id']}) - env1 = cli_factory.make_lifecycle_environment( + env1 = module_target_sat.cli_factory.make_lifecycle_environment( {'organization-id': module_entitlement_manifest_org.id} ) # Promote the Published version of CV to the next env @@ -1189,7 +1218,7 @@ def test_positive_promote_rh_content( @pytest.mark.run_in_one_thread @pytest.mark.tier3 def test_positive_promote_rh_and_custom_content( - self, module_entitlement_manifest_org, module_rhel_content + self, module_entitlement_manifest_org, module_rhel_content, module_target_sat ): """attempt to promote a content view containing RH content and custom content using filters @@ -1205,9 +1234,9 @@ def test_positive_promote_rh_and_custom_content( :CaseLevel: Integration """ # Create custom repo - new_repo = cli_factory.make_repository( + new_repo = module_target_sat.cli_factory.make_repository( { - 'product-id': cli_factory.make_product( + 'product-id': module_target_sat.cli_factory.make_product( {'organization-id': module_entitlement_manifest_org.id} )['id'] } @@ -1215,16 +1244,16 @@ def test_positive_promote_rh_and_custom_content( # Sync custom repo Repository.synchronize({'id': new_repo['id']}) # Create CV - new_cv = cli_factory.make_content_view( + new_cv = module_target_sat.cli_factory.make_content_view( {'organization-id': module_entitlement_manifest_org.id} ) # Associate repos with CV ContentView.add_repository({'id': new_cv['id'], 'repository-id': module_rhel_content['id']}) ContentView.add_repository({'id': new_cv['id'], 'repository-id': new_repo['id']}) - cvf = cli_factory.make_content_view_filter( + cvf = module_target_sat.cli_factory.make_content_view_filter( {'content-view-id': new_cv['id'], 'inclusion': 'false', 'type': 'rpm'} ) - cli_factory.make_content_view_filter_rule( + module_target_sat.cli_factory.content_view_filter_rule( { 'content-view-filter-id': cvf['filter-id'], 'min-version': 5, @@ -1234,7 +1263,7 @@ def test_positive_promote_rh_and_custom_content( # Publish a new version of CV ContentView.publish({'id': new_cv['id']}) new_cv = ContentView.info({'id': new_cv['id']}) - env1 = cli_factory.make_lifecycle_environment( + env1 = module_target_sat.cli_factory.make_lifecycle_environment( {'organization-id': module_entitlement_manifest_org.id} ) # Promote the Published version of CV to the next env @@ -1247,7 +1276,7 @@ def test_positive_promote_rh_and_custom_content( @pytest.mark.build_sanity @pytest.mark.tier2 - def test_positive_promote_custom_content(self, module_org, module_product): + def test_positive_promote_custom_content(self, module_org, module_product, module_target_sat): """attempt to promote a content view containing custom content :id: 64c2f1c2-7443-4836-a108-060b913ad2b1 @@ -1261,13 +1290,15 @@ def test_positive_promote_custom_content(self, module_org, module_product): :CaseLevel: Integration """ # Create REPO - new_repo = cli_factory.make_repository({'product-id': module_product.id}) + new_repo = module_target_sat.cli_factory.make_repository({'product-id': module_product.id}) # Sync REPO Repository.synchronize({'id': new_repo['id']}) # create lce - environment = cli_factory.make_lifecycle_environment({'organization-id': module_org.id}) + environment = module_target_sat.cli_factory.make_lifecycle_environment( + {'organization-id': module_org.id} + ) # Create CV - new_cv = cli_factory.make_content_view({'organization-id': module_org.id}) + new_cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) # Associate repo to CV ContentView.add_repository({'id': new_cv['id'], 'repository-id': new_repo['id']}) # Publish a new version of CV @@ -1286,7 +1317,7 @@ def test_positive_promote_custom_content(self, module_org, module_product): ] @pytest.mark.tier2 - def test_positive_promote_ccv(self, module_org, module_product): + def test_positive_promote_ccv(self, module_org, module_product, module_target_sat): """attempt to promote a content view containing custom content :id: 9d31113d-39ec-4524-854c-7f03b0f028fe @@ -1302,13 +1333,15 @@ def test_positive_promote_ccv(self, module_org, module_product): :CaseLevel: Integration """ # Create REPO - new_repo = cli_factory.make_repository({'product-id': module_product.id}) + new_repo = module_target_sat.cli_factory.make_repository({'product-id': module_product.id}) # Sync REPO Repository.synchronize({'id': new_repo['id']}) # Create lce - environment = cli_factory.make_lifecycle_environment({'organization-id': module_org.id}) + environment = module_target_sat.cli_factory.make_lifecycle_environment( + {'organization-id': module_org.id} + ) # Create CV - new_cv = cli_factory.make_content_view({'organization-id': module_org.id}) + new_cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) # Associate repo to CV ContentView.add_repository({'id': new_cv['id'], 'repository-id': new_repo['id']}) # Publish a new version of CV @@ -1317,7 +1350,7 @@ def test_positive_promote_ccv(self, module_org, module_product): # Let us now store the version1 id version1_id = new_cv['versions'][0]['id'] # Create CV - con_view = cli_factory.make_content_view( + con_view = module_target_sat.cli_factory.make_content_view( {'composite': True, 'organization-id': module_org.id} ) # Associate version to composite CV @@ -1339,7 +1372,7 @@ def test_positive_promote_ccv(self, module_org, module_product): ] @pytest.mark.tier2 - def test_negative_promote_default_cv(self, module_org): + def test_negative_promote_default_cv(self, module_org, module_target_sat): """attempt to promote a default content view :id: ef25a4d9-8852-4d2c-8355-e9b07eb0560b @@ -1350,7 +1383,9 @@ def test_negative_promote_default_cv(self, module_org): :CaseLevel: Integration """ - environment = cli_factory.make_lifecycle_environment({'organization-id': module_org.id}) + environment = module_target_sat.cli_factory.make_lifecycle_environment( + {'organization-id': module_org.id} + ) print("Hello, the org ID is currently", module_org.id) result = ContentView.list({'organization-id': module_org.id}, per_page=False) content_view = random.choice([cv for cv in result if cv['name'] == constants.DEFAULT_CV]) @@ -1362,7 +1397,7 @@ def test_negative_promote_default_cv(self, module_org): ) @pytest.mark.tier2 - def test_negative_promote_with_invalid_lce(self, module_org, module_product): + def test_negative_promote_with_invalid_lce(self, module_org, module_product, module_target_sat): """attempt to promote a content view using an invalid environment @@ -1375,11 +1410,11 @@ def test_negative_promote_with_invalid_lce(self, module_org, module_product): :CaseLevel: Integration """ # Create REPO - new_repo = cli_factory.make_repository({'product-id': module_product.id}) + new_repo = module_target_sat.cli_factory.make_repository({'product-id': module_product.id}) # Sync REPO Repository.synchronize({'id': new_repo['id']}) # Create CV - new_cv = cli_factory.make_content_view({'organization-id': module_org.id}) + new_cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) # Associate repo to CV ContentView.add_repository({'id': new_cv['id'], 'repository-id': new_repo['id']}) # Publish a new version of CV @@ -1401,7 +1436,7 @@ def test_negative_promote_with_invalid_lce(self, module_org, module_product): @pytest.mark.run_in_one_thread @pytest.mark.tier2 def test_positive_publish_rh_content( - self, module_entitlement_manifest_org, module_rhel_content + self, module_entitlement_manifest_org, module_rhel_content, module_target_sat ): """attempt to publish a content view containing RH content @@ -1416,7 +1451,7 @@ def test_positive_publish_rh_content( :CaseLevel: Integration """ # Create CV - new_cv = cli_factory.make_content_view( + new_cv = module_target_sat.cli_factory.make_content_view( {'organization-id': module_entitlement_manifest_org.id} ) # Associate repo to CV @@ -1432,7 +1467,7 @@ def test_positive_publish_rh_content( @pytest.mark.pit_server @pytest.mark.tier3 def test_positive_publish_rh_and_custom_content( - self, module_entitlement_manifest_org, module_rhel_content + self, module_entitlement_manifest_org, module_rhel_content, module_target_sat ): """attempt to publish a content view containing a RH and custom repos and has filters @@ -1448,9 +1483,9 @@ def test_positive_publish_rh_and_custom_content( :CaseLevel: Integration """ # Create custom repo - new_repo = cli_factory.make_repository( + new_repo = module_target_sat.cli_factory.make_repository( { - 'product-id': cli_factory.make_product( + 'product-id': module_target_sat.cli_factory.make_product( {'organization-id': module_entitlement_manifest_org.id} )['id'] } @@ -1458,16 +1493,16 @@ def test_positive_publish_rh_and_custom_content( # Sync custom repo Repository.synchronize({'id': new_repo['id']}) # Create CV - new_cv = cli_factory.make_content_view( + new_cv = module_target_sat.cli_factory.make_content_view( {'organization-id': module_entitlement_manifest_org.id} ) # Associate repos with CV ContentView.add_repository({'id': new_cv['id'], 'repository-id': module_rhel_content['id']}) ContentView.add_repository({'id': new_cv['id'], 'repository-id': new_repo['id']}) - cvf = cli_factory.make_content_view_filter( + cvf = module_target_sat.cli_factory.make_content_view_filter( {'content-view-id': new_cv['id'], 'inclusion': 'false', 'type': 'rpm'} ) - cli_factory.make_content_view_filter_rule( + module_target_sat.cli_factory.content_view_filter_rule( { 'content-view-filter-id': cvf['filter-id'], 'min-version': 5, @@ -1483,7 +1518,7 @@ 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): + 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 @@ -1496,11 +1531,11 @@ def test_positive_publish_custom_content(self, module_org, module_product): :CaseLevel: Integration """ - new_repo = cli_factory.make_repository({'product-id': module_product.id}) + new_repo = module_target_sat.cli_factory.make_repository({'product-id': module_product.id}) # Sync REPO Repository.synchronize({'id': new_repo['id']}) # Create CV - new_cv = cli_factory.make_content_view({'organization-id': module_org.id}) + new_cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) # Associate repo to CV ContentView.add_repository({'id': new_cv['id'], 'repository-id': new_repo['id']}) # Publish a new version of CV @@ -1510,7 +1545,7 @@ def test_positive_publish_custom_content(self, module_org, module_product): assert new_cv['versions'][0]['version'] == '1.0' @pytest.mark.tier2 - def test_positive_publish_custom_major_minor_cv_version(self): + def test_positive_publish_custom_major_minor_cv_version(self, module_target_sat): """CV can published with custom major and minor versions :id: 6697cd22-253a-4bdc-a108-7e0af22caaf4 @@ -1528,10 +1563,10 @@ def test_positive_publish_custom_major_minor_cv_version(self): :CaseLevel: System """ - org = cli_factory.make_org() + org = module_target_sat.cli_factory.make_org() major = random.randint(1, 1000) minor = random.randint(1, 1000) - content_view = cli_factory.make_content_view( + content_view = module_target_sat.cli_factory.make_content_view( {'name': gen_string('alpha'), 'organization-id': org['id']} ) ContentView.publish({'id': content_view['id'], 'major': major, 'minor': minor}) @@ -1545,7 +1580,9 @@ def test_positive_publish_custom_major_minor_cv_version(self): @pytest.mark.skipif( (not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url' ) - def test_positive_publish_custom_content_module_stream(self, module_org, module_product): + def test_positive_publish_custom_content_module_stream( + self, module_org, module_product, module_target_sat + ): """attempt to publish a content view containing custom content module streams @@ -1560,7 +1597,7 @@ def test_positive_publish_custom_content_module_stream(self, module_org, module_ :CaseLevel: Integration """ - software_repo = cli_factory.make_repository( + software_repo = module_target_sat.cli_factory.make_repository( { 'product-id': module_product.id, 'content-type': 'yum', @@ -1568,7 +1605,7 @@ def test_positive_publish_custom_content_module_stream(self, module_org, module_ } ) - animal_repo = cli_factory.make_repository( + animal_repo = module_target_sat.cli_factory.make_repository( { 'product-id': module_product.id, 'content-type': 'yum', @@ -1580,7 +1617,7 @@ def test_positive_publish_custom_content_module_stream(self, module_org, module_ Repository.synchronize({'id': animal_repo['id']}) Repository.synchronize({'id': software_repo['id']}) # Create CV - new_cv = cli_factory.make_content_view({'organization-id': module_org.id}) + new_cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) # Associate repo to CV ContentView.add_repository({'id': new_cv['id'], 'repository-id': animal_repo['id']}) # Publish a new version of CV @@ -1596,7 +1633,9 @@ def test_positive_publish_custom_content_module_stream(self, module_org, module_ assert len(module_streams) > 13 @pytest.mark.tier2 - def test_positive_republish_after_content_removed(self, module_org, module_product): + def test_positive_republish_after_content_removed( + self, module_org, module_product, module_target_sat + ): """Attempt to re-publish content view after all associated content were removed from that CV @@ -1616,9 +1655,9 @@ def test_positive_republish_after_content_removed(self, module_org, module_produ :CaseLevel: Integration """ # Create new Yum repository - yum_repo = cli_factory.make_repository({'product-id': module_product.id}) + yum_repo = module_target_sat.cli_factory.make_repository({'product-id': module_product.id}) # Create new Docker repository - docker_repo = cli_factory.make_repository( + docker_repo = module_target_sat.cli_factory.make_repository( { 'content-type': 'docker', 'docker-upstream-name': 'quay/busybox', @@ -1630,7 +1669,7 @@ def test_positive_republish_after_content_removed(self, module_org, module_produ for repo_id in [yum_repo['id'], docker_repo['id']]: Repository.synchronize({'id': repo_id}) # Create CV with different content types - new_cv = cli_factory.make_content_view( + new_cv = module_target_sat.cli_factory.make_content_view( { 'organization-id': module_org.id, 'repository-ids': [yum_repo['id'], docker_repo['id']], @@ -1663,7 +1702,7 @@ def test_positive_republish_after_content_removed(self, module_org, module_produ @pytest.mark.run_in_one_thread @pytest.mark.tier2 def test_positive_republish_after_rh_content_removed( - self, module_entitlement_manifest_org, module_rhel_content + self, module_entitlement_manifest_org, module_rhel_content, module_target_sat ): """Attempt to re-publish content view after all RH associated content was removed from that CV @@ -1683,7 +1722,7 @@ def test_positive_republish_after_rh_content_removed( :CaseImportance: Medium """ - new_cv = cli_factory.make_content_view( + new_cv = module_target_sat.cli_factory.make_content_view( {'organization-id': module_entitlement_manifest_org.id} ) # Associate repo to CV @@ -1712,7 +1751,7 @@ def test_positive_republish_after_rh_content_removed( assert len(new_cv['versions']) == 2 @pytest.mark.tier2 - def test_positive_publish_ccv(self, module_org, module_product): + def test_positive_publish_ccv(self, module_org, module_product, module_target_sat): """attempt to publish a composite content view containing custom content @@ -1726,11 +1765,15 @@ def test_positive_publish_ccv(self, module_org, module_product): :CaseLevel: Integration """ - repository = cli_factory.make_repository({'product-id': module_product.id}) + repository = module_target_sat.cli_factory.make_repository( + {'product-id': module_product.id} + ) # Sync REPO Repository.synchronize({'id': repository['id']}) # Create CV - content_view = cli_factory.make_content_view({'organization-id': module_org.id}) + content_view = module_target_sat.cli_factory.make_content_view( + {'organization-id': module_org.id} + ) # Associate repo to CV ContentView.add_repository({'id': content_view['id'], 'repository-id': repository['id']}) # Publish a new version of CV @@ -1739,7 +1782,7 @@ def test_positive_publish_ccv(self, module_org, module_product): # Let us now store the version1 id version1_id = content_view['versions'][0]['id'] # Create composite CV - composite_cv = cli_factory.make_content_view( + composite_cv = module_target_sat.cli_factory.make_content_view( {'composite': True, 'organization-id': module_org.id} ) # Associate version to composite CV @@ -1756,7 +1799,7 @@ def test_positive_publish_ccv(self, module_org, module_product): @pytest.mark.tier2 @pytest.mark.upgrade - def test_positive_update_version_once(self, module_org, module_product): + 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, @@ -1782,13 +1825,15 @@ def test_positive_update_version_once(self, module_org, module_product): :CaseImportance: Critical """ # Create REPO - new_repo = cli_factory.make_repository({'product-id': module_product.id}) + new_repo = module_target_sat.cli_factory.make_repository({'product-id': module_product.id}) # Sync REPO Repository.synchronize({'id': new_repo['id']}) # Create lce - environment = cli_factory.make_lifecycle_environment({'organization-id': module_org.id}) + environment = module_target_sat.cli_factory.make_lifecycle_environment( + {'organization-id': module_org.id} + ) # Create CV - new_cv = cli_factory.make_content_view({'organization-id': module_org.id}) + new_cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) # Associate repo to CV ContentView.add_repository({'id': new_cv['id'], 'repository-id': new_repo['id']}) # Publish a version1 of CV @@ -1829,7 +1874,7 @@ def test_positive_update_version_once(self, module_org, module_product): 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): + 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) @@ -1853,13 +1898,15 @@ def test_positive_update_version_multiple(self, module_org, module_product): :CaseLevel: Integration """ # Create REPO - new_repo = cli_factory.make_repository({'product-id': module_product.id}) + new_repo = module_target_sat.cli_factory.make_repository({'product-id': module_product.id}) # Sync REPO Repository.synchronize({'id': new_repo['id']}) # Create lce - environment = cli_factory.make_lifecycle_environment({'organization-id': module_org.id}) + environment = module_target_sat.cli_factory.make_lifecycle_environment( + {'organization-id': module_org.id} + ) # Create CV - new_cv = cli_factory.make_content_view({'organization-id': module_org.id}) + new_cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) # Associate repo to CV ContentView.add_repository({'id': new_cv['id'], 'repository-id': new_repo['id']}) # Publish a version1 of CV @@ -1907,7 +1954,9 @@ def test_positive_update_version_multiple(self, module_org, module_product): assert len(version1['lifecycle-environments']) == 0 @pytest.mark.tier2 - def test_positive_auto_update_composite_to_latest_cv_version(self, module_org): + 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. @@ -1933,12 +1982,14 @@ def test_positive_auto_update_composite_to_latest_cv_version(self, module_org): :CaseImportance: High """ - content_view = cli_factory.make_content_view({'organization-id': module_org.id}) + content_view = module_target_sat.cli_factory.make_content_view( + {'organization-id': module_org.id} + ) ContentView.publish({'id': content_view['id']}) content_view = ContentView.info({'id': content_view['id']}) assert len(content_view['versions']) == 1 version_1_id = content_view['versions'][0]['id'] - composite_cv = cli_factory.make_content_view( + composite_cv = module_target_sat.cli_factory.make_content_view( {'composite': True, 'organization-id': module_org.id} ) ContentView.component_add( @@ -1971,7 +2022,7 @@ def test_positive_auto_update_composite_to_latest_cv_version(self, module_org): assert components[0]['current-version'] == '2.0' @pytest.mark.tier3 - def test_positive_subscribe_chost_by_id(self, module_org): + 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 @@ -1982,15 +2033,19 @@ def test_positive_subscribe_chost_by_id(self, module_org): :CaseLevel: System """ - env = cli_factory.make_lifecycle_environment({'organization-id': module_org.id}) - content_view = cli_factory.make_content_view({'organization-id': module_org.id}) + 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} + ) ContentView.publish({'id': content_view['id']}) content_view = ContentView.info({'id': content_view['id']}) cvv = content_view['versions'][0] ContentView.version_promote({'id': cvv['id'], 'to-lifecycle-environment-id': env['id']}) content_view = ContentView.info({'id': content_view['id']}) assert content_view['content-host-count'] == '0' - cli_factory.make_fake_host( + module_target_sat.cli_factory.make_fake_host( { 'content-view-id': content_view['id'], 'lifecycle-environment-id': env['id'], @@ -2004,7 +2059,7 @@ def test_positive_subscribe_chost_by_id(self, module_org): @pytest.mark.run_in_one_thread @pytest.mark.tier3 def test_positive_subscribe_chost_by_id_using_rh_content( - self, module_entitlement_manifest_org, module_rhel_content + self, module_entitlement_manifest_org, module_rhel_content, module_target_sat ): """Attempt to subscribe content host to content view that has Red Hat repository assigned to it @@ -2018,10 +2073,10 @@ def test_positive_subscribe_chost_by_id_using_rh_content( :CaseImportance: Medium """ - env = cli_factory.make_lifecycle_environment( + env = module_target_sat.cli_factory.make_lifecycle_environment( {'organization-id': module_entitlement_manifest_org.id} ) - content_view = cli_factory.make_content_view( + content_view = module_target_sat.cli_factory.make_content_view( {'organization-id': module_entitlement_manifest_org.id} ) ContentView.add_repository( @@ -2039,7 +2094,7 @@ def test_positive_subscribe_chost_by_id_using_rh_content( ContentView.version_promote({'id': cvv['id'], 'to-lifecycle-environment-id': env['id']}) content_view = ContentView.info({'id': content_view['id']}) assert content_view['content-host-count'] == '0' - cli_factory.make_fake_host( + module_target_sat.cli_factory.make_fake_host( { 'content-view-id': content_view['id'], 'lifecycle-environment-id': env['id'], @@ -2054,7 +2109,7 @@ def test_positive_subscribe_chost_by_id_using_rh_content( @pytest.mark.tier3 @pytest.mark.upgrade def test_positive_subscribe_chost_by_id_using_rh_content_and_filters( - self, module_entitlement_manifest_org, module_rhel_content + self, module_entitlement_manifest_org, module_rhel_content, module_target_sat ): """Attempt to subscribe content host to filtered content view that has Red Hat repository assigned to it @@ -2070,10 +2125,10 @@ def test_positive_subscribe_chost_by_id_using_rh_content_and_filters( :CaseImportance: Low """ - env = cli_factory.make_lifecycle_environment( + env = module_target_sat.cli_factory.make_lifecycle_environment( {'organization-id': module_entitlement_manifest_org.id} ) - content_view = cli_factory.make_content_view( + content_view = module_target_sat.cli_factory.make_content_view( {'organization-id': module_entitlement_manifest_org.id} ) ContentView.add_repository( @@ -2096,7 +2151,7 @@ def test_positive_subscribe_chost_by_id_using_rh_content_and_filters( } ) - cli_factory.make_content_view_filter_rule( + module_target_sat.cli_factory.content_view_filter_rule( { 'content-view-filter': name, 'content-view-id': content_view['id'], @@ -2112,7 +2167,7 @@ def test_positive_subscribe_chost_by_id_using_rh_content_and_filters( content_view = ContentView.info({'id': content_view['id']}) assert content_view['content-host-count'] == '0' - cli_factory.make_fake_host( + module_target_sat.cli_factory.make_fake_host( { 'content-view-id': content_view['id'], 'lifecycle-environment-id': env['id'], @@ -2124,7 +2179,9 @@ def test_positive_subscribe_chost_by_id_using_rh_content_and_filters( assert content_view['content-host-count'] == '1' @pytest.mark.tier3 - def test_positive_subscribe_chost_by_id_using_custom_content(self, module_org): + 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 @@ -2137,11 +2194,15 @@ def test_positive_subscribe_chost_by_id_using_custom_content(self, module_org): :CaseImportance: High """ - new_product = cli_factory.make_product({'organization-id': module_org.id}) - new_repo = cli_factory.make_repository({'product-id': new_product['id']}) - env = cli_factory.make_lifecycle_environment({'organization-id': module_org.id}) + new_product = module_target_sat.cli_factory.make_product({'organization-id': module_org.id}) + new_repo = module_target_sat.cli_factory.make_repository({'product-id': new_product['id']}) + env = module_target_sat.cli_factory.make_lifecycle_environment( + {'organization-id': module_org.id} + ) Repository.synchronize({'id': new_repo['id']}) - content_view = cli_factory.make_content_view({'organization-id': module_org.id}) + content_view = module_target_sat.cli_factory.make_content_view( + {'organization-id': module_org.id} + ) ContentView.add_repository( { 'id': content_view['id'], @@ -2158,7 +2219,7 @@ def test_positive_subscribe_chost_by_id_using_custom_content(self, module_org): content_view = ContentView.info({'id': content_view['id']}) assert content_view['content-host-count'] == '0' - cli_factory.make_fake_host( + module_target_sat.cli_factory.make_fake_host( { 'content-view-id': content_view['id'], 'lifecycle-environment-id': env['id'], @@ -2170,7 +2231,7 @@ def test_positive_subscribe_chost_by_id_using_custom_content(self, module_org): assert content_view['content-host-count'] == '1' @pytest.mark.tier3 - def test_positive_subscribe_chost_by_id_using_ccv(self, module_org): + def test_positive_subscribe_chost_by_id_using_ccv(self, module_org, module_target_sat): """Attempt to subscribe content host to composite content view :id: 4be340c0-9e58-4b96-ab37-d7e3b12c724f @@ -2182,8 +2243,10 @@ def test_positive_subscribe_chost_by_id_using_ccv(self, module_org): :CaseLevel: System """ - env = cli_factory.make_lifecycle_environment({'organization-id': module_org.id}) - content_view = cli_factory.make_content_view( + env = module_target_sat.cli_factory.make_lifecycle_environment( + {'organization-id': module_org.id} + ) + content_view = module_target_sat.cli_factory.make_content_view( {'composite': True, 'organization-id': module_org.id} ) ContentView.publish({'id': content_view['id']}) @@ -2194,7 +2257,7 @@ def test_positive_subscribe_chost_by_id_using_ccv(self, module_org): content_view = ContentView.info({'id': content_view['id']}) assert content_view['content-host-count'] == '0' - cli_factory.make_fake_host( + module_target_sat.cli_factory.make_fake_host( { 'content-view-id': content_view['id'], 'lifecycle-environment-id': env['id'], @@ -2274,12 +2337,12 @@ def test_positive_sub_host_with_restricted_user_perm_at_custom_loc( 'Architecture': ['view_architectures'], } # Create a location and organization - loc = cli_factory.make_location() + loc = target_sat.cli_factory.make_location() default_loc = Location.info({'name': constants.DEFAULT_LOC}) - org = cli_factory.make_org() + org = target_sat.cli_factory.make_org() Org.add_location({'id': org['id'], 'location-id': loc['id']}) # Create a non admin user, for the moment without any permissions - user = cli_factory.make_user( + user = target_sat.cli_factory.make_user( { 'admin': False, 'default-organization-id': org['id'], @@ -2291,7 +2354,7 @@ def test_positive_sub_host_with_restricted_user_perm_at_custom_loc( } ) # Create a new role - role = cli_factory.make_role() + role = target_sat.cli_factory.make_role() # Get the available permissions available_permissions = Filter.available_permissions() # group the available permissions by resource type @@ -2313,7 +2376,9 @@ def test_positive_sub_host_with_restricted_user_perm_at_custom_loc( # assert that all the required permissions are available assert set(permission_names) == set(available_permission_names) # Create the current resource type role permissions - cli_factory.make_filter({'role-id': role['id'], 'permissions': permission_names}) + target_sat.cli_factory.make_filter( + {'role-id': role['id'], 'permissions': permission_names} + ) # Add the created and initiated role with permissions to user User.add_role({'id': user['id'], 'role-id': role['id']}) # assert that the user is not an admin one and cannot read the current @@ -2322,16 +2387,16 @@ def test_positive_sub_host_with_restricted_user_perm_at_custom_loc( Role.with_user(user_name, user_password).info({'id': role['id']}) assert 'Access denied' in str(context) # Create a lifecycle environment - env = cli_factory.make_lifecycle_environment({'organization-id': org['id']}) + env = target_sat.cli_factory.make_lifecycle_environment({'organization-id': org['id']}) # Create a product - product = cli_factory.make_product({'organization-id': org['id']}) + product = target_sat.cli_factory.make_product({'organization-id': org['id']}) # Create a yum repository and synchronize - repo = cli_factory.make_repository( + repo = target_sat.cli_factory.make_repository( {'product-id': product['id'], 'url': settings.repos.yum_1.url} ) Repository.synchronize({'id': repo['id']}) # Create a content view, add the yum repository and publish - content_view = cli_factory.make_content_view({'organization-id': org['id']}) + content_view = target_sat.cli_factory.make_content_view({'organization-id': org['id']}) ContentView.add_repository( {'id': content_view['id'], 'organization-id': org['id'], 'repository-id': repo['id']} ) @@ -2429,10 +2494,10 @@ def test_positive_sub_host_with_restricted_user_perm_at_default_loc( } # Create organization loc = Location.info({'name': constants.DEFAULT_LOC}) - org = cli_factory.make_org() + org = target_sat.cli_factory.make_org() Org.add_location({'id': org['id'], 'location-id': loc['id']}) # Create a non admin user, for the moment without any permissions - user = cli_factory.make_user( + user = target_sat.cli_factory.make_user( { 'admin': False, 'default-organization-id': org['id'], @@ -2444,7 +2509,7 @@ def test_positive_sub_host_with_restricted_user_perm_at_default_loc( } ) # Create a new role - role = cli_factory.make_role() + role = target_sat.cli_factory.make_role() # Get the available permissions available_permissions = Filter.available_permissions() # group the available permissions by resource type @@ -2466,7 +2531,9 @@ def test_positive_sub_host_with_restricted_user_perm_at_default_loc( # assert that all the required permissions are available assert set(permission_names) == set(available_permission_names) # Create the current resource type role permissions - cli_factory.make_filter({'role-id': role['id'], 'permissions': permission_names}) + target_sat.cli_factory.make_filter( + {'role-id': role['id'], 'permissions': permission_names} + ) # Add the created and initiated role with permissions to user User.add_role({'id': user['id'], 'role-id': role['id']}) # assert that the user is not an admin one and cannot read the current @@ -2475,16 +2542,16 @@ def test_positive_sub_host_with_restricted_user_perm_at_default_loc( Role.with_user(user_name, user_password).info({'id': role['id']}) assert '403 Forbidden' in str(context) # Create a lifecycle environment - env = cli_factory.make_lifecycle_environment({'organization-id': org['id']}) + env = target_sat.cli_factory.make_lifecycle_environment({'organization-id': org['id']}) # Create a product - product = cli_factory.make_product({'organization-id': org['id']}) + product = target_sat.cli_factory.make_product({'organization-id': org['id']}) # Create a yum repository and synchronize - repo = cli_factory.make_repository( + repo = target_sat.cli_factory.make_repository( {'product-id': product['id'], 'url': settings.repos.yum_1.url} ) Repository.synchronize({'id': repo['id']}) # Create a content view, add the yum repository and publish - content_view = cli_factory.make_content_view({'organization-id': org['id']}) + content_view = target_sat.cli_factory.make_content_view({'organization-id': org['id']}) ContentView.add_repository( {'id': content_view['id'], 'organization-id': org['id'], 'repository-id': repo['id']} ) @@ -2519,7 +2586,7 @@ def test_positive_sub_host_with_restricted_user_perm_at_default_loc( assert org_hosts[0]['name'] == rhel7_contenthost.hostname @pytest.mark.tier1 - def test_positive_clone_by_id(self, module_org): + def test_positive_clone_by_id(self, module_org, module_target_sat): """Clone existing content view by id :id: e3b63e6e-0964-45fb-a765-e1885c0ecbdd @@ -2529,13 +2596,15 @@ def test_positive_clone_by_id(self, module_org): :CaseImportance: Critical """ cloned_cv_name = gen_string('alpha') - content_view = cli_factory.make_content_view({'organization-id': module_org.id}) + content_view = module_target_sat.cli_factory.make_content_view( + {'organization-id': module_org.id} + ) new_cv = ContentView.copy({'id': content_view['id'], 'new-name': cloned_cv_name})[0] new_cv = 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): + def test_positive_clone_by_name(self, module_org, module_target_sat): """Clone existing content view by name :id: b4c94286-ebbe-4e4c-a1df-22cb7055984d @@ -2547,7 +2616,9 @@ def test_positive_clone_by_name(self, module_org): :CaseImportance: Critical """ cloned_cv_name = gen_string('alpha') - content_view = cli_factory.make_content_view({'organization-id': module_org.id}) + content_view = module_target_sat.cli_factory.make_content_view( + {'organization-id': module_org.id} + ) new_cv = ContentView.copy( { 'name': content_view['name'], @@ -2559,7 +2630,7 @@ def test_positive_clone_by_name(self, module_org): assert new_cv['name'] == cloned_cv_name @pytest.mark.tier2 - def test_positive_clone_within_same_env(self, module_org): + def test_positive_clone_within_same_env(self, module_org, module_target_sat): """Attempt to create, publish and promote new content view based on existing view within the same environment as the original content view @@ -2573,8 +2644,12 @@ def test_positive_clone_within_same_env(self, module_org): :CaseImportance: High """ cloned_cv_name = gen_string('alpha') - lc_env = cli_factory.make_lifecycle_environment({'organization-id': module_org.id}) - content_view = cli_factory.make_content_view({'organization-id': module_org.id}) + lc_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} + ) ContentView.publish({'id': content_view['id']}) content_view = ContentView.info({'id': content_view['id']}) cvv = content_view['versions'][0] @@ -2588,7 +2663,7 @@ def test_positive_clone_within_same_env(self, module_org): assert {'id': lc_env['id'], 'name': lc_env['name']} in new_cv['lifecycle-environments'] @pytest.mark.tier2 - def test_positive_clone_with_diff_env(self, module_org): + def test_positive_clone_with_diff_env(self, module_org, module_target_sat): """Attempt to create, publish and promote new content view based on existing view but promoted to a different environment @@ -2602,9 +2677,15 @@ def test_positive_clone_with_diff_env(self, module_org): :CaseLevel: Integration """ cloned_cv_name = gen_string('alpha') - lc_env = cli_factory.make_lifecycle_environment({'organization-id': module_org.id}) - lc_env_cloned = cli_factory.make_lifecycle_environment({'organization-id': module_org.id}) - content_view = cli_factory.make_content_view({'organization-id': module_org.id}) + lc_env = module_target_sat.cli_factory.make_lifecycle_environment( + {'organization-id': module_org.id} + ) + lc_env_cloned = 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} + ) ContentView.publish({'id': content_view['id']}) content_view = ContentView.info({'id': content_view['id']}) cvv = content_view['versions'][0] @@ -2657,7 +2738,9 @@ def test_positive_restart_dynflow_publish(self): @pytest.mark.skipif( (not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url' ) - def test_positive_remove_renamed_cv_version_from_default_env(self, module_org): + def test_positive_remove_renamed_cv_version_from_default_env( + self, module_org, module_target_sat + ): """Remove version of renamed content view from Library environment :id: aa9bbfda-72e8-45ec-b26d-fdf2691980cf @@ -2678,8 +2761,10 @@ def test_positive_remove_renamed_cv_version_from_default_env(self, module_org): :CaseImportance: Low """ new_name = gen_string('alpha') - custom_yum_product = cli_factory.make_product({'organization-id': module_org.id}) - custom_yum_repo = cli_factory.make_repository( + 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'], @@ -2687,7 +2772,9 @@ def test_positive_remove_renamed_cv_version_from_default_env(self, module_org): } ) Repository.synchronize({'id': custom_yum_repo['id']}) - content_view = cli_factory.make_content_view({'organization-id': module_org.id}) + content_view = module_target_sat.cli_factory.make_content_view( + {'organization-id': module_org.id} + ) ContentView.add_repository( { 'id': content_view['id'], @@ -2725,7 +2812,9 @@ def test_positive_remove_renamed_cv_version_from_default_env(self, module_org): @pytest.mark.skipif( (not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url' ) - def test_positive_remove_promoted_cv_version_from_default_env(self, module_org): + def test_positive_remove_promoted_cv_version_from_default_env( + self, module_org, module_target_sat + ): """Remove promoted content view version from Library environment :id: 6643837a-560a-47de-aa4d-90778914dcfa @@ -2747,9 +2836,13 @@ def test_positive_remove_promoted_cv_version_from_default_env(self, module_org): :CaseImportance: High """ - lce_dev = cli_factory.make_lifecycle_environment({'organization-id': module_org.id}) - custom_product = cli_factory.make_product({'organization-id': module_org.id}) - custom_yum_repo = cli_factory.make_repository( + lce_dev = module_target_sat.cli_factory.make_lifecycle_environment( + {'organization-id': module_org.id} + ) + custom_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_product['id'], @@ -2757,7 +2850,9 @@ def test_positive_remove_promoted_cv_version_from_default_env(self, module_org): } ) Repository.synchronize({'id': custom_yum_repo['id']}) - content_view = cli_factory.make_content_view({'organization-id': module_org.id}) + content_view = module_target_sat.cli_factory.make_content_view( + {'organization-id': module_org.id} + ) ContentView.add_repository( { 'id': content_view['id'], @@ -2807,7 +2902,9 @@ def test_positive_remove_promoted_cv_version_from_default_env(self, module_org): 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): + 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 @@ -2828,12 +2925,16 @@ def test_positive_remove_qe_promoted_cv_version_from_default_env(self, module_or :CaseImportance: High """ - lce_dev = cli_factory.make_lifecycle_environment({'organization-id': module_org.id}) - lce_qe = cli_factory.make_lifecycle_environment( + 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 = cli_factory.make_product({'organization-id': module_org.id}) - docker_repository = cli_factory.make_repository( + 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, @@ -2843,7 +2944,9 @@ def test_positive_remove_qe_promoted_cv_version_from_default_env(self, module_or } ) Repository.synchronize({'id': docker_repository['id']}) - content_view = cli_factory.make_content_view({'organization-id': module_org.id}) + content_view = module_target_sat.cli_factory.make_content_view( + {'organization-id': module_org.id} + ) ContentView.add_repository( { 'id': content_view['id'], @@ -2884,7 +2987,9 @@ def test_positive_remove_qe_promoted_cv_version_from_default_env(self, module_or @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): + 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 @@ -2905,15 +3010,19 @@ def test_positive_remove_prod_promoted_cv_version_from_default_env(self, module_ :CaseLevel: Integration """ - lce_dev = cli_factory.make_lifecycle_environment({'organization-id': module_org.id}) - lce_qe = cli_factory.make_lifecycle_environment( + 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 = cli_factory.make_lifecycle_environment( + lce_prod = module_target_sat.cli_factory.make_lifecycle_environment( {'organization-id': module_org.id, 'prior': lce_qe['name']} ) - custom_yum_product = cli_factory.make_product({'organization-id': module_org.id}) - custom_yum_repo = cli_factory.make_repository( + 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'], @@ -2921,8 +3030,10 @@ def test_positive_remove_prod_promoted_cv_version_from_default_env(self, module_ } ) Repository.synchronize({'id': custom_yum_repo['id']}) - docker_product = cli_factory.make_product({'organization-id': module_org.id}) - docker_repository = cli_factory.make_repository( + 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, @@ -2932,7 +3043,9 @@ def test_positive_remove_prod_promoted_cv_version_from_default_env(self, module_ } ) Repository.synchronize({'id': docker_repository['id']}) - content_view = cli_factory.make_content_view({'organization-id': module_org.id}) + content_view = module_target_sat.cli_factory.make_content_view( + {'organization-id': module_org.id} + ) for repo in [custom_yum_repo, docker_repository]: ContentView.add_repository( { @@ -2977,7 +3090,7 @@ def test_positive_remove_prod_promoted_cv_version_from_default_env(self, module_ @pytest.mark.skipif( (not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url' ) - def test_positive_remove_cv_version_from_env(self, module_org): + def test_positive_remove_cv_version_from_env(self, module_org, module_target_sat): """Remove promoted content view version from environment :id: 577757ac-b184-4ece-9310-182dd5ceb718 @@ -3001,18 +3114,22 @@ def test_positive_remove_cv_version_from_env(self, module_org): :CaseImportance: High """ - lce_dev = cli_factory.make_lifecycle_environment({'organization-id': module_org.id}) - lce_qe = cli_factory.make_lifecycle_environment( + 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 = cli_factory.make_lifecycle_environment( + lce_stage = module_target_sat.cli_factory.make_lifecycle_environment( {'organization-id': module_org.id, 'prior': lce_qe['name']} ) - lce_prod = cli_factory.make_lifecycle_environment( + lce_prod = module_target_sat.cli_factory.make_lifecycle_environment( {'organization-id': module_org.id, 'prior': lce_stage['name']} ) - custom_yum_product = cli_factory.make_product({'organization-id': module_org.id}) - custom_yum_repo = cli_factory.make_repository( + 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'], @@ -3020,8 +3137,10 @@ def test_positive_remove_cv_version_from_env(self, module_org): } ) Repository.synchronize({'id': custom_yum_repo['id']}) - docker_product = cli_factory.make_product({'organization-id': module_org.id}) - docker_repository = cli_factory.make_repository( + 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, @@ -3031,7 +3150,9 @@ def test_positive_remove_cv_version_from_env(self, module_org): } ) Repository.synchronize({'id': docker_repository['id']}) - content_view = cli_factory.make_content_view({'organization-id': module_org.id}) + content_view = module_target_sat.cli_factory.make_content_view( + {'organization-id': module_org.id} + ) for repo in [custom_yum_repo, docker_repository]: ContentView.add_repository( { @@ -3089,7 +3210,7 @@ def test_positive_remove_cv_version_from_env(self, module_org): @pytest.mark.skipif( (not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url' ) - def test_positive_remove_cv_version_from_multi_env(self, module_org): + def test_positive_remove_cv_version_from_multi_env(self, module_org, module_target_sat): """Remove promoted content view version from multiple environment :id: 997cfd7d-9029-47e2-a41e-84f4370b5ce5 @@ -3109,18 +3230,22 @@ def test_positive_remove_cv_version_from_multi_env(self, module_org): :CaseImportance: High """ - lce_dev = cli_factory.make_lifecycle_environment({'organization-id': module_org.id}) - lce_qe = cli_factory.make_lifecycle_environment( + 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 = cli_factory.make_lifecycle_environment( + lce_stage = module_target_sat.cli_factory.make_lifecycle_environment( {'organization-id': module_org.id, 'prior': lce_qe['name']} ) - lce_prod = cli_factory.make_lifecycle_environment( + lce_prod = module_target_sat.cli_factory.make_lifecycle_environment( {'organization-id': module_org.id, 'prior': lce_stage['name']} ) - custom_yum_product = cli_factory.make_product({'organization-id': module_org.id}) - custom_yum_repo = cli_factory.make_repository( + 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'], @@ -3128,8 +3253,10 @@ def test_positive_remove_cv_version_from_multi_env(self, module_org): } ) Repository.synchronize({'id': custom_yum_repo['id']}) - docker_product = cli_factory.make_product({'organization-id': module_org.id}) - docker_repository = cli_factory.make_repository( + 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, @@ -3139,7 +3266,9 @@ def test_positive_remove_cv_version_from_multi_env(self, module_org): } ) Repository.synchronize({'id': docker_repository['id']}) - content_view = cli_factory.make_content_view({'organization-id': module_org.id}) + content_view = module_target_sat.cli_factory.make_content_view( + {'organization-id': module_org.id} + ) for repo in [custom_yum_repo, docker_repository]: ContentView.add_repository( { @@ -3182,7 +3311,7 @@ def test_positive_remove_cv_version_from_multi_env(self, module_org): ) @pytest.mark.tier3 - def test_positive_delete_cv_promoted_to_multi_env(self, module_org): + 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 @@ -3204,18 +3333,22 @@ def test_positive_delete_cv_promoted_to_multi_env(self, module_org): :CaseImportance: High """ - lce_dev = cli_factory.make_lifecycle_environment({'organization-id': module_org.id}) - lce_qe = cli_factory.make_lifecycle_environment( + 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 = cli_factory.make_lifecycle_environment( + lce_stage = module_target_sat.cli_factory.make_lifecycle_environment( {'organization-id': module_org.id, 'prior': lce_qe['name']} ) - lce_prod = cli_factory.make_lifecycle_environment( + lce_prod = module_target_sat.cli_factory.make_lifecycle_environment( {'organization-id': module_org.id, 'prior': lce_stage['name']} ) - custom_yum_product = cli_factory.make_product({'organization-id': module_org.id}) - custom_yum_repo = cli_factory.make_repository( + 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'], @@ -3223,8 +3356,10 @@ def test_positive_delete_cv_promoted_to_multi_env(self, module_org): } ) Repository.synchronize({'id': custom_yum_repo['id']}) - docker_product = cli_factory.make_product({'organization-id': module_org.id}) - docker_repository = cli_factory.make_repository( + 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, @@ -3234,7 +3369,9 @@ def test_positive_delete_cv_promoted_to_multi_env(self, module_org): } ) Repository.synchronize({'id': docker_repository['id']}) - content_view = cli_factory.make_content_view({'organization-id': module_org.id}) + content_view = module_target_sat.cli_factory.make_content_view( + {'organization-id': module_org.id} + ) for repo in [custom_yum_repo, docker_repository]: ContentView.add_repository( { @@ -3367,7 +3504,7 @@ def test_positive_delete_cv_multi_env_promoted_with_host_registered(self): (not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url' ) def test_positive_remove_cv_version_from_multi_env_capsule_scenario( - self, module_org, capsule_configured + self, module_org, capsule_configured, module_target_sat ): """Remove promoted content view version from multiple environment, with satellite setup to use capsule @@ -3405,11 +3542,13 @@ def test_positive_remove_cv_version_from_multi_env_capsule_scenario( """ # Note: This test case requires complete external capsule # configuration. - dev_env = cli_factory.make_lifecycle_environment({'organization-id': module_org.id}) - qe_env = cli_factory.make_lifecycle_environment( + dev_env = module_target_sat.cli_factory.make_lifecycle_environment( + {'organization-id': module_org.id} + ) + qe_env = module_target_sat.cli_factory.make_lifecycle_environment( {'organization-id': module_org.id, 'prior': dev_env['name']} ) - prod_env = cli_factory.make_lifecycle_environment( + prod_env = module_target_sat.cli_factory.make_lifecycle_environment( {'organization-id': module_org.id, 'prior': qe_env['name']} ) capsule = Capsule().info({'name': capsule_configured.hostname}) @@ -3429,8 +3568,10 @@ def test_positive_remove_cv_version_from_multi_env_capsule_scenario( capsule_environments_names = {env['name'] for env in capsule_environments} assert environments == capsule_environments_names # Setup a yum repo - custom_yum_product = cli_factory.make_product({'organization-id': module_org.id}) - custom_yum_repo = cli_factory.make_repository( + 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'], @@ -3438,8 +3579,10 @@ def test_positive_remove_cv_version_from_multi_env_capsule_scenario( } ) Repository.synchronize({'id': custom_yum_repo['id']}) - docker_product = cli_factory.make_product({'organization-id': module_org.id}) - docker_repository = cli_factory.make_repository( + 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, @@ -3449,7 +3592,9 @@ def test_positive_remove_cv_version_from_multi_env_capsule_scenario( } ) Repository.synchronize({'id': docker_repository['id']}) - content_view = cli_factory.make_content_view({'organization-id': module_org.id}) + content_view = module_target_sat.cli_factory.make_content_view( + {'organization-id': module_org.id} + ) for repo in [custom_yum_repo, docker_repository]: ContentView.add_repository( { @@ -3541,7 +3686,7 @@ def test_positive_remove_cv_version_from_multi_env_capsule_scenario( assert content_view['name'] not in capsule_content_info_lce_cvs_names @pytest.mark.tier2 - def test_negative_user_with_no_create_view_cv_permissions(self, module_org): + def test_negative_user_with_no_create_view_cv_permissions(self, module_org, module_target_sat): """Unauthorized users are not able to create/view content views :id: 17617893-27c2-4cb2-a2ed-47378ef90e7a @@ -3554,9 +3699,9 @@ def test_negative_user_with_no_create_view_cv_permissions(self, module_org): :CaseImportance: Critical """ password = gen_alphanumeric() - no_rights_user = cli_factory.make_user({'password': password}) + no_rights_user = module_target_sat.cli_factory.make_user({'password': password}) no_rights_user['password'] = password - org_id = cli_factory.make_org(cached=True)['id'] + org_id = module_target_sat.cli_factory.make_org(cached=True)['id'] for name in generate_strings_list(exclude_types=['cjk']): # test that user can't create with pytest.raises(CLIReturnCodeError): @@ -3564,14 +3709,16 @@ def test_negative_user_with_no_create_view_cv_permissions(self, module_org): {'name': name, 'organization-id': org_id} ) # test that user can't read - con_view = cli_factory.make_content_view({'name': name, 'organization-id': org_id}) + con_view = module_target_sat.cli_factory.make_content_view( + {'name': name, 'organization-id': org_id} + ) with pytest.raises(CLIReturnCodeError): ContentView.with_user(no_rights_user['login'], no_rights_user['password']).info( {'id': con_view['id']} ) @pytest.mark.tier2 - def test_negative_user_with_read_only_cv_permission(self, module_org): + def test_negative_user_with_read_only_cv_permission(self, module_org, module_target_sat): """Read-only user is able to view content view :id: 588f57b5-9855-4c14-80d0-64b617c6b6dc @@ -3588,12 +3735,14 @@ def test_negative_user_with_read_only_cv_permission(self, module_org): :CaseImportance: Critical """ - cv = cli_factory.make_content_view({'organization-id': module_org.id}) - environment = cli_factory.make_lifecycle_environment({'organization-id': module_org.id}) + cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) + environment = module_target_sat.cli_factory.make_lifecycle_environment( + {'organization-id': module_org.id} + ) password = gen_string('alphanumeric') - user = cli_factory.make_user({'password': password}) - role = cli_factory.make_role() - cli_factory.make_filter( + user = module_target_sat.cli_factory.make_user({'password': password}) + role = module_target_sat.cli_factory.make_role() + module_target_sat.cli_factory.make_filter( { 'organization-ids': module_org.id, 'permissions': 'view_content_views', @@ -3644,7 +3793,7 @@ def test_negative_user_with_read_only_cv_permission(self, module_org): ) @pytest.mark.tier2 - def test_positive_user_with_all_cv_permissions(self, module_org): + def test_positive_user_with_all_cv_permissions(self, module_org, module_target_sat): """A user with all content view permissions is able to create, read, modify, promote, publish content views @@ -3661,16 +3810,20 @@ def test_positive_user_with_all_cv_permissions(self, module_org): :CaseImportance: Critical """ - cv = cli_factory.make_content_view({'organization-id': module_org.id}) - environment = cli_factory.make_lifecycle_environment({'organization-id': module_org.id}) + cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) + environment = module_target_sat.cli_factory.make_lifecycle_environment( + {'organization-id': module_org.id} + ) password = gen_string('alphanumeric') - user = cli_factory.make_user({'password': password, 'organization-ids': module_org.id}) - role = cli_factory.make_role({'organization-ids': module_org.id}) + user = module_target_sat.cli_factory.make_user( + {'password': password, 'organization-ids': module_org.id} + ) + role = module_target_sat.cli_factory.make_role({'organization-ids': module_org.id}) # note: the filters inherit role organizations - cli_factory.make_filter( + module_target_sat.cli_factory.make_filter( {'permissions': constants.PERMISSIONS['Katello::ContentView'], 'role-id': role['id']} ) - cli_factory.make_filter( + module_target_sat.cli_factory.make_filter( {'permissions': constants.PERMISSIONS['Katello::KTEnvironment'], 'role-id': role['id']} ) User.add_role({'id': user['id'], 'role-id': role['id']}) @@ -3711,7 +3864,7 @@ def test_positive_user_with_all_cv_permissions(self, module_org): @pytest.mark.skipif( (not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url' ) - def test_positive_inc_update_no_lce(self, module_org, module_product): + def test_positive_inc_update_no_lce(self, module_org, module_product, module_target_sat): """Publish incremental update without providing lifecycle environment for a content view version not promoted to any lifecycle environment @@ -3727,7 +3880,7 @@ def test_positive_inc_update_no_lce(self, module_org, module_product): :CaseLevel: Integration """ - repo = cli_factory.make_repository( + repo = module_target_sat.cli_factory.make_repository( { 'product-id': module_product.id, 'content-type': 'yum', @@ -3735,7 +3888,7 @@ def test_positive_inc_update_no_lce(self, module_org, module_product): } ) Repository.synchronize({'id': repo['id']}) - content_view = cli_factory.make_content_view( + content_view = module_target_sat.cli_factory.make_content_view( {'organization-id': module_org.id, 'repository-ids': repo['id']} ) ContentView.add_repository( @@ -3745,7 +3898,7 @@ def test_positive_inc_update_no_lce(self, module_org, module_product): 'repository-id': repo['id'], } ) - cvf = cli_factory.make_content_view_filter( + cvf = module_target_sat.cli_factory.make_content_view_filter( { 'content-view-id': content_view['id'], 'inclusion': 'true', @@ -3753,7 +3906,7 @@ def test_positive_inc_update_no_lce(self, module_org, module_product): 'type': 'rpm', }, ) - cli_factory.make_content_view_filter_rule( + module_target_sat.cli_factory.content_view_filter_rule( { 'content-view-filter-id': cvf['filter-id'], 'name': FAKE_2_CUSTOM_PACKAGE_NAME, @@ -3788,8 +3941,8 @@ def make_file_repository_upload_contents( if options is None: options = {'product-id': module_product.id, 'content-type': 'file'} if not options.get('content-type'): - raise cli_factory.CLIFactoryError('Please provide a valid Content Type.') - new_repo = cli_factory.make_repository(options) + raise satellite.cli_factory.CLIFactoryError('Please provide a valid Content Type.') + new_repo = satellite.cli_factory.make_repository(options) remote_path = f'/tmp/{constants.RPM_TO_UPLOAD}' satellite.put(DataFile.RPM_TO_UPLOAD, remote_path) Repository.upload_content( @@ -3833,7 +3986,7 @@ def test_positive_arbitrary_file_repo_addition(self, module_org, module_product, repo = self.make_file_repository_upload_contents( module_org, module_product, satellite=target_sat ) - cv = cli_factory.make_content_view({'organization-id': module_org.id}) + cv = target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) # Associate repo to CV with names. ContentView.add_repository( { @@ -3871,7 +4024,7 @@ def test_positive_arbitrary_file_repo_removal(self, module_org, module_product, :BZ: 1908465 """ - cv = cli_factory.make_content_view({'organization-id': module_org.id}) + cv = target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) repo = self.make_file_repository_upload_contents( module_org, module_product, satellite=target_sat ) @@ -3935,14 +4088,14 @@ def test_positive_arbitrary_file_repo_promotion(self, module_org, module_product :CaseImportance: High """ - cv = cli_factory.make_content_view({'organization-id': module_org.id}) + cv = target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) repo = self.make_file_repository_upload_contents( module_product, module_product, satellite=target_sat ) ContentView.add_repository( {'id': cv['id'], 'repository-id': repo['id'], 'organization-id': module_org.id} ) - env = cli_factory.make_lifecycle_environment({'organization-id': module_org.id}) + env = target_sat.cli_factory.make_lifecycle_environment({'organization-id': module_org.id}) ContentView.publish({'id': cv['id']}) content_view_info = ContentView.version_info({'content-view-id': cv['id'], 'version': 1}) ContentView.version_promote( @@ -3980,7 +4133,7 @@ def test_positive_katello_repo_rpms_max_int(self, target_sat): assert 'id|bigint' in result.stdout.splitlines()[3].replace(' ', '') @pytest.mark.tier3 - def test_positive_inc_update_should_not_fail(self, module_org): + 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 :BZ: 2041497 @@ -3991,8 +4144,10 @@ def test_positive_inc_update_should_not_fail(self, module_org): :expectedresults: Incremental update is successful """ - custom_yum_product = cli_factory.make_product({'organization-id': module_org.id}) - custom_yum_repo = cli_factory.make_repository( + 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'], @@ -4007,7 +4162,7 @@ def test_positive_inc_update_should_not_fail(self, module_org): Repository.remove_content({'id': repo['id'], 'ids': [package['id']]}) repo = Repository.info({'id': repo['id']}) assert repo['content-counts']['packages'] == '31' - content_view = cli_factory.make_content_view( + content_view = module_target_sat.cli_factory.make_content_view( {'organization-id': module_org.id, 'repository-ids': repo['id']} ) ContentView.add_repository( diff --git a/tests/foreman/cli/test_contentviewfilter.py b/tests/foreman/cli/test_contentviewfilter.py index c19091df054..06ede34f0c1 100644 --- a/tests/foreman/cli/test_contentviewfilter.py +++ b/tests/foreman/cli/test_contentviewfilter.py @@ -21,12 +21,11 @@ from fauxfactory import gen_string import pytest -from robottelo.cli.base import CLIReturnCodeError from robottelo.cli.contentview import ContentView from robottelo.cli.defaults import Defaults -from robottelo.cli.factory import make_content_view, make_repository from robottelo.cli.repository import Repository from robottelo.constants import CONTAINER_REGISTRY_HUB +from robottelo.exceptions import CLIReturnCodeError from robottelo.utils.datafactory import ( invalid_values_list, parametrized, @@ -35,15 +34,17 @@ @pytest.fixture(scope='module') -def sync_repo(module_org, module_product): - repo = make_repository({'organization-id': module_org.id, 'product-id': module_product.id}) +def sync_repo(module_org, module_product, module_target_sat): + repo = module_target_sat.cli_factory.make_repository( + {'organization-id': module_org.id, 'product-id': module_product.id} + ) Repository.synchronize({'id': repo['id']}) return repo @pytest.fixture -def content_view(module_org, sync_repo): - return make_content_view( +def content_view(module_org, sync_repo, module_target_sat): + return module_target_sat.cli_factory.make_content_view( {'organization-id': module_org.id, 'repository-ids': [sync_repo['id']]} ) @@ -394,7 +395,7 @@ def test_positive_create_with_original_pkgs(self, sync_repo, content_view): @pytest.mark.tier2 def test_positive_create_with_repos_yum_and_docker( - self, module_org, module_product, sync_repo, content_view + self, module_org, module_product, sync_repo, content_view, module_target_sat ): """Create new docker repository and add to content view that has yum repo already assigned to it. Create new content view filter and assign @@ -406,7 +407,7 @@ def test_positive_create_with_repos_yum_and_docker( :expectedresults: Content view filter created successfully and has both repositories affected (yum and docker) """ - docker_repository = make_repository( + docker_repository = module_target_sat.cli_factory.make_repository( { 'content-type': 'docker', 'docker-upstream-name': 'busybox', @@ -582,7 +583,7 @@ def test_positive_update_name(self, new_name, module_org, content_view): @pytest.mark.tier2 def test_positive_update_repo_with_same_type( - self, module_org, module_product, sync_repo, content_view + self, module_org, module_product, sync_repo, content_view, module_target_sat ): """Create new content view filter and apply it to existing content view that has repository assigned to it. Try to update that filter and @@ -610,7 +611,7 @@ def test_positive_update_repo_with_same_type( assert len(cvf['repositories']) == 1 assert cvf['repositories'][0]['name'] == sync_repo['name'] - new_repo = make_repository( + new_repo = module_target_sat.cli_factory.make_repository( {'organization-id': module_org.id, 'product-id': module_product.id}, ) ContentView.add_repository({'id': content_view['id'], 'repository-id': new_repo['id']}) @@ -631,7 +632,7 @@ def test_positive_update_repo_with_same_type( @pytest.mark.tier2 @pytest.mark.upgrade def test_positive_update_repo_with_different_type( - self, module_org, module_product, sync_repo, content_view + self, module_org, module_product, sync_repo, content_view, module_target_sat ): """Create new content view filter and apply it to existing content view that has repository assigned to it. Try to update that filter and @@ -657,7 +658,7 @@ def test_positive_update_repo_with_different_type( cvf = ContentView.filter.info({'content-view-id': content_view['id'], 'name': cvf_name}) assert len(cvf['repositories']) == 1 assert cvf['repositories'][0]['name'] == sync_repo['name'] - docker_repo = make_repository( + docker_repo = module_target_sat.cli_factory.make_repository( { 'content-type': 'docker', 'docker-upstream-name': 'busybox', @@ -844,7 +845,7 @@ def test_negative_update_with_non_existent_repo_id(self, sync_repo, content_view @pytest.mark.tier1 def test_negative_update_with_invalid_repo_id( - self, module_org, module_product, sync_repo, content_view + self, module_org, module_product, sync_repo, content_view, module_target_sat ): """Try to update filter and assign repository which does not belong to filter content view @@ -864,7 +865,7 @@ def test_negative_update_with_invalid_repo_id( 'type': 'rpm', }, ) - new_repo = make_repository( + new_repo = module_target_sat.cli_factory.make_repository( {'organization-id': module_org.id, 'product-id': module_product.id}, ) with pytest.raises(CLIReturnCodeError): diff --git a/tests/foreman/cli/test_discoveryrule.py b/tests/foreman/cli/test_discoveryrule.py index efdc081d79f..b3ec46375e7 100644 --- a/tests/foreman/cli/test_discoveryrule.py +++ b/tests/foreman/cli/test_discoveryrule.py @@ -25,8 +25,7 @@ import pytest from requests import HTTPError -from robottelo.cli.base import CLIReturnCodeError -from robottelo.cli.factory import CLIFactoryError, make_discoveryrule +from robottelo.exceptions import CLIFactoryError, CLIReturnCodeError from robottelo.logging import logger from robottelo.utils.datafactory import ( filtered_datapoint, @@ -62,7 +61,7 @@ class TestDiscoveryRule: """Implements Foreman discovery Rules tests in CLI.""" @pytest.fixture(scope='function') - def discoveryrule_factory(self, class_org, class_location, class_hostgroup): + def discoveryrule_factory(self, class_org, class_location, class_hostgroup, class_target_sat): def _create_discoveryrule(org, loc, hostgroup, options=None): """Makes a new discovery rule and asserts its success""" options = options or {} @@ -89,7 +88,7 @@ def _create_discoveryrule(org, loc, hostgroup, options=None): # create a simple object from the dictionary that the CLI factory provides # This allows for consistent attributized access of all fixture entities in the tests - return Box(make_discoveryrule(options)) + return Box(class_target_sat.cli_factory.discoveryrule(options)) return partial( _create_discoveryrule, org=class_org, loc=class_location, hostgroup=class_hostgroup diff --git a/tests/foreman/cli/test_docker.py b/tests/foreman/cli/test_docker.py index 9e7ca7b5ed4..18d2282f9ab 100644 --- a/tests/foreman/cli/test_docker.py +++ b/tests/foreman/cli/test_docker.py @@ -18,16 +18,8 @@ import pytest from robottelo.cli.activationkey import ActivationKey -from robottelo.cli.base import CLIReturnCodeError from robottelo.cli.contentview import ContentView from robottelo.cli.docker import Docker -from robottelo.cli.factory import ( - make_activation_key, - make_content_view, - make_lifecycle_environment, - make_product_wait, - make_repository, -) from robottelo.cli.lifecycleenvironment import LifecycleEnvironment from robottelo.cli.product import Product from robottelo.cli.repository import Repository @@ -38,6 +30,7 @@ CONTAINER_UPSTREAM_NAME, REPO_TYPE, ) +from robottelo.exceptions import CLIReturnCodeError from robottelo.utils.datafactory import ( invalid_docker_upstream_names, parametrized, @@ -46,7 +39,7 @@ ) -def _repo(product_id, name=None, upstream_name=None, url=None): +def _repo(sat, product_id, name=None, upstream_name=None, url=None): """Creates a Docker-based repository. :param product_id: ID of the ``Product``. @@ -58,7 +51,7 @@ def _repo(product_id, name=None, upstream_name=None, url=None): CONTAINER_REGISTRY_HUB constant. :return: A ``Repository`` object. """ - return make_repository( + return sat.cli_factory.make_repository( { 'content-type': REPO_TYPE['docker'], 'docker-upstream-name': upstream_name or CONTAINER_UPSTREAM_NAME, @@ -69,21 +62,23 @@ def _repo(product_id, name=None, upstream_name=None, url=None): ) -def _content_view(repo_id, org_id): +def _content_view(sat, repo_id, org_id): """Create a content view and link it to the given repository.""" - content_view = make_content_view({'composite': False, 'organization-id': org_id}) + content_view = sat.cli_factory.make_content_view( + {'composite': False, 'organization-id': org_id} + ) ContentView.add_repository({'id': content_view['id'], 'repository-id': repo_id}) return ContentView.info({'id': content_view['id']}) @pytest.fixture -def repo(module_product): - return _repo(module_product.id) +def repo(module_product, target_sat): + return _repo(target_sat, module_product.id) @pytest.fixture -def content_view(module_org, repo): - return _content_view(repo['id'], module_org.id) +def content_view(module_org, target_sat, repo): + return _content_view(target_sat, repo['id'], module_org.id) @pytest.fixture @@ -188,7 +183,7 @@ def test_positive_create_repos_using_same_product(self, module_org, module_produ assert repo_names.issubset({repo_['repo-name'] for repo_ in product['content']}) @pytest.mark.tier2 - def test_positive_create_repos_using_multiple_products(self, module_org): + def test_positive_create_repos_using_multiple_products(self, module_org, module_target_sat): """Create multiple Docker-type repositories on multiple products. @@ -201,7 +196,9 @@ def test_positive_create_repos_using_multiple_products(self, module_org): :CaseLevel: Integration """ for _ in range(randint(2, 5)): - product = make_product_wait({'organization-id': module_org.id}) + product = module_target_sat.cli_factory.make_product_wait( + {'organization-id': module_org.id} + ) repo_names = set() for _ in range(randint(2, 3)): repo = _repo(product['id']) @@ -368,7 +365,7 @@ def test_positive_delete_by_id(self, repo): Repository.info({'id': repo['id']}) @pytest.mark.tier2 - def test_positive_delete_random_repo_by_id(self, module_org): + def test_positive_delete_random_repo_by_id(self, module_org, module_target_sat): """Create Docker-type repositories on multiple products and delete a random repository from a random product. @@ -378,7 +375,8 @@ def test_positive_delete_random_repo_by_id(self, module_org): without altering the other products. """ products = [ - make_product_wait({'organization-id': module_org.id}) for _ in range(randint(2, 5)) + module_target_sat.cli_factory.make_product_wait({'organization-id': module_org.id}) + for _ in range(randint(2, 5)) ] repos = [] for product in products: @@ -408,7 +406,7 @@ class TestDockerContentView: """ @pytest.mark.tier2 - def test_positive_add_docker_repo_by_id(self, module_org, repo): + 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 @@ -416,13 +414,15 @@ def test_positive_add_docker_repo_by_id(self, module_org, repo): :expectedresults: A repository is created with a Docker repository and the product is added to a non-composite content view """ - content_view = make_content_view({'composite': False, 'organization-id': module_org.id}) + content_view = module_target_sat.cli_factory.make_content_view( + {'composite': False, 'organization-id': module_org.id} + ) ContentView.add_repository({'id': content_view['id'], 'repository-id': repo['id']}) content_view = 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): + 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. :id: 2eb19e28-a633-4c21-9469-75a686c83b34 @@ -432,7 +432,9 @@ def test_positive_add_docker_repos_by_id(self, module_org, module_product): view. """ repos = [_repo(module_product.id) for _ in range(randint(2, 5))] - content_view = make_content_view({'composite': False, 'organization-id': module_org.id}) + content_view = module_target_sat.cli_factory.make_content_view( + {'composite': False, 'organization-id': module_org.id} + ) for repo in repos: ContentView.add_repository({'id': content_view['id'], 'repository-id': repo['id']}) content_view = ContentView.info({'id': content_view['id']}) @@ -442,7 +444,7 @@ def test_positive_add_docker_repos_by_id(self, module_org, module_product): } @pytest.mark.tier2 - def test_positive_add_synced_docker_repo_by_id(self, module_org, repo): + 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 @@ -454,13 +456,17 @@ def test_positive_add_synced_docker_repo_by_id(self, module_org, repo): repo = Repository.info({'id': repo['id']}) assert int(repo['content-counts']['container-image-manifests']) > 0 - content_view = make_content_view({'composite': False, 'organization-id': module_org.id}) + content_view = module_target_sat.cli_factory.make_content_view( + {'composite': False, 'organization-id': module_org.id} + ) ContentView.add_repository({'id': content_view['id'], 'repository-id': repo['id']}) content_view = 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): + 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 @@ -474,7 +480,9 @@ def test_positive_add_docker_repo_by_id_to_ccv(self, module_org, content_view): ContentView.publish({'id': content_view['id']}) content_view = ContentView.info({'id': content_view['id']}) assert len(content_view['versions']) == 1 - comp_content_view = make_content_view({'composite': True, 'organization-id': module_org.id}) + comp_content_view = module_target_sat.cli_factory.make_content_view( + {'composite': True, 'organization-id': module_org.id} + ) ContentView.update( { 'id': comp_content_view['id'], @@ -487,7 +495,9 @@ def test_positive_add_docker_repo_by_id_to_ccv(self, module_org, content_view): ] @pytest.mark.tier2 - def test_positive_add_docker_repos_by_id_to_ccv(self, module_org, module_product): + 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 @@ -500,14 +510,18 @@ def test_positive_add_docker_repos_by_id_to_ccv(self, module_org, module_product """ cv_versions = [] for _ in range(randint(2, 5)): - content_view = make_content_view({'composite': False, 'organization-id': module_org.id}) + content_view = module_target_sat.cli_factory.make_content_view( + {'composite': False, 'organization-id': module_org.id} + ) repo = _repo(module_product.id) ContentView.add_repository({'id': content_view['id'], 'repository-id': repo['id']}) ContentView.publish({'id': content_view['id']}) content_view = ContentView.info({'id': content_view['id']}) assert len(content_view['versions']) == 1 cv_versions.append(content_view['versions'][0]) - comp_content_view = make_content_view({'composite': True, 'organization-id': module_org.id}) + comp_content_view = module_target_sat.cli_factory.make_content_view( + {'composite': True, 'organization-id': module_org.id} + ) ContentView.update( { 'component-ids': [cv_version['id'] for cv_version in cv_versions], @@ -535,7 +549,9 @@ def test_positive_publish_with_docker_repo(self, content_view): assert len(content_view['versions']) == 1 @pytest.mark.tier2 - def test_positive_publish_with_docker_repo_composite(self, content_view, module_org): + def test_positive_publish_with_docker_repo_composite( + self, content_view, module_org, module_target_sat + ): """Add Docker-type repository to composite CV and publish it once. :id: 2d75419b-73ed-4f29-ae0d-9af8d9624c87 @@ -553,7 +569,9 @@ def test_positive_publish_with_docker_repo_composite(self, content_view, module_ content_view = ContentView.info({'id': content_view['id']}) assert len(content_view['versions']) == 1 - comp_content_view = make_content_view({'composite': True, 'organization-id': module_org.id}) + comp_content_view = module_target_sat.cli_factory.make_content_view( + {'composite': True, 'organization-id': module_org.id} + ) ContentView.update( { 'component-ids': content_view['versions'][0]['id'], @@ -589,7 +607,9 @@ def test_positive_publish_multiple_with_docker_repo(self, content_view): assert len(content_view['versions']) == publish_amount @pytest.mark.tier2 - def test_positive_publish_multiple_with_docker_repo_composite(self, module_org, content_view): + 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. @@ -608,7 +628,9 @@ def test_positive_publish_multiple_with_docker_repo_composite(self, module_org, content_view = ContentView.info({'id': content_view['id']}) assert len(content_view['versions']) == 1 - comp_content_view = make_content_view({'composite': True, 'organization-id': module_org.id}) + comp_content_view = module_target_sat.cli_factory.make_content_view( + {'composite': True, 'organization-id': module_org.id} + ) ContentView.update( { 'component-ids': content_view['versions'][0]['id'], @@ -649,7 +671,9 @@ def test_positive_promote_with_docker_repo(self, module_org, module_lce, content @pytest.mark.tier2 @pytest.mark.upgrade - def test_positive_promote_multiple_with_docker_repo(self, module_org, content_view): + 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. @@ -666,7 +690,9 @@ def test_positive_promote_multiple_with_docker_repo(self, module_org, content_vi assert len(cvv['lifecycle-environments']) == 1 lces = [ - make_lifecycle_environment({'organization-id': module_org.id}) + module_target_sat.cli_factory.make_lifecycle_environment( + {'organization-id': module_org.id} + ) for _ in range(1, randint(3, 6)) ] @@ -677,7 +703,7 @@ def test_positive_promote_multiple_with_docker_repo(self, module_org, content_vi @pytest.mark.tier2 def test_positive_promote_with_docker_repo_composite( - self, module_org, module_lce, content_view + 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. @@ -693,7 +719,9 @@ def test_positive_promote_with_docker_repo_composite( content_view = ContentView.info({'id': content_view['id']}) assert len(content_view['versions']) == 1 - comp_content_view = make_content_view({'composite': True, 'organization-id': module_org.id}) + comp_content_view = module_target_sat.cli_factory.make_content_view( + {'composite': True, 'organization-id': module_org.id} + ) ContentView.update( { 'component-ids': content_view['versions'][0]['id'], @@ -721,7 +749,9 @@ def test_positive_promote_with_docker_repo_composite( @pytest.mark.tier2 @pytest.mark.upgrade - def test_positive_promote_multiple_with_docker_repo_composite(self, content_view, module_org): + def test_positive_promote_multiple_with_docker_repo_composite( + self, content_view, module_org, module_target_sat + ): """Add Docker-type repository to composite content view and publish it. Then promote it to the multiple available lifecycle-environments. @@ -736,7 +766,9 @@ def test_positive_promote_multiple_with_docker_repo_composite(self, content_view content_view = ContentView.info({'id': content_view['id']}) assert len(content_view['versions']) == 1 - comp_content_view = make_content_view({'composite': True, 'organization-id': module_org.id}) + comp_content_view = module_target_sat.cli_factory.make_content_view( + {'composite': True, 'organization-id': module_org.id} + ) ContentView.update( { 'component-ids': content_view['versions'][0]['id'], @@ -754,7 +786,9 @@ def test_positive_promote_multiple_with_docker_repo_composite(self, content_view assert len(cvv['lifecycle-environments']) == 1 lces = [ - make_lifecycle_environment({'organization-id': module_org.id}) + module_target_sat.cli_factory.make_lifecycle_environment( + {'organization-id': module_org.id} + ) for _ in range(1, randint(3, 6)) ] @@ -770,7 +804,7 @@ def test_positive_promote_multiple_with_docker_repo_composite(self, content_view @pytest.mark.tier2 @pytest.mark.upgrade - def test_positive_name_pattern_change(self, module_org): + 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. @@ -780,7 +814,9 @@ def test_positive_name_pattern_change(self, module_org): :expectedresults: Container repository name is changed according to new pattern. """ - lce = make_lifecycle_environment({'organization-id': module_org.id}) + 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 = ( @@ -788,12 +824,16 @@ def test_positive_name_pattern_change(self, module_org): ) repo = _repo( - make_product_wait({'organization-id': module_org.id})['id'], + module_target_sat.cli_factory.make_product_wait({'organization-id': module_org.id})[ + 'id' + ], name=gen_string('alpha', 5), upstream_name=docker_upstream_name, ) Repository.synchronize({'id': repo['id']}) - content_view = make_content_view({'composite': False, 'organization-id': module_org.id}) + content_view = module_target_sat.cli_factory.make_content_view( + {'composite': False, 'organization-id': module_org.id} + ) ContentView.add_repository({'id': content_view['id'], 'repository-id': repo['id']}) ContentView.publish({'id': content_view['id']}) content_view = ContentView.info({'id': content_view['id']}) @@ -818,7 +858,7 @@ def test_positive_name_pattern_change(self, module_org): assert Repository.info({'id': repo['id']})['container-repository-name'] == expected_name @pytest.mark.tier2 - def test_positive_product_name_change_after_promotion(self, module_org): + 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. @@ -833,11 +873,17 @@ def test_positive_product_name_change_after_promotion(self, module_org): docker_upstream_name = 'hello-world' new_pattern = '<%= content_view.label %>/<%= product.name %>' - lce = make_lifecycle_environment({'organization-id': module_org.id}) - prod = make_product_wait({'organization-id': module_org.id, 'name': old_prod_name}) + lce = module_target_sat.cli_factory.make_lifecycle_environment( + {'organization-id': module_org.id} + ) + prod = module_target_sat.cli_factory.make_product_wait( + {'organization-id': module_org.id, 'name': old_prod_name} + ) repo = _repo(prod['id'], name=gen_string('alpha', 5), upstream_name=docker_upstream_name) Repository.synchronize({'id': repo['id']}) - content_view = make_content_view({'composite': False, 'organization-id': module_org.id}) + content_view = module_target_sat.cli_factory.make_content_view( + {'composite': False, 'organization-id': module_org.id} + ) ContentView.add_repository({'id': content_view['id'], 'repository-id': repo['id']}) ContentView.publish({'id': content_view['id']}) content_view = ContentView.info({'id': content_view['id']}) @@ -882,7 +928,7 @@ def test_positive_product_name_change_after_promotion(self, module_org): assert Repository.info({'id': repo['id']})['container-repository-name'] == expected_name @pytest.mark.tier2 - def test_positive_repo_name_change_after_promotion(self, module_org): + 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. @@ -897,11 +943,15 @@ def test_positive_repo_name_change_after_promotion(self, module_org): docker_upstream_name = 'hello-world' new_pattern = '<%= content_view.label %>/<%= repository.name %>' - lce = make_lifecycle_environment({'organization-id': module_org.id}) - prod = make_product_wait({'organization-id': module_org.id}) + lce = module_target_sat.cli_factory.make_lifecycle_environment( + {'organization-id': module_org.id} + ) + prod = module_target_sat.cli_factory.make_product_wait({'organization-id': module_org.id}) repo = _repo(prod['id'], name=old_repo_name, upstream_name=docker_upstream_name) Repository.synchronize({'id': repo['id']}) - content_view = make_content_view({'composite': False, 'organization-id': module_org.id}) + content_view = module_target_sat.cli_factory.make_content_view( + {'composite': False, 'organization-id': module_org.id} + ) ContentView.add_repository({'id': content_view['id'], 'repository-id': repo['id']}) ContentView.publish({'id': content_view['id']}) content_view = ContentView.info({'id': content_view['id']}) @@ -947,7 +997,7 @@ def test_positive_repo_name_change_after_promotion(self, module_org): assert Repository.info({'id': repo['id']})['container-repository-name'] == expected_name @pytest.mark.tier2 - def test_negative_set_non_unique_name_pattern_and_promote(self, module_org): + 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. @@ -959,12 +1009,14 @@ def test_negative_set_non_unique_name_pattern_and_promote(self, module_org): docker_upstream_names = ['hello-world', 'alpine'] new_pattern = '<%= organization.label %>' - lce = make_lifecycle_environment( + lce = module_target_sat.cli_factory.make_lifecycle_environment( {'organization-id': module_org.id, 'registry-name-pattern': new_pattern} ) - prod = make_product_wait({'organization-id': module_org.id}) - content_view = make_content_view({'composite': False, 'organization-id': module_org.id}) + prod = module_target_sat.cli_factory.make_product_wait({'organization-id': module_org.id}) + content_view = module_target_sat.cli_factory.make_content_view( + {'composite': False, 'organization-id': module_org.id} + ) for docker_name in docker_upstream_names: repo = _repo(prod['id'], upstream_name=docker_name) Repository.synchronize({'id': repo['id']}) @@ -978,7 +1030,9 @@ def test_negative_set_non_unique_name_pattern_and_promote(self, module_org): ) @pytest.mark.tier2 - def test_negative_promote_and_set_non_unique_name_pattern(self, module_org, module_product): + def test_negative_promote_and_set_non_unique_name_pattern( + self, module_org, module_product, 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 @@ -991,14 +1045,18 @@ def test_negative_promote_and_set_non_unique_name_pattern(self, module_org, modu docker_upstream_names = ['hello-world', 'alpine'] new_pattern = '<%= organization.label %>' - content_view = make_content_view({'composite': False, 'organization-id': module_org.id}) + content_view = module_target_sat.cli_factory.make_content_view( + {'composite': False, 'organization-id': module_org.id} + ) for docker_name in docker_upstream_names: repo = _repo(module_product.id, upstream_name=docker_name) Repository.synchronize({'id': repo['id']}) ContentView.add_repository({'id': content_view['id'], 'repository-id': repo['id']}) ContentView.publish({'id': content_view['id']}) content_view = ContentView.info({'id': content_view['id']}) - lce = make_lifecycle_environment({'organization-id': module_org.id}) + lce = module_target_sat.cli_factory.make_lifecycle_environment( + {'organization-id': module_org.id} + ) ContentView.version_promote( {'id': content_view['versions'][0]['id'], 'to-lifecycle-environment-id': lce['id']} ) @@ -1024,7 +1082,9 @@ class TestDockerActivationKey: """ @pytest.mark.tier2 - def test_positive_add_docker_repo_cv(self, module_org, module_lce, content_view_promote): + def test_positive_add_docker_repo_cv( + self, module_org, module_lce, content_view_promote, module_target_sat + ): """Add Docker-type repository to a non-composite content view and publish it. Then create an activation key and associate it with the Docker content view. @@ -1034,7 +1094,7 @@ def test_positive_add_docker_repo_cv(self, module_org, module_lce, content_view_ :expectedresults: Docker-based content view can be added to activation key """ - activation_key = make_activation_key( + activation_key = module_target_sat.cli_factory.make_activation_key( { 'content-view-id': content_view_promote['content-view-id'], 'lifecycle-environment-id': module_lce.id, @@ -1044,7 +1104,9 @@ def test_positive_add_docker_repo_cv(self, module_org, module_lce, content_view_ assert activation_key['content-view'] == content_view_promote['content-view-name'] @pytest.mark.tier2 - def test_positive_remove_docker_repo_cv(self, module_org, module_lce, content_view_promote): + def test_positive_remove_docker_repo_cv( + self, module_org, module_lce, content_view_promote, module_target_sat + ): """Add Docker-type repository to a non-composite content view and publish it. Create an activation key and associate it with the Docker content view. Then remove this content view from the activation @@ -1055,7 +1117,7 @@ def test_positive_remove_docker_repo_cv(self, module_org, module_lce, content_vi :expectedresults: Docker-based content view can be added and then removed from the activation key. """ - activation_key = make_activation_key( + activation_key = module_target_sat.cli_factory.make_activation_key( { 'content-view-id': content_view_promote['content-view-id'], 'lifecycle-environment-id': module_lce.id, @@ -1065,7 +1127,9 @@ def test_positive_remove_docker_repo_cv(self, module_org, module_lce, content_vi assert activation_key['content-view'] == content_view_promote['content-view-name'] # Create another content view replace with - another_cv = make_content_view({'composite': False, 'organization-id': module_org.id}) + another_cv = module_target_sat.cli_factory.make_content_view( + {'composite': False, 'organization-id': module_org.id} + ) ContentView.publish({'id': another_cv['id']}) another_cv = ContentView.info({'id': another_cv['id']}) ContentView.version_promote( @@ -1084,7 +1148,9 @@ def test_positive_remove_docker_repo_cv(self, module_org, module_lce, content_vi assert activation_key['content-view'] != content_view_promote['content-view-name'] @pytest.mark.tier2 - def test_positive_add_docker_repo_ccv(self, module_org, module_lce, content_view_publish): + def test_positive_add_docker_repo_ccv( + self, module_org, module_lce, content_view_publish, module_target_sat + ): """Add Docker-type repository to a non-composite content view and publish it. Then add this content view to a composite content view and publish it. Create an activation key and associate it with the @@ -1097,7 +1163,9 @@ def test_positive_add_docker_repo_ccv(self, module_org, module_lce, content_view :BZ: 1359665 """ - comp_content_view = make_content_view({'composite': True, 'organization-id': module_org.id}) + comp_content_view = module_target_sat.cli_factory.make_content_view( + {'composite': True, 'organization-id': module_org.id} + ) ContentView.update( { 'component-ids': content_view_publish['id'], @@ -1115,7 +1183,7 @@ def test_positive_add_docker_repo_ccv(self, module_org, module_lce, content_view ContentView.version_promote( {'id': comp_cvv['id'], 'to-lifecycle-environment-id': module_lce.id} ) - activation_key = make_activation_key( + activation_key = module_target_sat.cli_factory.make_activation_key( { 'content-view-id': comp_content_view['id'], 'lifecycle-environment-id': module_lce.id, @@ -1125,7 +1193,9 @@ def test_positive_add_docker_repo_ccv(self, module_org, module_lce, content_view assert activation_key['content-view'] == comp_content_view['name'] @pytest.mark.tier2 - def test_positive_remove_docker_repo_ccv(self, module_org, module_lce, content_view_publish): + def test_positive_remove_docker_repo_ccv( + self, module_org, module_lce, content_view_publish, module_target_sat + ): """Add Docker-type repository to a non-composite content view and publish it. Then add this content view to a composite content view and publish it. Create an activation key and associate it with the @@ -1139,7 +1209,9 @@ def test_positive_remove_docker_repo_ccv(self, module_org, module_lce, content_v :BZ: 1359665 """ - comp_content_view = make_content_view({'composite': True, 'organization-id': module_org.id}) + comp_content_view = module_target_sat.cli_factory.make_content_view( + {'composite': True, 'organization-id': module_org.id} + ) ContentView.update( { 'component-ids': content_view_publish['id'], @@ -1157,7 +1229,7 @@ def test_positive_remove_docker_repo_ccv(self, module_org, module_lce, content_v ContentView.version_promote( {'id': comp_cvv['id'], 'to-lifecycle-environment-id': module_lce.id} ) - activation_key = make_activation_key( + activation_key = module_target_sat.cli_factory.make_activation_key( { 'content-view-id': comp_content_view['id'], 'lifecycle-environment-id': module_lce.id, @@ -1167,7 +1239,9 @@ def test_positive_remove_docker_repo_ccv(self, module_org, module_lce, content_v assert activation_key['content-view'] == comp_content_view['name'] # Create another content view replace with - another_cv = make_content_view({'composite': False, 'organization-id': module_org.id}) + another_cv = module_target_sat.cli_factory.make_content_view( + {'composite': False, 'organization-id': module_org.id} + ) ContentView.publish({'id': another_cv['id']}) another_cv = ContentView.info({'id': another_cv['id']}) ContentView.version_promote( diff --git a/tests/foreman/cli/test_domain.py b/tests/foreman/cli/test_domain.py index b0d6aeca207..7122592391e 100644 --- a/tests/foreman/cli/test_domain.py +++ b/tests/foreman/cli/test_domain.py @@ -19,9 +19,8 @@ from fauxfactory import gen_string import pytest -from robottelo.cli.base import CLIReturnCodeError from robottelo.cli.domain import Domain -from robottelo.cli.factory import CLIFactoryError, make_domain, make_location, make_org +from robottelo.exceptions import CLIFactoryError, CLIReturnCodeError from robottelo.utils.datafactory import ( filtered_datapoint, invalid_id_list, @@ -113,7 +112,7 @@ def valid_delete_params(): @pytest.mark.tier1 @pytest.mark.upgrade -def test_positive_create_update_delete_domain(): +def test_positive_create_update_delete_domain(module_target_sat): """Create domain, update and delete domain and set parameters :id: 018740bf-1551-4162-b88e-4d4905af097b @@ -123,9 +122,9 @@ def test_positive_create_update_delete_domain(): :CaseImportance: Critical """ options = valid_create_params()[0] - location = make_location() - org = make_org() - domain = make_domain( + location = module_target_sat.cli_factory.make_location() + org = module_target_sat.cli_factory.make_org() + domain = module_target_sat.cli_factory.make_domain( { 'name': options['name'], 'description': options['description'], @@ -171,7 +170,7 @@ def test_positive_create_update_delete_domain(): @pytest.mark.tier2 @pytest.mark.parametrize('options', **parametrized(invalid_create_params())) -def test_negative_create(options): +def test_negative_create(options, module_target_sat): """Create domain with invalid values :id: 6d3aec19-75dc-41ca-89af-fef0ca37082d @@ -183,11 +182,11 @@ def test_negative_create(options): :CaseImportance: Medium """ with pytest.raises(CLIFactoryError): - make_domain(options) + module_target_sat.cli_factory.make_domain(options) @pytest.mark.tier2 -def test_negative_create_with_invalid_dns_id(): +def test_negative_create_with_invalid_dns_id(module_target_sat): """Attempt to register a domain with invalid id :id: 4aa52167-368a-41ad-87b7-41d468ad41a8 @@ -201,7 +200,7 @@ def test_negative_create_with_invalid_dns_id(): :CaseImportance: Medium """ with pytest.raises(CLIFactoryError) as context: - make_domain({'name': gen_string('alpha'), 'dns-id': -1}) + module_target_sat.cli_factory.make_domain({'name': gen_string('alpha'), 'dns-id': -1}) valid_messages = ['Invalid smart-proxy id', 'Invalid capsule id'] exception_string = str(context.value) messages = [message for message in valid_messages if message in exception_string] diff --git a/tests/foreman/cli/test_environment.py b/tests/foreman/cli/test_environment.py index ae6e0d7e947..10481c743c6 100644 --- a/tests/foreman/cli/test_environment.py +++ b/tests/foreman/cli/test_environment.py @@ -21,8 +21,8 @@ from fauxfactory import gen_alphanumeric, gen_string import pytest -from robottelo.cli.base import CLIReturnCodeError from robottelo.config import settings +from robottelo.exceptions import CLIReturnCodeError from robottelo.utils.datafactory import ( invalid_id_list, invalid_values_list, diff --git a/tests/foreman/cli/test_errata.py b/tests/foreman/cli/test_errata.py index 13e0502ac31..5ac50b85c16 100644 --- a/tests/foreman/cli/test_errata.py +++ b/tests/foreman/cli/test_errata.py @@ -24,17 +24,8 @@ import pytest from robottelo.cli.activationkey import ActivationKey -from robottelo.cli.base import CLIReturnCodeError from robottelo.cli.contentview import ContentView, ContentViewFilter from robottelo.cli.erratum import Erratum -from robottelo.cli.factory import ( - make_content_view_filter, - make_content_view_filter_rule, - make_host_collection, - make_repository, - setup_org_for_a_custom_repo, - setup_org_for_a_rh_repo, -) from robottelo.cli.host import Host from robottelo.cli.hostcollection import HostCollection from robottelo.cli.job_invocation import JobInvocation @@ -59,6 +50,7 @@ REPOS, REPOSET, ) +from robottelo.exceptions import CLIReturnCodeError from robottelo.hosts import ContentHost PER_PAGE = 10 @@ -128,7 +120,7 @@ def orgs(): @pytest.fixture(scope='module') -def products_with_repos(orgs): +def products_with_repos(orgs, module_target_sat): """Create and return a list of products. For each product, create and sync a single repo.""" products = [] # Create one product for each org, and a second product for the last org. @@ -138,7 +130,7 @@ def products_with_repos(orgs): # with the one we already have. product.organization = org products.append(product) - repo = make_repository( + repo = module_target_sat.cli_factory.make_repository( { 'download-policy': 'immediate', 'organization-id': product.organization.id, @@ -152,9 +144,11 @@ def products_with_repos(orgs): @pytest.fixture(scope='module') -def rh_repo(module_entitlement_manifest_org, module_lce, module_cv, module_ak_cv_lce): +def rh_repo( + module_entitlement_manifest_org, module_lce, module_cv, module_ak_cv_lce, module_target_sat +): """Add a subscription for the Satellite Tools repo to activation key.""" - setup_org_for_a_rh_repo( + module_target_sat.cli_factory.setup_org_for_a_rh_repo( { 'product': PRDS['rhel'], 'repository-set': REPOSET['rhst7'], @@ -168,9 +162,11 @@ def rh_repo(module_entitlement_manifest_org, module_lce, module_cv, module_ak_cv @pytest.fixture(scope='module') -def custom_repo(module_entitlement_manifest_org, module_lce, module_cv, module_ak_cv_lce): +def custom_repo( + module_entitlement_manifest_org, module_lce, module_cv, module_ak_cv_lce, module_target_sat +): """Create custom repo and add a subscription to activation key.""" - setup_org_for_a_custom_repo( + module_target_sat.cli_factory.setup_org_for_a_custom_repo( { 'url': REPO_WITH_ERRATA['url'], 'organization-id': module_entitlement_manifest_org.id, @@ -229,9 +225,13 @@ def errata_hosts(register_hosts): @pytest.fixture(scope='module') -def host_collection(module_entitlement_manifest_org, module_ak_cv_lce, register_hosts): +def host_collection( + module_entitlement_manifest_org, module_ak_cv_lce, register_hosts, module_target_sat +): """Create and setup host collection.""" - host_collection = make_host_collection({'organization-id': module_entitlement_manifest_org.id}) + host_collection = module_target_sat.cli_factory.make_host_collection( + {'organization-id': module_entitlement_manifest_org.id} + ) host_ids = [Host.info({'name': host.hostname})['id'] for host in register_hosts] HostCollection.add_host( { @@ -500,7 +500,9 @@ def test_negative_install_by_hc_name_without_errata_info( @pytest.mark.tier3 -def test_negative_install_without_hc_info(module_entitlement_manifest_org, host_collection): +def test_negative_install_without_hc_info( + module_entitlement_manifest_org, host_collection, module_target_sat +): """Attempt to install an erratum on a host collection without specifying host collection info. This test only works with two or more host collections (BZ#1928281). We have the one from the fixture, just need to create one more at the start of the test. @@ -520,7 +522,9 @@ def test_negative_install_without_hc_info(module_entitlement_manifest_org, host_ :CaseLevel: System """ - make_host_collection({'organization-id': module_entitlement_manifest_org.id}) + module_target_sat.cli_factory.make_host_collection( + {'organization-id': module_entitlement_manifest_org.id} + ) with pytest.raises(CLIReturnCodeError): HostCollection.erratum_install( { @@ -667,7 +671,7 @@ def test_install_errata_to_one_host( @pytest.mark.tier3 @pytest.mark.e2e def test_positive_list_affected_chosts_by_erratum_restrict_flag( - request, module_entitlement_manifest_org, module_cv, module_lce, errata_hosts + request, module_entitlement_manifest_org, module_cv, module_lce, errata_hosts, module_target_sat ): """View a list of affected content hosts for an erratum filtered with restrict flags. Applicability is calculated using the Library, @@ -756,7 +760,7 @@ def test_positive_list_affected_chosts_by_erratum_restrict_flag( # Apply a filter and rule to the CV to hide the RPM, thus making erratum not installable # Make RPM exclude filter - cv_filter = make_content_view_filter( + cv_filter = module_target_sat.cli_factory.make_content_view_filter( { 'content-view-id': module_cv.id, 'name': 'erratum_restrict_test', @@ -777,7 +781,7 @@ def cleanup(): ) # Make rule to hide the RPM that creates the need for the installable erratum - make_content_view_filter_rule( + module_target_sat.cli_factory.content_view_filter_rule( { 'content-view-id': module_cv.id, 'content-view-filter-id': cv_filter['filter-id'], @@ -942,7 +946,7 @@ def test_host_errata_search_commands( # Step 7: Apply filter and rule to CV to hide RPM, thus making erratum not installable # Make RPM exclude filter - cv_filter = make_content_view_filter( + cv_filter = target_sat.cli_factory.make_content_view_filter( { 'content-view-id': module_cv.id, 'name': 'erratum_search_test', @@ -963,7 +967,7 @@ def cleanup(): ) # Make rule to exclude the specified bugfix package - make_content_view_filter_rule( + target_sat.cli_factory.content_view_filter_rule( { 'content-view-id': module_cv.id, 'content-view-filter-id': cv_filter['filter-id'], @@ -1199,7 +1203,7 @@ def test_positive_list_filter_by_cve(module_entitlement_manifest_org, rh_repo): @pytest.mark.tier3 -def test_positive_check_errata_dates(module_entitlement_manifest_org): +def test_positive_check_errata_dates(module_entitlement_manifest_org, module_target_sat): """Check for errata dates in `hammer erratum list` :id: b19286ae-bdb4-4319-87d0-5d3ff06c5f38 @@ -1213,7 +1217,7 @@ def test_positive_check_errata_dates(module_entitlement_manifest_org): :BZ: 1695163 """ product = entities.Product(organization=module_entitlement_manifest_org).create() - repo = make_repository( + repo = module_target_sat.cli_factory.make_repository( {'content-type': 'yum', 'product-id': product.id, 'url': REPO_WITH_ERRATA['url']} ) # Synchronize custom repository @@ -1614,7 +1618,7 @@ def test_downgrading_package_shows_errata_from_library( @pytest.mark.skip_if_open('BZ:1785146') @pytest.mark.tier2 -def test_errata_list_by_contentview_filter(module_entitlement_manifest_org): +def test_errata_list_by_contentview_filter(module_entitlement_manifest_org, module_target_sat): """Hammer command to list errata should take filter ID into consideration. :id: e9355a92-8354-4853-a806-d388ed32d73e @@ -1635,7 +1639,7 @@ def test_errata_list_by_contentview_filter(module_entitlement_manifest_org): :BZ: 1785146 """ product = entities.Product(organization=module_entitlement_manifest_org).create() - repo = make_repository( + repo = module_target_sat.cli_factory.make_repository( {'content-type': 'yum', 'product-id': product.id, 'url': REPO_WITH_ERRATA['url']} ) Repository.synchronize({'id': repo['id']}) diff --git a/tests/foreman/cli/test_filter.py b/tests/foreman/cli/test_filter.py index da5eccb86c2..be3a40e9662 100644 --- a/tests/foreman/cli/test_filter.py +++ b/tests/foreman/cli/test_filter.py @@ -18,10 +18,9 @@ """ import pytest -from robottelo.cli.base import CLIReturnCodeError -from robottelo.cli.factory import make_filter, make_location, make_org, make_role from robottelo.cli.filter import Filter from robottelo.cli.role import Role +from robottelo.exceptions import CLIReturnCodeError @pytest.fixture(scope='module') @@ -35,13 +34,13 @@ def module_perms(): @pytest.fixture(scope='function') -def function_role(): +def function_role(target_sat): """Create a role that a filter would be assigned""" - return make_role() + return target_sat.cli_factory.make_role() @pytest.mark.tier1 -def test_positive_create_with_permission(module_perms, function_role): +def test_positive_create_with_permission(module_perms, function_role, target_sat): """Create a filter and assign it some permissions. :id: 6da6c5d3-2727-4eb7-aa15-9f7b6f91d3b2 @@ -51,12 +50,14 @@ def test_positive_create_with_permission(module_perms, function_role): :CaseImportance: Critical """ # Assign filter to created role - filter_ = make_filter({'role-id': function_role['id'], 'permissions': module_perms}) + filter_ = target_sat.cli_factory.make_filter( + {'role-id': function_role['id'], 'permissions': module_perms} + ) assert set(filter_['permissions'].split(", ")) == set(module_perms) @pytest.mark.tier1 -def test_positive_create_with_org(module_perms, function_role): +def test_positive_create_with_org(module_perms, function_role, target_sat): """Create a filter and assign it some permissions. :id: f6308192-0e1f-427b-a296-b285f6684691 @@ -67,9 +68,9 @@ def test_positive_create_with_org(module_perms, function_role): :CaseImportance: Critical """ - org = make_org() + org = target_sat.cli_factory.make_org() # Assign filter to created role - filter_ = make_filter( + filter_ = target_sat.cli_factory.make_filter( { 'role-id': function_role['id'], 'permissions': module_perms, @@ -82,7 +83,7 @@ def test_positive_create_with_org(module_perms, function_role): @pytest.mark.tier1 -def test_positive_create_with_loc(module_perms, function_role): +def test_positive_create_with_loc(module_perms, function_role, module_target_sat): """Create a filter and assign it some permissions. :id: d7d1969a-cb30-4e97-a9a3-3a4aaf608795 @@ -93,9 +94,9 @@ def test_positive_create_with_loc(module_perms, function_role): :CaseImportance: Critical """ - loc = make_location() + loc = module_target_sat.cli_factory.make_location() # Assign filter to created role - filter_ = make_filter( + filter_ = module_target_sat.cli_factory.make_filter( { 'role-id': function_role['id'], 'permissions': module_perms, @@ -108,7 +109,7 @@ def test_positive_create_with_loc(module_perms, function_role): @pytest.mark.tier1 -def test_positive_delete(module_perms, function_role): +def test_positive_delete(module_perms, function_role, module_target_sat): """Create a filter and delete it afterwards. :id: 97d1093c-0d49-454b-86f6-f5be87b32775 @@ -117,7 +118,9 @@ def test_positive_delete(module_perms, function_role): :CaseImportance: Critical """ - filter_ = make_filter({'role-id': function_role['id'], 'permissions': module_perms}) + filter_ = module_target_sat.cli_factory.make_filter( + {'role-id': function_role['id'], 'permissions': module_perms} + ) Filter.delete({'id': filter_['id']}) with pytest.raises(CLIReturnCodeError): Filter.info({'id': filter_['id']}) @@ -125,7 +128,7 @@ def test_positive_delete(module_perms, function_role): @pytest.mark.tier1 @pytest.mark.upgrade -def test_positive_delete_role(module_perms, function_role): +def test_positive_delete_role(module_perms, function_role, target_sat): """Create a filter and delete the role it points at. :id: e2adb6a4-e408-4912-a32d-2bf2c43187d9 @@ -134,7 +137,9 @@ def test_positive_delete_role(module_perms, function_role): :CaseImportance: Critical """ - filter_ = make_filter({'role-id': function_role['id'], 'permissions': module_perms}) + filter_ = target_sat.cli_factory.make_filter( + {'role-id': function_role['id'], 'permissions': module_perms} + ) # A filter depends on a role. Deleting a role implicitly deletes the # filter pointing at it. @@ -146,7 +151,7 @@ def test_positive_delete_role(module_perms, function_role): @pytest.mark.tier1 -def test_positive_update_permissions(module_perms, function_role): +def test_positive_update_permissions(module_perms, function_role, target_sat): """Create a filter and update its permissions. :id: 3d6a52d8-2f8f-4f97-a155-9b52888af16e @@ -155,7 +160,9 @@ def test_positive_update_permissions(module_perms, function_role): :CaseImportance: Critical """ - filter_ = make_filter({'role-id': function_role['id'], 'permissions': module_perms}) + filter_ = target_sat.cli_factory.make_filter( + {'role-id': function_role['id'], 'permissions': module_perms} + ) new_perms = [ permission['name'] for permission in Filter.available_permissions({"search": "resource_type=User"}) @@ -166,7 +173,7 @@ def test_positive_update_permissions(module_perms, function_role): @pytest.mark.tier1 -def test_positive_update_role(module_perms, function_role): +def test_positive_update_role(module_perms, function_role, target_sat): """Create a filter and assign it to another role. :id: 2950b3a1-2bce-447f-9df2-869b1d10eaf5 @@ -175,16 +182,18 @@ def test_positive_update_role(module_perms, function_role): :CaseImportance: Critical """ - filter_ = make_filter({'role-id': function_role['id'], 'permissions': module_perms}) + filter_ = target_sat.cli_factory.make_filter( + {'role-id': function_role['id'], 'permissions': module_perms} + ) # Update with another role - new_role = make_role() + new_role = target_sat.cli_factory.make_role() Filter.update({'id': filter_['id'], 'role-id': new_role['id']}) filter_ = Filter.info({'id': filter_['id']}) assert filter_['role'] == new_role['name'] @pytest.mark.tier1 -def test_positive_update_org_loc(module_perms, function_role): +def test_positive_update_org_loc(module_perms, function_role, target_sat): """Create a filter and assign it to another organization and location. :id: 9bb59109-9701-4ef3-95c6-81f387d372da @@ -195,9 +204,9 @@ def test_positive_update_org_loc(module_perms, function_role): :CaseImportance: Critical """ - org = make_org() - loc = make_location() - filter_ = make_filter( + org = target_sat.cli_factory.make_org() + loc = target_sat.cli_factory.make_location() + filter_ = target_sat.cli_factory.make_filter( { 'role-id': function_role['id'], 'permissions': module_perms, @@ -207,8 +216,8 @@ def test_positive_update_org_loc(module_perms, function_role): } ) # Update org and loc - new_org = make_org() - new_loc = make_location() + new_org = target_sat.cli_factory.make_org() + new_loc = target_sat.cli_factory.make_location() Filter.update( { 'id': filter_['id'], diff --git a/tests/foreman/cli/test_host.py b/tests/foreman/cli/test_host.py index 538c8ebe27a..1a3ba2d9de1 100644 --- a/tests/foreman/cli/test_host.py +++ b/tests/foreman/cli/test_host.py @@ -25,14 +25,6 @@ import yaml from robottelo.cli.activationkey import ActivationKey -from robottelo.cli.base import CLIReturnCodeError -from robottelo.cli.factory import ( - CLIFactoryError, - add_role_permissions, - make_fake_host, - make_host, - setup_org_for_a_rh_repo, -) from robottelo.cli.host import Host, HostInterface, HostTraces from robottelo.cli.job_invocation import JobInvocation from robottelo.cli.package import Package @@ -51,6 +43,7 @@ REPOSET, SM_OVERALL_STATUS, ) +from robottelo.exceptions import CLIFactoryError, CLIReturnCodeError from robottelo.hosts import ContentHostError from robottelo.logging import logger from robottelo.utils.datafactory import ( @@ -72,7 +65,7 @@ def function_host(target_sat): host_template = target_sat.api.Host() host_template.create_missing() # using CLI to create host - host = make_host( + host = target_sat.cli_factory.make_host( { 'architecture-id': host_template.architecture.id, 'domain-id': host_template.domain.id, @@ -261,7 +254,7 @@ def parse_cli_entity_list_help_message(help_message): return parsed_dict -def test_positive_search_all_field_sets(): +def test_positive_search_all_field_sets(module_target_sat): """All fields in predefined field sets from hammer host list --help message are shown when specified as --fields in hammer host list command Note: host was created, so we there will always be at least 1 host @@ -283,7 +276,7 @@ def test_positive_search_all_field_sets(): :customerscenario: true """ - new_host = make_fake_host() + new_host = module_target_sat.cli_factory.make_fake_host() host_help_yaml = Host.list(options={'help': ''}, output_format='yaml') host_help = yaml.load(host_help_yaml, yaml.SafeLoader) parsed_dict = parse_cli_entity_list_help_message(host_help[':message']) @@ -324,7 +317,7 @@ def test_positive_create_and_delete(target_sat, module_lce_library, module_publi 'type=interface,mac={},identifier=eth0,name={},domain_id={},' 'ip={},primary=true,provision=true' ).format(host.mac, gen_string('alpha'), host.domain.id, gen_ipaddr()) - new_host = make_host( + new_host = target_sat.cli_factory.make_host( { 'architecture-id': host.architecture.id, 'content-view-id': module_published_cv.id, @@ -373,7 +366,7 @@ def test_positive_crud_interface_by_id(target_sat, default_location, default_org domain = target_sat.api.Domain(location=[default_location], organization=[default_org]).create() mac = gen_mac(multicast=False) - host = make_fake_host({'domain-id': domain.id}) + host = target_sat.cli_factory.make_fake_host({'domain-id': domain.id}) number_of_interfaces = len(HostInterface.list({'host-id': host['id']})) HostInterface.create( @@ -419,7 +412,9 @@ def test_positive_crud_interface_by_id(target_sat, default_location, default_org @pytest.mark.cli_host_create @pytest.mark.tier2 -def test_negative_create_with_content_source(module_lce_library, module_org, module_published_cv): +def test_negative_create_with_content_source( + module_lce_library, module_org, module_published_cv, module_target_sat +): """Attempt to create a host with invalid content source specified :id: d92d6aff-4ad3-467c-88a8-5a5e56614f58 @@ -431,7 +426,7 @@ def test_negative_create_with_content_source(module_lce_library, module_org, mod :CaseImportance: Medium """ with pytest.raises(CLIFactoryError): - make_fake_host( + module_target_sat.cli_factory.make_fake_host( { 'content-source-id': gen_integer(10000, 99999), 'content-view-id': module_published_cv.id, @@ -444,7 +439,7 @@ def test_negative_create_with_content_source(module_lce_library, module_org, mod @pytest.mark.cli_host_create @pytest.mark.tier2 def test_negative_update_content_source( - module_default_proxy, module_lce_library, module_org, module_published_cv + module_default_proxy, module_lce_library, module_org, module_published_cv, module_target_sat ): """Attempt to update host's content source with invalid value @@ -459,7 +454,7 @@ def test_negative_update_content_source( :CaseImportance: Medium """ - host = make_fake_host( + host = module_target_sat.cli_factory.make_fake_host( { 'content-source-id': module_default_proxy['id'], 'content-view-id': module_published_cv.id, @@ -475,7 +470,9 @@ def test_negative_update_content_source( @pytest.mark.cli_host_create @pytest.mark.tier1 -def test_positive_create_with_lce_and_cv(module_lce, module_org, module_promoted_cv): +def test_positive_create_with_lce_and_cv( + module_lce, module_org, module_promoted_cv, module_target_sat +): """Check if host can be created with new lifecycle and new content view @@ -488,7 +485,7 @@ def test_positive_create_with_lce_and_cv(module_lce, module_org, module_promoted :CaseImportance: Critical """ - new_host = make_fake_host( + new_host = module_target_sat.cli_factory.make_fake_host( { 'content-view-id': module_promoted_cv.id, 'lifecycle-environment-id': module_lce.id, @@ -501,7 +498,9 @@ def test_positive_create_with_lce_and_cv(module_lce, module_org, module_promoted @pytest.mark.cli_host_create @pytest.mark.tier2 -def test_positive_create_with_openscap_proxy_id(module_default_proxy, module_org): +def test_positive_create_with_openscap_proxy_id( + module_default_proxy, module_org, module_target_sat +): """Check if host can be created with OpenSCAP Proxy id :id: 3774ba08-3b18-4e64-b07f-53f6aa0504f3 @@ -510,7 +509,7 @@ def test_positive_create_with_openscap_proxy_id(module_default_proxy, module_org :CaseImportance: Medium """ - host = make_fake_host( + host = module_target_sat.cli_factory.make_fake_host( {'organization-id': module_org.id, 'openscap-proxy-id': module_default_proxy['id']} ) assert host['openscap-proxy'] == module_default_proxy['id'] @@ -518,7 +517,9 @@ def test_positive_create_with_openscap_proxy_id(module_default_proxy, module_org @pytest.mark.cli_host_create @pytest.mark.tier1 -def test_negative_create_with_name(module_lce_library, module_org, module_published_cv): +def test_negative_create_with_name( + module_lce_library, module_org, module_published_cv, module_target_sat +): """Check if host can be created with random long names :id: f92b6070-b2d1-4e3e-975c-39f1b1096697 @@ -529,7 +530,7 @@ def test_negative_create_with_name(module_lce_library, module_org, module_publis """ name = gen_choice(invalid_values_list()) with pytest.raises(CLIFactoryError): - make_fake_host( + module_target_sat.cli_factory.make_fake_host( { 'name': name, 'organization-id': module_org.id, @@ -541,7 +542,7 @@ def test_negative_create_with_name(module_lce_library, module_org, module_publis @pytest.mark.cli_host_create @pytest.mark.tier1 -def test_negative_create_with_unpublished_cv(module_lce, module_org, module_cv): +def test_negative_create_with_unpublished_cv(module_lce, module_org, module_cv, module_target_sat): """Check if host can be created using unpublished cv :id: 9997383d-3c27-4f14-94f9-4b8b51180eb6 @@ -551,7 +552,7 @@ def test_negative_create_with_unpublished_cv(module_lce, module_org, module_cv): :CaseImportance: Critical """ with pytest.raises(CLIFactoryError): - make_fake_host( + module_target_sat.cli_factory.make_fake_host( { 'content-view-id': module_cv.id, 'lifecycle-environment-id': module_lce.id, @@ -703,7 +704,9 @@ def test_positive_create_inherit_lce_cv( lifecycle_environment=module_lce_library, organization=[module_org], ).create() - host = make_fake_host({'hostgroup-id': hostgroup.id, 'organization-id': module_org.id}) + host = target_sat.cli_factory.make_fake_host( + {'hostgroup-id': hostgroup.id, 'organization-id': module_org.id} + ) assert ( int(host['content-information']['lifecycle-environment']['id']) == hostgroup.lifecycle_environment.id @@ -758,7 +761,7 @@ def test_positive_create_inherit_nested_hostgroup(target_sat): ).create() nested_hostgroups.append(nested_hg) - host = make_host( + host = target_sat.cli_factory.make_host( { 'hostgroup-title': f'{parent_hostgroups[0].name}/{nested_hostgroups[0].name}', 'location-id': options.location.id, @@ -812,7 +815,7 @@ def test_positive_list_with_nested_hostgroup(target_sat): organization=[options.organization], parent=parent_hg, ).create() - make_host( + target_sat.cli_factory.make_host( { 'hostgroup-id': nested_hg.id, 'location-id': options.location.id, @@ -1142,7 +1145,7 @@ def test_negative_view_parameter_by_non_admin_user(target_sat, function_host, fu host = Host.info({'id': function_host['id']}) assert host['parameters'][param_name] == param_value role = target_sat.api.Role(name=gen_string('alphanumeric')).create() - add_role_permissions( + target_sat.cli_factory.add_role_permissions( role.id, resource_permissions={ 'Host': {'permissions': ['view_hosts']}, @@ -1185,7 +1188,7 @@ def test_positive_view_parameter_by_non_admin_user(target_sat, function_host, fu host = Host.info({'id': function_host['id']}) assert host['parameters'][param_name] == param_value role = target_sat.api.Role(name=gen_string('alphanumeric')).create() - add_role_permissions( + target_sat.cli_factory.add_role_permissions( role.id, resource_permissions={ 'Host': {'permissions': ['view_hosts']}, @@ -1230,7 +1233,7 @@ def test_negative_edit_parameter_by_non_admin_user(target_sat, function_host, fu host = Host.info({'id': function_host['id']}) assert host['parameters'][param_name] == param_value role = target_sat.api.Role(name=gen_string('alphanumeric')).create() - add_role_permissions( + target_sat.cli_factory.add_role_permissions( role.id, resource_permissions={ 'Host': {'permissions': ['view_hosts']}, @@ -2063,7 +2066,7 @@ def test_negative_without_attach_with_lce( environment=function_lce, organization=function_org, ).create() - setup_org_for_a_rh_repo( + target_sat.cli_factory.setup_org_for_a_rh_repo( { 'product': PRDS['rhel'], 'repository-set': REPOSET['rhst7'], diff --git a/tests/foreman/cli/test_hostcollection.py b/tests/foreman/cli/test_hostcollection.py index fa41aa9067e..31505316618 100644 --- a/tests/foreman/cli/test_hostcollection.py +++ b/tests/foreman/cli/test_hostcollection.py @@ -21,18 +21,12 @@ import pytest from robottelo.cli.activationkey import ActivationKey -from robottelo.cli.base import CLIReturnCodeError from robottelo.cli.contentview import ContentView -from robottelo.cli.factory import ( - CLIFactoryError, - make_fake_host, - make_host_collection, - make_org, -) from robottelo.cli.host import Host from robottelo.cli.hostcollection import HostCollection from robottelo.cli.lifecycleenvironment import LifecycleEnvironment from robottelo.constants import DEFAULT_CV, ENVIRONMENT +from robottelo.exceptions import CLIFactoryError, CLIReturnCodeError from robottelo.hosts import ContentHost from robottelo.utils.datafactory import ( invalid_values_list, @@ -41,11 +35,11 @@ ) -def _make_fake_host_helper(module_org): +def _make_fake_host_helper(module_org, module_target_sat): """Make a new fake host""" library = LifecycleEnvironment.info({'organization-id': module_org.id, 'name': ENVIRONMENT}) default_cv = ContentView.info({'organization-id': module_org.id, 'name': DEFAULT_CV}) - return make_fake_host( + return module_target_sat.cli_factory.make_fake_host( { 'content-view-id': default_cv['id'], 'lifecycle-environment-id': library['id'], @@ -58,7 +52,7 @@ def _make_fake_host_helper(module_org): @pytest.mark.upgrade @pytest.mark.tier2 @pytest.mark.e2e -def test_positive_end_to_end(module_org): +def test_positive_end_to_end(module_org, module_target_sat): """Check if host collection can be created with name and description, content host can be added and removed, host collection can be listed, updated and deleted @@ -73,14 +67,14 @@ def test_positive_end_to_end(module_org): """ name = list(valid_data_list().values())[0] desc = list(valid_data_list().values())[0] - new_host_col = make_host_collection( + new_host_col = module_target_sat.cli_factory.make_host_collection( {'description': desc, 'name': name, 'organization-id': module_org.id} ) assert new_host_col['name'] == name assert new_host_col['description'] == desc # add host - new_system = _make_fake_host_helper(module_org) + new_system = _make_fake_host_helper(module_org, module_target_sat) no_of_content_host = new_host_col['total-hosts'] HostCollection.add_host({'host-ids': new_system['id'], 'id': new_host_col['id']}) result = HostCollection.info({'id': new_host_col['id']}) @@ -122,7 +116,7 @@ def test_positive_end_to_end(module_org): @pytest.mark.tier1 -def test_positive_create_with_limit(module_org): +def test_positive_create_with_limit(module_org, module_target_sat): """Check if host collection can be created with correct limits :id: 682b5624-1095-48e6-a0dd-c76e70ca6540 @@ -132,12 +126,14 @@ def test_positive_create_with_limit(module_org): :CaseImportance: Critical """ for limit in ('1', '3', '5', '10', '20'): - new_host_col = make_host_collection({'max-hosts': limit, 'organization-id': module_org.id}) + new_host_col = module_target_sat.cli_factory.make_host_collection( + {'max-hosts': limit, 'organization-id': module_org.id} + ) assert new_host_col['limit'] == limit @pytest.mark.tier1 -def test_positive_update_to_unlimited_hosts(module_org): +def test_positive_update_to_unlimited_hosts(module_org, module_target_sat): """Create Host Collection with a limit and update it to unlimited hosts :id: d688fd4a-88eb-484e-9e90-854e0595edd0 @@ -146,7 +142,7 @@ def test_positive_update_to_unlimited_hosts(module_org): :CaseImportance: High """ - host_collection = make_host_collection( + host_collection = module_target_sat.cli_factory.make_host_collection( { 'max-hosts': 1, 'organization-id': module_org.id, @@ -171,7 +167,7 @@ def test_positive_update_to_unlimited_hosts(module_org): @pytest.mark.parametrize('name', **parametrized(invalid_values_list())) @pytest.mark.tier1 -def test_negative_create_with_name(module_org, name): +def test_negative_create_with_name(module_org, name, module_target_sat): """Attempt to create host collection with invalid name of different types @@ -184,11 +180,13 @@ def test_negative_create_with_name(module_org, name): :CaseImportance: Critical """ with pytest.raises(CLIFactoryError): - make_host_collection({'name': name, 'organization-id': module_org.id}) + module_target_sat.cli_factory.make_host_collection( + {'name': name, 'organization-id': module_org.id} + ) @pytest.mark.tier1 -def test_positive_update_limit(module_org): +def test_positive_update_limit(module_org, module_target_sat): """Check if host collection limits can be updated :id: 4c0e0c3b-82ac-4aa2-8378-6adc7946d4ec @@ -199,7 +197,9 @@ def test_positive_update_limit(module_org): :CaseImportance: Critical """ - new_host_col = make_host_collection({'organization-id': module_org.id}) + new_host_col = module_target_sat.cli_factory.make_host_collection( + {'organization-id': module_org.id} + ) for limit in ('3', '6', '9', '12', '15', '17', '19'): HostCollection.update({'id': new_host_col['id'], 'max-hosts': limit}) result = HostCollection.info({'id': new_host_col['id']}) @@ -207,7 +207,7 @@ def test_positive_update_limit(module_org): @pytest.mark.tier2 -def test_positive_list_by_org_id(module_org): +def test_positive_list_by_org_id(module_org, module_target_sat): """Check if host collection list can be filtered by organization id :id: afbe077a-0de1-432c-a0c4-082129aab92e @@ -217,9 +217,11 @@ def test_positive_list_by_org_id(module_org): :CaseLevel: Integration """ # Create two host collections within different organizations - make_host_collection({'organization-id': module_org.id}) - new_org = make_org() - new_host_col = make_host_collection({'organization-id': new_org['id']}) + module_target_sat.cli_factory.make_host_collection({'organization-id': module_org.id}) + new_org = module_target_sat.cli_factory.make_org() + new_host_col = module_target_sat.cli_factory.make_host_collection( + {'organization-id': new_org['id']} + ) # List all host collections assert len(HostCollection.list()) >= 2 # Filter list by org id @@ -229,7 +231,7 @@ def test_positive_list_by_org_id(module_org): @pytest.mark.tier2 -def test_positive_host_collection_host_pagination(module_org): +def test_positive_host_collection_host_pagination(module_org, module_target_sat): """Check if pagination configured on per-page param defined in hammer host-collection hosts command overrides global configuration defined on /etc/hammer/cli_config.yml, which default is 20 per page @@ -243,8 +245,12 @@ def test_positive_host_collection_host_pagination(module_org): :CaseLevel: Integration """ - host_collection = make_host_collection({'organization-id': module_org.id}) - host_ids = ','.join(_make_fake_host_helper(module_org)['id'] for _ in range(2)) + host_collection = module_target_sat.cli_factory.make_host_collection( + {'organization-id': module_org.id} + ) + host_ids = ','.join( + _make_fake_host_helper((module_org)['id'] for _ in range(2)), module_target_sat + ) HostCollection.add_host({'host-ids': host_ids, 'id': host_collection['id']}) for number in range(1, 3): listed_hosts = HostCollection.hosts( @@ -258,7 +264,7 @@ def test_positive_host_collection_host_pagination(module_org): @pytest.mark.tier2 -def test_positive_copy_by_id(module_org): +def test_positive_copy_by_id(module_org, module_target_sat): """Check if host collection can be cloned by id :id: fd7cea50-bc56-4938-a81d-4f7a60711814 @@ -271,7 +277,7 @@ def test_positive_copy_by_id(module_org): :CaseLevel: Integration """ - host_collection = make_host_collection( + host_collection = module_target_sat.cli_factory.make_host_collection( {'name': gen_string('alpha', 15), 'organization-id': module_org.id} ) new_name = gen_string('numeric') @@ -295,7 +301,7 @@ def test_positive_register_host_ak_with_host_collection(module_org, module_ak_wi """ host_info = _make_fake_host_helper(module_org) - hc = make_host_collection({'organization-id': module_org.id}) + hc = target_sat.cli_factory.make_host_collection({'organization-id': module_org.id}) ActivationKey.add_host_collection( { 'id': module_ak_with_cv.id, diff --git a/tests/foreman/cli/test_hostgroup.py b/tests/foreman/cli/test_hostgroup.py index d1fa7190b5a..e32a49b29f7 100644 --- a/tests/foreman/cli/test_hostgroup.py +++ b/tests/foreman/cli/test_hostgroup.py @@ -20,25 +20,11 @@ from nailgun import entities import pytest -from robottelo.cli.base import CLIReturnCodeError from robottelo.cli.contentview import ContentView -from robottelo.cli.factory import ( - CLIFactoryError, - make_architecture, - make_content_view, - make_domain, - make_environment, - make_hostgroup, - make_lifecycle_environment, - make_location, - make_medium, - make_os, - make_partition_table, - make_subnet, -) from robottelo.cli.hostgroup import HostGroup from robottelo.cli.proxy import Proxy from robottelo.config import settings +from robottelo.exceptions import CLIFactoryError, CLIReturnCodeError from robottelo.utils.datafactory import ( invalid_id_list, invalid_values_list, @@ -96,9 +82,9 @@ def content_source(module_target_sat): @pytest.fixture(scope='module') -def hostgroup(content_source, module_org): +def hostgroup(content_source, module_org, module_target_sat): """Create a host group.""" - return make_hostgroup( + return module_target_sat.cli_factory.make_hostgroup( {'content-source-id': content_source['id'], 'organization-ids': module_org.id} ) @@ -140,27 +126,39 @@ def test_positive_create_with_multiple_entities_and_delete( with session_puppet_enabled_sat: # Common entities name = valid_hostgroups_list()[0] - loc = make_location() + loc = session_puppet_enabled_sat.cli_factory.make_location() org_2 = entities.Organization().create() orgs = [module_puppet_org, org_2] - env = make_environment({'location-ids': loc['id'], 'organization-ids': org_2.id}) - lce = make_lifecycle_environment({'organization-id': org_2.id}) + env = session_puppet_enabled_sat.cli_factory.make_environment( + {'location-ids': loc['id'], 'organization-ids': org_2.id} + ) + lce = session_puppet_enabled_sat.cli_factory.make_lifecycle_environment( + {'organization-id': org_2.id} + ) # Content View should be promoted to be used with LC Env - cv = make_content_view({'organization-id': org_2.id}) + cv = session_puppet_enabled_sat.cli_factory.make_content_view({'organization-id': org_2.id}) ContentView.publish({'id': cv['id']}) cv = ContentView.info({'id': cv['id']}) ContentView.version_promote( {'id': cv['versions'][0]['id'], 'to-lifecycle-environment-id': lce['id']} ) # Network - domain = make_domain({'location-ids': loc['id'], 'organization-ids': org_2.id}) - subnet = make_subnet({'domain-ids': domain['id'], 'organization-ids': org_2.id}) + domain = session_puppet_enabled_sat.cli_factory.make_domain( + {'location-ids': loc['id'], 'organization-ids': org_2.id} + ) + subnet = session_puppet_enabled_sat.cli_factory.make_subnet( + {'domain-ids': domain['id'], 'organization-ids': org_2.id} + ) # Operating System - arch = make_architecture() - ptable = make_partition_table({'location-ids': loc['id'], 'organization-ids': org_2.id}) - os = make_os({'architecture-ids': arch['id'], 'partition-table-ids': ptable['id']}) + arch = session_puppet_enabled_sat.cli_factory.make_architecture() + ptable = session_puppet_enabled_sat.cli_factory.make_partition_table( + {'location-ids': loc['id'], 'organization-ids': org_2.id} + ) + os = session_puppet_enabled_sat.cli_factory.make_os( + {'architecture-ids': arch['id'], 'partition-table-ids': ptable['id']} + ) os_full_name = "{} {}.{}".format(os['name'], os['major-version'], os['minor-version']) - media = make_medium( + media = session_puppet_enabled_sat.cli_factory.make_medium( { 'operatingsystem-ids': os['id'], 'location-ids': loc['id'], @@ -188,7 +186,7 @@ def test_positive_create_with_multiple_entities_and_delete( 'puppet-classes': puppet_classes[0]['name'], 'query-organization': org_2.name, } - hostgroup = make_hostgroup(make_hostgroup_params) + hostgroup = session_puppet_enabled_sat.cli_factory.make_hostgroup(make_hostgroup_params) assert hostgroup['name'] == name assert {org.name for org in orgs} == set(hostgroup['organizations']) assert loc['name'] in hostgroup['locations'] @@ -212,7 +210,7 @@ def test_positive_create_with_multiple_entities_and_delete( @pytest.mark.tier2 -def test_negative_create_with_content_source(module_org): +def test_negative_create_with_content_source(module_org, module_target_sat): """Attempt to create a hostgroup with invalid content source specified :id: 9fc1b777-36a3-4940-a9c8-aed7ff725371 @@ -224,7 +222,7 @@ def test_negative_create_with_content_source(module_org): :CaseLevel: Integration """ with pytest.raises(CLIFactoryError): - make_hostgroup( + module_target_sat.cli_factory.make_hostgroup( { 'content-source-id': gen_integer(10000, 99999), 'organization-ids': module_org.id, @@ -257,7 +255,7 @@ def test_positive_update_hostgroup_with_puppet( :CaseLevel: Integration """ with session_puppet_enabled_sat as puppet_sat: - hostgroup = make_hostgroup( + hostgroup = puppet_sat.cli_factory.make_hostgroup( { 'content-source-id': puppet_content_source['id'], 'organization-ids': module_puppet_org.id, @@ -311,7 +309,7 @@ def test_positive_update_hostgroup( :CaseLevel: Integration """ - hostgroup = make_hostgroup( + hostgroup = module_target_sat.cli_factory.make_hostgroup( { 'content-source-id': content_source['id'], 'organization-ids': module_org.id, @@ -383,7 +381,7 @@ def test_negative_delete_by_id(): @pytest.mark.tier2 -def test_positive_created_nested_hostgroup(module_org): +def test_positive_created_nested_hostgroup(module_org, module_target_sat): """Create a nested host group using multiple parent hostgroup paths. e.g. ` hostgroup create --organization 'org_name' --name new3 --parent-title new_1/new_2` @@ -396,9 +394,11 @@ def test_positive_created_nested_hostgroup(module_org): :CaseImportance: Low """ - parent_hg = make_hostgroup({'organization-ids': module_org.id}) - nested = make_hostgroup({'organization-ids': module_org.id, 'parent': parent_hg['name']}) - sub_nested = make_hostgroup( + parent_hg = module_target_sat.cli_factory.make_hostgroup({'organization-ids': module_org.id}) + nested = module_target_sat.cli_factory.make_hostgroup( + {'organization-ids': module_org.id, 'parent': parent_hg['name']} + ) + sub_nested = module_target_sat.cli_factory.make_hostgroup( {'organization-ids': module_org.id, 'parent-title': f'{parent_hg["name"]}/{nested["name"]}'} ) assert sub_nested['title'] == f"{parent_hg['name']}/{nested['name']}/{sub_nested['name']}" diff --git a/tests/foreman/cli/test_http_proxy.py b/tests/foreman/cli/test_http_proxy.py index 50c71313a89..f01df8e743d 100644 --- a/tests/foreman/cli/test_http_proxy.py +++ b/tests/foreman/cli/test_http_proxy.py @@ -19,13 +19,12 @@ from fauxfactory import gen_integer, gen_string, gen_url import pytest -from robottelo.cli.base import CLIReturnCodeError -from robottelo.cli.factory import make_product, make_repository from robottelo.cli.http_proxy import HttpProxy from robottelo.cli.product import Product from robottelo.cli.repository import Repository from robottelo.config import settings from robottelo.constants import FAKE_0_YUM_REPO_PACKAGES_COUNT +from robottelo.exceptions import CLIReturnCodeError @pytest.mark.tier1 @@ -206,7 +205,7 @@ def test_positive_environment_variable_unset_set(): @pytest.mark.e2e @pytest.mark.tier2 @pytest.mark.skipif((not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url') -def test_positive_assign_http_proxy_to_products(module_org): +def test_positive_assign_http_proxy_to_products(module_org, module_target_sat): """Assign http_proxy to Products and perform product sync. :id: 6af7b2b8-15d5-4d9f-9f87-e76b404a966f @@ -234,9 +233,9 @@ def test_positive_assign_http_proxy_to_products(module_org): }, ) # Create products and repositories - product_a = make_product({'organization-id': module_org.id}) - product_b = make_product({'organization-id': module_org.id}) - repo_a1 = make_repository( + product_a = module_target_sat.cli_factory.make_product({'organization-id': module_org.id}) + product_b = module_target_sat.cli_factory.make_product({'organization-id': module_org.id}) + repo_a1 = module_target_sat.cli_factory.make_repository( { 'organization-id': module_org.id, 'product-id': product_a['id'], @@ -244,7 +243,7 @@ def test_positive_assign_http_proxy_to_products(module_org): 'http-proxy-policy': 'none', }, ) - repo_a2 = make_repository( + repo_a2 = module_target_sat.cli_factory.make_repository( { 'organization-id': module_org.id, 'product-id': product_a['id'], @@ -253,7 +252,7 @@ def test_positive_assign_http_proxy_to_products(module_org): 'http-proxy-id': http_proxy_a['id'], }, ) - repo_b1 = make_repository( + repo_b1 = module_target_sat.cli_factory.make_repository( { 'organization-id': module_org.id, 'product-id': product_b['id'], @@ -261,7 +260,7 @@ def test_positive_assign_http_proxy_to_products(module_org): 'http-proxy-policy': 'none', }, ) - repo_b2 = make_repository( + repo_b2 = module_target_sat.cli_factory.make_repository( { 'organization-id': module_org.id, 'product-id': product_b['id'], diff --git a/tests/foreman/cli/test_jobtemplate.py b/tests/foreman/cli/test_jobtemplate.py index 916fdea7a33..e2208860361 100644 --- a/tests/foreman/cli/test_jobtemplate.py +++ b/tests/foreman/cli/test_jobtemplate.py @@ -20,9 +20,8 @@ import pytest from robottelo import ssh -from robottelo.cli.base import CLIReturnCodeError -from robottelo.cli.factory import CLIFactoryError, make_job_template from robottelo.cli.job_template import JobTemplate +from robottelo.exceptions import CLIFactoryError, CLIReturnCodeError from robottelo.utils.datafactory import invalid_values_list, parametrized TEMPLATE_FILE = 'template_file.txt' @@ -36,7 +35,7 @@ def module_template(): @pytest.mark.tier1 -def test_positive_create_job_template(module_org): +def test_positive_create_job_template(module_org, module_target_sat): """Create a simple Job Template :id: a5a67b10-61b0-4362-b671-9d9f095c452c @@ -46,7 +45,7 @@ def test_positive_create_job_template(module_org): :CaseImportance: Critical """ template_name = gen_string('alpha', 7) - make_job_template( + module_target_sat.cli_factory.make_job_template( { 'organizations': module_org.name, 'name': template_name, @@ -58,7 +57,7 @@ def test_positive_create_job_template(module_org): @pytest.mark.tier1 @pytest.mark.parametrize('name', **parametrized(invalid_values_list())) -def test_negative_create_job_template_with_invalid_name(module_org, name): +def test_negative_create_job_template_with_invalid_name(module_org, name, module_target_sat): """Create Job Template with invalid name :id: eb51afd4-e7b3-42c3-81c3-6e18ef3d7efe @@ -71,7 +70,7 @@ def test_negative_create_job_template_with_invalid_name(module_org, name): :CaseImportance: Critical """ with pytest.raises(CLIFactoryError, match='Could not create the job template:'): - make_job_template( + module_target_sat.cli_factory.make_job_template( { 'organizations': module_org.name, 'name': name, @@ -81,7 +80,7 @@ def test_negative_create_job_template_with_invalid_name(module_org, name): @pytest.mark.tier1 -def test_negative_create_job_template_with_same_name(module_org): +def test_negative_create_job_template_with_same_name(module_org, module_target_sat): """Create Job Template with duplicate name :id: 66100c82-97f5-4300-a0c9-8cf041f7789f @@ -91,7 +90,7 @@ def test_negative_create_job_template_with_same_name(module_org): :CaseImportance: Critical """ template_name = gen_string('alpha', 7) - make_job_template( + module_target_sat.cli_factory.make_job_template( { 'organizations': module_org.name, 'name': template_name, @@ -99,7 +98,7 @@ def test_negative_create_job_template_with_same_name(module_org): } ) with pytest.raises(CLIFactoryError, match='Could not create the job template:'): - make_job_template( + module_target_sat.cli_factory.make_job_template( { 'organizations': module_org.name, 'name': template_name, @@ -109,7 +108,7 @@ def test_negative_create_job_template_with_same_name(module_org): @pytest.mark.tier1 -def test_negative_create_empty_job_template(module_org): +def test_negative_create_empty_job_template(module_org, module_target_sat): """Create Job Template with empty template file :id: 749be863-94ae-4008-a242-c23f353ca404 @@ -120,7 +119,7 @@ def test_negative_create_empty_job_template(module_org): """ template_name = gen_string('alpha', 7) with pytest.raises(CLIFactoryError, match='Could not create the job template:'): - make_job_template( + module_target_sat.cli_factory.make_job_template( { 'organizations': module_org.name, 'name': template_name, @@ -131,7 +130,7 @@ def test_negative_create_empty_job_template(module_org): @pytest.mark.tier1 @pytest.mark.upgrade -def test_positive_delete_job_template(module_org): +def test_positive_delete_job_template(module_org, module_target_sat): """Delete a job template :id: 33104c04-20e9-47aa-99da-4bf3414ea31a @@ -141,7 +140,7 @@ def test_positive_delete_job_template(module_org): :CaseImportance: Critical """ template_name = gen_string('alpha', 7) - make_job_template( + module_target_sat.cli_factory.make_job_template( { 'organizations': module_org.name, 'name': template_name, @@ -154,7 +153,7 @@ def test_positive_delete_job_template(module_org): @pytest.mark.tier2 -def test_positive_view_dump(module_org): +def test_positive_view_dump(module_org, module_target_sat): """Export contents of a job template :id: 25fcfcaa-fc4c-425e-919e-330e36195c4a @@ -163,7 +162,7 @@ def test_positive_view_dump(module_org): """ template_name = gen_string('alpha', 7) - make_job_template( + module_target_sat.cli_factory.make_job_template( { 'organizations': module_org.name, 'name': template_name, diff --git a/tests/foreman/cli/test_ldapauthsource.py b/tests/foreman/cli/test_ldapauthsource.py index 92d5185cc83..00bdb6d321b 100644 --- a/tests/foreman/cli/test_ldapauthsource.py +++ b/tests/foreman/cli/test_ldapauthsource.py @@ -21,16 +21,11 @@ import pytest from robottelo.cli.auth import Auth -from robottelo.cli.base import CLIReturnCodeError -from robottelo.cli.factory import ( - make_ldap_auth_source, - make_usergroup, - make_usergroup_external, -) from robottelo.cli.ldapauthsource import LDAPAuthSource from robottelo.cli.role import Role from robottelo.cli.usergroup import UserGroup, UserGroupExternal from robottelo.constants import LDAP_ATTR, LDAP_SERVER_TYPE +from robottelo.exceptions import CLIReturnCodeError from robottelo.utils.datafactory import generate_strings_list, parametrized @@ -57,7 +52,7 @@ class TestADAuthSource: @pytest.mark.upgrade @pytest.mark.parametrize('server_name', **parametrized(generate_strings_list())) @pytest.mark.usefixtures("ldap_tear_down") - def test_positive_create_with_ad(self, ad_data, server_name): + def test_positive_create_with_ad(self, ad_data, server_name, module_target_sat): """Create/update/delete LDAP authentication with AD using names of different types :id: 093f6abc-91e7-4449-b484-71e4a14ac808 @@ -69,7 +64,7 @@ def test_positive_create_with_ad(self, ad_data, server_name): :CaseImportance: Critical """ ad_data = ad_data() - auth = make_ldap_auth_source( + auth = module_target_sat.cli_factory.make_ldap_auth_source( { 'name': server_name, 'onthefly-register': 'true', @@ -99,7 +94,7 @@ def test_positive_create_with_ad(self, ad_data, server_name): @pytest.mark.tier1 @pytest.mark.parametrize('member_group', ['foobargroup', 'foobar.group']) @pytest.mark.usefixtures("ldap_tear_down") - def test_positive_refresh_usergroup_with_ad(self, member_group, ad_data): + def test_positive_refresh_usergroup_with_ad(self, member_group, ad_data, module_target_sat): """Verify the usergroup-sync functionality in AD Auth Source :id: 2e913e76-49c3-11eb-b4c6-d46d6dd3b5b2 @@ -117,7 +112,7 @@ def test_positive_refresh_usergroup_with_ad(self, member_group, ad_data): """ ad_data = ad_data() LOGEDIN_MSG = "Using configured credentials for user '{0}'." - auth_source = make_ldap_auth_source( + auth_source = module_target_sat.cli_factory.make_ldap_auth_source( { 'name': gen_string('alpha'), 'onthefly-register': 'true', @@ -133,8 +128,8 @@ def test_positive_refresh_usergroup_with_ad(self, member_group, ad_data): } ) viewer_role = Role.info({'name': 'Viewer'}) - user_group = make_usergroup() - make_usergroup_external( + user_group = module_target_sat.cli_factory.make_usergroup() + module_target_sat.cli_factory.make_usergroup_external( { 'auth-source-id': auth_source['server']['id'], 'user-group-id': user_group['id'], @@ -176,7 +171,7 @@ def _clean_up_previous_ldap(self): @pytest.mark.upgrade @pytest.mark.e2e @pytest.mark.usefixtures("ldap_tear_down") - def test_positive_end_to_end_with_ipa(self, default_ipa_host, server_name): + def test_positive_end_to_end_with_ipa(self, default_ipa_host, server_name, module_target_sat): """CRUD LDAP authentication with FreeIPA :id: 6cb54405-b579-4020-bf99-cb811a6aa28b @@ -188,7 +183,7 @@ def test_positive_end_to_end_with_ipa(self, default_ipa_host, server_name): :CaseImportance: High """ - auth = make_ldap_auth_source( + auth = module_target_sat.cli_factory.make_ldap_auth_source( { 'name': server_name, 'onthefly-register': 'true', @@ -217,7 +212,7 @@ def test_positive_end_to_end_with_ipa(self, default_ipa_host, server_name): @pytest.mark.tier3 @pytest.mark.usefixtures("ldap_tear_down") - def test_usergroup_sync_with_refresh(self, default_ipa_host): + def test_usergroup_sync_with_refresh(self, default_ipa_host, module_target_sat): """Verify the refresh functionality in Ldap Auth Source :id: c905eb80-2bd0-11ea-abc3-ddb7dbb3c930 @@ -233,7 +228,7 @@ def test_usergroup_sync_with_refresh(self, default_ipa_host): member_group = 'foreman_group' LOGEDIN_MSG = "Using configured credentials for user '{0}'." auth_source_name = gen_string('alpha') - auth_source = make_ldap_auth_source( + auth_source = module_target_sat.cli_factory.make_ldap_auth_source( { 'name': auth_source_name, 'onthefly-register': 'true', @@ -255,8 +250,8 @@ def test_usergroup_sync_with_refresh(self, default_ipa_host): # Adding User in IPA UserGroup default_ipa_host.add_user_to_usergroup(member_username, member_group) viewer_role = Role.info({'name': 'Viewer'}) - user_group = make_usergroup() - ext_user_group = make_usergroup_external( + user_group = module_target_sat.cli_factory.make_usergroup() + ext_user_group = module_target_sat.cli_factory.make_usergroup_external( { 'auth-source-id': auth_source['server']['id'], 'user-group-id': user_group['id'], @@ -298,7 +293,7 @@ def test_usergroup_sync_with_refresh(self, default_ipa_host): @pytest.mark.tier3 @pytest.mark.usefixtures("ldap_tear_down") - def test_usergroup_with_usergroup_sync(self, default_ipa_host): + def test_usergroup_with_usergroup_sync(self, default_ipa_host, module_target_sat): """Verify the usergroup-sync functionality in Ldap Auth Source :id: 2b63e886-2c53-11ea-9da5-db3ae0527554 @@ -314,7 +309,7 @@ def test_usergroup_with_usergroup_sync(self, default_ipa_host): member_group = 'foreman_group' LOGEDIN_MSG = "Using configured credentials for user '{0}'." auth_source_name = gen_string('alpha') - auth_source = make_ldap_auth_source( + auth_source = module_target_sat.cli_factory.make_ldap_auth_source( { 'name': auth_source_name, 'onthefly-register': 'true', @@ -336,8 +331,8 @@ def test_usergroup_with_usergroup_sync(self, default_ipa_host): # Adding User in IPA UserGroup default_ipa_host.add_user_to_usergroup(member_username, member_group) viewer_role = Role.info({'name': 'Viewer'}) - user_group = make_usergroup() - ext_user_group = make_usergroup_external( + user_group = module_target_sat.cli_factory.make_usergroup() + ext_user_group = module_target_sat.cli_factory.make_usergroup_external( { 'auth-source-id': auth_source['server']['id'], 'user-group-id': user_group['id'], @@ -379,7 +374,9 @@ class TestOpenLdapAuthSource: @pytest.mark.e2e @pytest.mark.parametrize('server_name', **parametrized(generate_strings_list())) @pytest.mark.upgrade - def test_positive_end_to_end_with_open_ldap(self, open_ldap_data, server_name): + def test_positive_end_to_end_with_open_ldap( + self, open_ldap_data, server_name, module_target_sat + ): """CRUD LDAP Operations with OpenLDAP :id: f84db334-0189-11eb-846c-d46d6dd3b5b2 @@ -390,7 +387,7 @@ def test_positive_end_to_end_with_open_ldap(self, open_ldap_data, server_name): :CaseImportance: High """ - auth = make_ldap_auth_source( + auth = module_target_sat.cli_factory.make_ldap_auth_source( { 'name': server_name, 'onthefly-register': 'true', diff --git a/tests/foreman/cli/test_lifecycleenvironment.py b/tests/foreman/cli/test_lifecycleenvironment.py index b9a77b5220f..d95f9ae0e2e 100644 --- a/tests/foreman/cli/test_lifecycleenvironment.py +++ b/tests/foreman/cli/test_lifecycleenvironment.py @@ -21,15 +21,14 @@ from fauxfactory import gen_string import pytest -from robottelo.cli.base import CLIReturnCodeError -from robottelo.cli.factory import make_lifecycle_environment, make_org from robottelo.cli.lifecycleenvironment import LifecycleEnvironment from robottelo.constants import ENVIRONMENT +from robottelo.exceptions import CLIReturnCodeError @pytest.fixture(scope='class') -def module_lce(module_org): - return make_lifecycle_environment( +def module_lce(module_org, class_target_sat): + return class_target_sat.cli_factory.make_lifecycle_environment( { 'name': module_org.name, 'organization-id': module_org.id, @@ -60,7 +59,7 @@ def test_positive_list_subcommand(module_org): @pytest.mark.tier2 -def test_positive_search_lce_via_UTF8(module_org): +def test_positive_search_lce_via_UTF8(module_org, module_target_sat): """Search lifecycle environment via its name containing UTF-8 chars @@ -75,14 +74,17 @@ def test_positive_search_lce_via_UTF8(module_org): test_data = {'name': gen_string('utf8', 15), 'organization-id': module_org.id} # Can we find the new object result = LifecycleEnvironment.info( - {'name': make_lifecycle_environment(test_data)['name'], 'organization-id': module_org.id} + { + 'name': module_target_sat.cli_factory.make_lifecycle_environment(test_data)['name'], + 'organization-id': module_org.id, + } ) assert result['name'] == test_data['name'] # CRUD @pytest.mark.tier1 -def test_positive_lce_crud(module_org): +def test_positive_lce_crud(module_org, module_target_sat): """CRUD test case for lifecycle environment for name, description, label, registry name pattern, and unauthenticated pull @@ -103,7 +105,7 @@ def test_positive_lce_crud(module_org): ).format(gen_string('alpha', 5)) # create - lce = make_lifecycle_environment( + lce = module_target_sat.cli_factory.make_lifecycle_environment( { 'organization': org_name, 'organization-id': module_org.id, @@ -141,7 +143,7 @@ def test_positive_lce_crud(module_org): @pytest.mark.tier1 -def test_positive_create_with_organization_label(module_org): +def test_positive_create_with_organization_label(module_org, module_target_sat): """Create lifecycle environment, specifying organization label :id: eb5cfc71-c83d-45ca-ba34-9ef79197691d @@ -152,14 +154,14 @@ def test_positive_create_with_organization_label(module_org): :CaseImportance: Critical """ - new_lce = make_lifecycle_environment( + new_lce = module_target_sat.cli_factory.make_lifecycle_environment( {'name': gen_string('alpha'), 'organization-label': module_org.label} ) assert new_lce['organization'] == module_org.label @pytest.mark.tier1 -def test_positve_list_paths(module_org): +def test_positve_list_paths(module_org, module_target_sat): """List the environment paths under a given organization :id: 71600d6b-1ef4-4b88-8e9b-eb2481ee1fe2 @@ -169,7 +171,9 @@ def test_positve_list_paths(module_org): :CaseImportance: Critical """ - lc_env = make_lifecycle_environment({'organization-id': module_org.id}) + lc_env = module_target_sat.cli_factory.make_lifecycle_environment( + {'organization-id': module_org.id} + ) # Add paths to lifecycle environments result = LifecycleEnvironment.paths( {'organization-id': module_org.id, 'permission-type': 'readable'} @@ -181,17 +185,17 @@ class LifeCycleEnvironmentPaginationTestCase: """Test class for LifeCycle Environment pagination tests""" @classmethod - def setUpClass(cls): + def setUpClass(cls, target_sat): """Create organization and lifecycle environments to reuse in tests""" super().setUpClass() cls.lces_count = 25 - cls.org = make_org() + cls.org = target_sat.cli_factory.make_org() env_base_name = gen_string('alpha') last_env_name = ENVIRONMENT cls.env_names = [last_env_name] for env_index in range(cls.lces_count): env_name = f'{env_base_name}-{env_index}' - make_lifecycle_environment( + target_sat.cli_factorymake_lifecycle_environment( {'name': env_name, 'organization-id': cls.org['id'], 'prior': last_env_name} ) last_env_name = env_name diff --git a/tests/foreman/cli/test_location.py b/tests/foreman/cli/test_location.py index ee157c4ef76..c06f19b9172 100644 --- a/tests/foreman/cli/test_location.py +++ b/tests/foreman/cli/test_location.py @@ -19,22 +19,9 @@ from fauxfactory import gen_string import pytest -from robottelo.cli.base import CLIReturnCodeError from robottelo.cli.computeresource import ComputeResource from robottelo.cli.domain import Domain from robottelo.cli.environment import Environment -from robottelo.cli.factory import ( - CLIFactoryError, - make_compute_resource, - make_domain, - make_environment, - make_hostgroup, - make_location, - make_medium, - make_subnet, - make_template, - make_user, -) from robottelo.cli.hostgroup import HostGroup from robottelo.cli.location import Location from robottelo.cli.medium import Medium @@ -42,6 +29,7 @@ from robottelo.cli.subnet import Subnet from robottelo.cli.template import Template from robottelo.cli.user import User +from robottelo.exceptions import CLIFactoryError, CLIReturnCodeError def _proxy(request, target_sat): @@ -56,8 +44,8 @@ def _cleanup(): return proxy -def _location(request, options=None): - location = make_location(options=options) +def _location(request, target_sat, options=None): + location = target_sat.cli_factory.make_location(options=options) @request.addfinalizer def _cleanup(): @@ -67,8 +55,8 @@ def _cleanup(): return location -def _subnet(request): - subnet = make_subnet() +def _subnet(request, target_sat): + subnet = target_sat.cli_factory.make_subnet() @request.addfinalizer def _cleanup(): @@ -78,8 +66,8 @@ def _cleanup(): return subnet -def _environment(request): - environment = make_environment() +def _environment(request, target_sat): + environment = target_sat.cli_factory.make_environment() @request.addfinalizer def _cleanup(): @@ -89,8 +77,8 @@ def _cleanup(): return environment -def _domain(request): - domain = make_domain() +def _domain(request, target_sat): + domain = target_sat.cli_factory.make_domain() @request.addfinalizer def _cleanup(): @@ -100,8 +88,8 @@ def _cleanup(): return domain -def _medium(request): - medium = make_medium() +def _medium(request, target_sat): + medium = target_sat.cli_factory.make_medium() @request.addfinalizer def _cleanup(): @@ -111,8 +99,8 @@ def _cleanup(): return medium -def _host_group(request): - host_group = make_hostgroup() +def _host_group(request, target_sat): + host_group = target_sat.cli_factory.make_hostgroup() @request.addfinalizer def _cleanup(): @@ -122,8 +110,8 @@ def _cleanup(): return host_group -def _compute_resource(request): - compute_resource = make_compute_resource() +def _compute_resource(request, target_sat): + compute_resource = target_sat.cli_factory.make_compute_resource() @request.addfinalizer def _cleanup(): @@ -133,8 +121,8 @@ def _cleanup(): return compute_resource -def _template(request): - template = make_template() +def _template(request, target_sat): + template = target_sat.cli_factory.make_template() @request.addfinalizer def _cleanup(): @@ -144,8 +132,8 @@ def _cleanup(): return template -def _user(request): - user = make_user() +def _user(request, target_sat): + user = target_sat.cli_factory.make_user() @request.addfinalizer def _cleanup(): diff --git a/tests/foreman/cli/test_logging.py b/tests/foreman/cli/test_logging.py index 45692e2e2a2..90db0b86266 100644 --- a/tests/foreman/cli/test_logging.py +++ b/tests/foreman/cli/test_logging.py @@ -22,7 +22,6 @@ from nailgun import entities import pytest -from robottelo.cli.factory import make_product, make_repository from robottelo.cli.product import Product from robottelo.cli.repository import Repository from robottelo.config import settings @@ -238,10 +237,10 @@ def test_positive_logging_from_pulp3(module_org, target_sat): name = product_name label = product_name desc = product_name - product = make_product( + product = target_sat.cli_factory.make_product( {'description': desc, 'label': label, 'name': name, 'organization-id': module_org.id}, ) - repo = make_repository( + repo = target_sat.cli_factory.make_repository( { 'organization-id': module_org.id, 'product-id': product['id'], diff --git a/tests/foreman/cli/test_medium.py b/tests/foreman/cli/test_medium.py index d9f835fdb0b..019e1dcf229 100644 --- a/tests/foreman/cli/test_medium.py +++ b/tests/foreman/cli/test_medium.py @@ -19,9 +19,8 @@ from fauxfactory import gen_alphanumeric import pytest -from robottelo.cli.base import CLIReturnCodeError -from robottelo.cli.factory import make_location, make_medium, make_org, make_os from robottelo.cli.medium import Medium +from robottelo.exceptions import CLIReturnCodeError from robottelo.utils.datafactory import parametrized, valid_data_list URL = "http://mirror.fakeos.org/%s/$major.$minor/os/$arch" @@ -33,7 +32,7 @@ class TestMedium: @pytest.mark.tier1 @pytest.mark.parametrize('name', **parametrized(valid_data_list().values())) - def test_positive_crud_with_name(self, name): + def test_positive_crud_with_name(self, name, module_target_sat): """Check if Medium can be created, updated, deleted :id: 66b749b2-0248-47a8-b78f-3366f3804b29 @@ -45,7 +44,7 @@ def test_positive_crud_with_name(self, name): :CaseImportance: Critical """ - medium = make_medium({'name': name}) + medium = module_target_sat.cli_factory.make_medium({'name': name}) assert medium['name'] == name new_name = gen_alphanumeric(6) Medium.update({'name': medium['name'], 'new-name': new_name}) @@ -56,7 +55,7 @@ def test_positive_crud_with_name(self, name): Medium.info({'id': medium['id']}) @pytest.mark.tier1 - def test_positive_create_with_location(self): + def test_positive_create_with_location(self, module_target_sat): """Check if medium with location can be created :id: cbc6c586-fae7-4bb9-aeb1-e30158f16a98 @@ -66,12 +65,12 @@ def test_positive_create_with_location(self): :CaseImportance: Medium """ - location = make_location() - medium = make_medium({'location-ids': location['id']}) + location = module_target_sat.cli_factory.make_location() + medium = module_target_sat.cli_factory.make_medium({'location-ids': location['id']}) assert location['name'] in medium['locations'] @pytest.mark.tier1 - def test_positive_create_with_organization_by_id(self): + def test_positive_create_with_organization_by_id(self, module_target_sat): """Check if medium with organization can be created :id: 631bb6ed-e42b-482a-83f0-f6ce0f20729a @@ -81,13 +80,13 @@ def test_positive_create_with_organization_by_id(self): :CaseImportance: Medium """ - org = make_org() - medium = make_medium({'organization-ids': org['id']}) + org = module_target_sat.cli_factory.make_org() + medium = module_target_sat.cli_factory.make_medium({'organization-ids': org['id']}) assert org['name'] in medium['organizations'] @pytest.mark.tier2 @pytest.mark.upgrade - def test_positive_remove_os(self): + def test_positive_remove_os(self, module_target_sat): """Check if Medium can be associated with operating system and then removed from media :id: 23b5b55b-3624-440c-8001-75c7c5a5a004 @@ -97,8 +96,8 @@ def test_positive_remove_os(self): :CaseLevel: Integration """ - medium = make_medium() - os = make_os() + medium = module_target_sat.cli_factory.make_medium() + os = module_target_sat.cli_factory.make_os() Medium.add_operating_system({'id': medium['id'], 'operatingsystem-id': os['id']}) medium = Medium.info({'id': medium['id']}) assert os['title'] in medium['operating-systems'] diff --git a/tests/foreman/cli/test_model.py b/tests/foreman/cli/test_model.py index fe8050d13e9..ac98983c8c7 100644 --- a/tests/foreman/cli/test_model.py +++ b/tests/foreman/cli/test_model.py @@ -19,9 +19,8 @@ from fauxfactory import gen_string import pytest -from robottelo.cli.base import CLIReturnCodeError -from robottelo.cli.factory import make_model from robottelo.cli.model import Model +from robottelo.exceptions import CLIReturnCodeError from robottelo.utils.datafactory import ( invalid_id_list, invalid_values_list, @@ -34,9 +33,9 @@ class TestModel: """Test class for Model CLI""" @pytest.fixture() - def class_model(self): + def class_model(self, target_sat): """Shared model for tests""" - return make_model() + return target_sat.cli_factory.make_model() @pytest.mark.tier1 @pytest.mark.upgrade @@ -44,7 +43,7 @@ def class_model(self): 'name, new_name', **parametrized(list(zip(valid_data_list().values(), valid_data_list().values()))) ) - def test_positive_crud_with_name(self, name, new_name): + def test_positive_crud_with_name(self, name, new_name, module_target_sat): """Successfully creates, updates and deletes a Model. :id: 9ca9d5ff-750a-4d60-91b2-4c4375f0e35f @@ -55,7 +54,7 @@ def test_positive_crud_with_name(self, name, new_name): :CaseImportance: High """ - model = make_model({'name': name}) + model = module_target_sat.cli_factory.make_model({'name': name}) assert model['name'] == name Model.update({'id': model['id'], 'new-name': new_name}) model = Model.info({'id': model['id']}) @@ -65,7 +64,7 @@ def test_positive_crud_with_name(self, name, new_name): Model.info({'id': model['id']}) @pytest.mark.tier1 - def test_positive_create_with_vendor_class(self): + def test_positive_create_with_vendor_class(self, module_target_sat): """Check if Model can be created with specific vendor class :id: c36d3490-cd12-4f5f-a453-2ae5d0404496 @@ -75,7 +74,7 @@ def test_positive_create_with_vendor_class(self): :CaseImportance: Medium """ vendor_class = gen_string('utf8') - model = make_model({'vendor-class': vendor_class}) + model = module_target_sat.cli_factory.make_model({'vendor-class': vendor_class}) assert model['vendor-class'] == vendor_class @pytest.mark.tier1 diff --git a/tests/foreman/cli/test_operatingsystem.py b/tests/foreman/cli/test_operatingsystem.py index 587ceeb67a0..7b5e0bd60a5 100644 --- a/tests/foreman/cli/test_operatingsystem.py +++ b/tests/foreman/cli/test_operatingsystem.py @@ -19,14 +19,8 @@ from fauxfactory import gen_alphanumeric, gen_string import pytest -from robottelo.cli.base import CLIReturnCodeError -from robottelo.cli.factory import ( - make_architecture, - make_medium, - make_partition_table, - make_template, -) from robottelo.constants import DEFAULT_ORG +from robottelo.exceptions import CLIReturnCodeError from robottelo.utils.datafactory import ( filtered_datapoint, invalid_values_list, @@ -114,10 +108,10 @@ def test_positive_end_to_end_os(self, target_sat): new_pass_hash = 'SHA256' new_minor_version = gen_string('numeric', 1) new_major_version = gen_string('numeric', 1) - new_architecture = make_architecture() - new_medium = make_medium() - new_ptable = make_partition_table() - new_template = make_template() + new_architecture = target_sat.cli_factory.make_architecture() + new_medium = target_sat.cli_factory.make_medium() + new_ptable = target_sat.cli_factory.make_partition_table() + new_template = target_sat.cli_factory.make_template() os = target_sat.cli.OperatingSys.update( { 'id': os['id'], diff --git a/tests/foreman/cli/test_organization.py b/tests/foreman/cli/test_organization.py index 2d4a8b8b8b8..53a30227e4b 100644 --- a/tests/foreman/cli/test_organization.py +++ b/tests/foreman/cli/test_organization.py @@ -19,25 +19,12 @@ from fauxfactory import gen_string import pytest -from robottelo.cli.base import CLIReturnCodeError -from robottelo.cli.factory import ( - CLIFactoryError, - make_compute_resource, - make_domain, - make_hostgroup, - make_lifecycle_environment, - make_location, - make_medium, - make_org, - make_subnet, - make_template, - make_user, -) from robottelo.cli.lifecycleenvironment import LifecycleEnvironment from robottelo.cli.org import Org from robottelo.cli.user import User from robottelo.config import settings from robottelo.constants import FOREMAN_PROVIDERS +from robottelo.exceptions import CLIFactoryError, CLIReturnCodeError from robottelo.utils.datafactory import ( filtered_datapoint, invalid_values_list, @@ -98,7 +85,7 @@ def test_positive_no_duplicate_lines(): @pytest.mark.e2e @pytest.mark.tier1 -def test_positive_CRD(): +def test_positive_CRD(module_target_sat): """Create organization with valid name, label and description :id: 35840da7-668e-4f78-990a-738aa688d586 @@ -113,7 +100,9 @@ def test_positive_CRD(): name = valid_org_names_list()[0] label = valid_labels_list()[0] desc = list(valid_data_list().values())[0] - org = make_org({'name': name, 'label': label, 'description': desc}) + org = module_target_sat.cli_factory.make_org( + {'name': name, 'label': label, 'description': desc} + ) assert org['name'] == name assert org['label'] == label @@ -153,7 +142,7 @@ def test_positive_CRD(): @pytest.mark.tier2 -def test_positive_create_with_system_admin_user(): +def test_positive_create_with_system_admin_user(module_target_sat): """Create organization using user with system admin role :id: 1482ab6e-18c7-4a62-81a2-cc969ac373fe @@ -165,16 +154,16 @@ def test_positive_create_with_system_admin_user(): login = gen_string('alpha') password = gen_string('alpha') org_name = gen_string('alpha') - make_user({'login': login, 'password': password}) + module_target_sat.cli_factory.make_user({'login': login, 'password': password}) User.add_role({'login': login, 'role': 'System admin'}) - make_org({'user': login, 'password': password, 'name': org_name}) + module_target_sat.cli_factory.make_org({'user': login, 'password': password, 'name': org_name}) result = Org.info({'name': org_name}) assert result['name'] == org_name @pytest.mark.tier2 @pytest.mark.upgrade -def test_positive_add_and_remove_subnets(module_org): +def test_positive_add_and_remove_subnets(module_org, module_target_sat): """add and remove a subnet from organization :id: adb5310b-76c5-4aca-8220-fdf0fe605cb0 @@ -189,7 +178,7 @@ def test_positive_add_and_remove_subnets(module_org): :CaseLevel: Integration """ - subnets = [make_subnet() for _ in range(0, 2)] + subnets = [module_target_sat.cli_factory.make_subnet() for _ in range(0, 2)] Org.add_subnet({'name': module_org.name, 'subnet': subnets[0]['name']}) Org.add_subnet({'name': module_org.name, 'subnet-id': subnets[1]['id']}) org_info = Org.info({'id': module_org.id}) @@ -201,7 +190,7 @@ def test_positive_add_and_remove_subnets(module_org): @pytest.mark.tier2 -def test_positive_add_and_remove_users(module_org): +def test_positive_add_and_remove_users(module_org, module_target_sat): """Add and remove (admin) user to organization :id: c35b2e88-a65f-4eea-ba55-89cef59f30be @@ -218,8 +207,8 @@ def test_positive_add_and_remove_users(module_org): :CaseLevel: Integration """ - user = make_user() - admin_user = make_user({'admin': '1'}) + user = module_target_sat.cli_factory.make_user() + admin_user = module_target_sat.cli_factory.make_user({'admin': '1'}) assert admin_user['admin'] == 'yes' # add and remove user and admin user by name @@ -250,7 +239,7 @@ def test_positive_add_and_remove_users(module_org): @pytest.mark.tier2 -def test_positive_add_and_remove_hostgroups(module_org): +def test_positive_add_and_remove_hostgroups(module_org, module_target_sat): """add and remove a hostgroup from an organization :id: 34e2c7c8-dc20-4709-a5a9-83c0dee9d84d @@ -265,7 +254,7 @@ def test_positive_add_and_remove_hostgroups(module_org): :CaseLevel: Integration """ - hostgroups = [make_hostgroup() for _ in range(0, 2)] + hostgroups = [module_target_sat.cli_factory.make_hostgroup() for _ in range(0, 2)] Org.add_hostgroup({'hostgroup-id': hostgroups[0]['id'], 'id': module_org.id}) Org.add_hostgroup({'hostgroup': hostgroups[1]['name'], 'name': module_org.name}) @@ -283,7 +272,7 @@ def test_positive_add_and_remove_hostgroups(module_org): @pytest.mark.tier2 @pytest.mark.libvirt_discovery @pytest.mark.upgrade -def test_positive_add_and_remove_compute_resources(module_org): +def test_positive_add_and_remove_compute_resources(module_org, module_target_sat): """Add and remove a compute resource from organization :id: 415c14ab-f879-4ed8-9ba7-8af4ada2e277 @@ -299,7 +288,7 @@ def test_positive_add_and_remove_compute_resources(module_org): :CaseLevel: Integration """ compute_resources = [ - make_compute_resource( + module_target_sat.cli_factory.make_compute_resource( { 'provider': FOREMAN_PROVIDERS['libvirt'], 'url': f'qemu+ssh://root@{settings.libvirt.libvirt_hostname}/system', @@ -331,7 +320,7 @@ def test_positive_add_and_remove_compute_resources(module_org): @pytest.mark.tier2 -def test_positive_add_and_remove_media(module_org): +def test_positive_add_and_remove_media(module_org, module_target_sat): """Add and remove medium to organization :id: c2943a81-c8f7-44c4-926b-388055d7c290 @@ -346,7 +335,7 @@ def test_positive_add_and_remove_media(module_org): :CaseLevel: Integration """ - media = [make_medium() for _ in range(0, 2)] + media = [module_target_sat.cli_factory.make_medium() for _ in range(0, 2)] Org.add_medium({'id': module_org.id, 'medium-id': media[0]['id']}) Org.add_medium({'name': module_org.name, 'medium': media[1]['name']}) org_info = Org.info({'id': module_org.id}) @@ -362,7 +351,7 @@ def test_positive_add_and_remove_media(module_org): @pytest.mark.tier2 @pytest.mark.skip_if_open("BZ:1845860") @pytest.mark.skip_if_open("BZ:1886876") -def test_positive_add_and_remove_templates(module_org): +def test_positive_add_and_remove_templates(module_org, module_target_sat): """Add and remove provisioning templates to organization :id: bd46a192-488f-4da0-bf47-1f370ae5f55c @@ -380,7 +369,9 @@ def test_positive_add_and_remove_templates(module_org): # create and remove templates by name name = list(valid_data_list().values())[0] - template = make_template({'content': gen_string('alpha'), 'name': name}) + template = module_target_sat.cli_factory.make_template( + {'content': gen_string('alpha'), 'name': name} + ) # Add provisioning-template Org.add_provisioning_template( {'name': module_org.name, 'provisioning-template': template['name']} @@ -416,7 +407,7 @@ def test_positive_add_and_remove_templates(module_org): @pytest.mark.tier2 -def test_positive_add_and_remove_domains(module_org): +def test_positive_add_and_remove_domains(module_org, module_target_sat): """Add and remove domains to organization :id: 97359ffe-4ce6-4e44-9e3f-583d3fdebbc8 @@ -431,7 +422,7 @@ def test_positive_add_and_remove_domains(module_org): :CaseLevel: Integration """ - domains = [make_domain() for _ in range(0, 2)] + domains = [module_target_sat.cli_factory.make_domain() for _ in range(0, 2)] Org.add_domain({'domain-id': domains[0]['id'], 'name': module_org.name}) Org.add_domain({'domain': domains[1]['name'], 'name': module_org.name}) org_info = Org.info({'id': module_org.id}) @@ -446,7 +437,7 @@ def test_positive_add_and_remove_domains(module_org): @pytest.mark.tier2 @pytest.mark.upgrade -def test_positive_add_and_remove_lce(module_org): +def test_positive_add_and_remove_lce(module_org, module_target_sat): """Remove a lifecycle environment from organization :id: bfa9198e-6078-4f10-b79a-3d7f51b835fd @@ -460,7 +451,9 @@ def test_positive_add_and_remove_lce(module_org): :CaseLevel: Integration """ # Create a lifecycle environment. - lc_env_name = make_lifecycle_environment({'organization-id': module_org.id})['name'] + lc_env_name = module_target_sat.cli_factory.make_lifecycle_environment( + {'organization-id': module_org.id} + )['name'] lc_env_attrs = {'name': lc_env_name, 'organization-id': module_org.id} # Read back information about the lifecycle environment. Verify the # sanity of that information. @@ -505,7 +498,7 @@ def test_positive_add_and_remove_capsules(proxy, module_org): @pytest.mark.tier2 @pytest.mark.upgrade -def test_positive_add_and_remove_locations(module_org): +def test_positive_add_and_remove_locations(module_org, module_target_sat): """Add and remove a locations from organization :id: 37b63e5c-8fd5-439c-9540-972b597b590a @@ -520,7 +513,7 @@ def test_positive_add_and_remove_locations(module_org): :CaseLevel: Integration """ - locations = [make_location() for _ in range(0, 2)] + locations = [module_target_sat.cli_factory.make_location() for _ in range(0, 2)] Org.add_location({'location-id': locations[0]['id'], 'name': module_org.name}) Org.add_location({'location': locations[1]['name'], 'name': module_org.name}) org_info = Org.info({'id': module_org.id}) @@ -574,7 +567,7 @@ def test_positive_add_and_remove_parameter(module_org): @pytest.mark.tier1 @pytest.mark.parametrize('name', **parametrized(invalid_values_list())) -def test_negative_create_with_invalid_name(name): +def test_negative_create_with_invalid_name(name, module_target_sat): """Try to create an organization with invalid name, but valid label and description @@ -586,7 +579,7 @@ def test_negative_create_with_invalid_name(name): """ with pytest.raises(CLIFactoryError): - make_org( + module_target_sat.cli_factory.make_org( { 'description': gen_string('alpha'), 'label': gen_string('alpha'), @@ -596,7 +589,7 @@ def test_negative_create_with_invalid_name(name): @pytest.mark.tier1 -def test_negative_create_same_name(module_org): +def test_negative_create_same_name(module_org, module_target_sat): """Create a new organization with same name, description, and label. :id: 07924e1f-1eff-4bae-b0db-e41b84966bc1 @@ -606,7 +599,7 @@ def test_negative_create_same_name(module_org): :CaseImportance: Critical """ with pytest.raises(CLIFactoryError): - make_org( + module_target_sat.cli_factory.make_org( { 'description': module_org.description, 'label': module_org.label, @@ -657,7 +650,7 @@ def test_negative_update_name(new_name, module_org): @pytest.mark.tier2 -def test_positive_create_user_with_timezone(module_org): +def test_positive_create_user_with_timezone(module_org, module_target_sat): """Create and remove user with valid timezone in an organization :id: b9b92c00-ee99-4da2-84c5-0a576a862100 @@ -686,7 +679,7 @@ def test_positive_create_user_with_timezone(module_org): 'Samoa', ] for timezone in users_timezones: - user = make_user({'timezone': timezone, 'admin': '1'}) + user = module_target_sat.cli_factory.make_user({'timezone': timezone, 'admin': '1'}) Org.add_user({'name': module_org.name, 'user': user['login']}) org_info = Org.info({'name': module_org.name}) assert user['login'] in org_info['users'] diff --git a/tests/foreman/cli/test_oscap.py b/tests/foreman/cli/test_oscap.py index 5088d25fb60..63968b936f2 100644 --- a/tests/foreman/cli/test_oscap.py +++ b/tests/foreman/cli/test_oscap.py @@ -20,19 +20,12 @@ from nailgun import entities import pytest -from robottelo.cli.base import CLIReturnCodeError -from robottelo.cli.factory import ( - CLIFactoryError, - make_hostgroup, - make_scap_policy, - make_scapcontent, - make_tailoringfile, -) from robottelo.cli.host import Host from robottelo.cli.scap_policy import Scappolicy from robottelo.cli.scapcontent import Scapcontent from robottelo.config import settings from robottelo.constants import OSCAP_DEFAULT_CONTENT, OSCAP_PERIOD, OSCAP_WEEKDAY +from robottelo.exceptions import CLIFactoryError, CLIReturnCodeError from robottelo.utils.datafactory import ( invalid_names_list, parametrized, @@ -120,7 +113,7 @@ def test_negative_list_default_content_with_viewer_role( ) @pytest.mark.tier1 - def test_positive_view_scap_content_info_admin(self): + def test_positive_view_scap_content_info_admin(self, module_target_sat): """View info of scap content with admin account :id: 539ea982-0701-43f5-bb91-e566e6687e35 @@ -142,7 +135,9 @@ def test_positive_view_scap_content_info_admin(self): :CaseImportance: Medium """ title = gen_string('alpha') - make_scapcontent({'title': title, 'scap-file': settings.oscap.content_path}) + module_target_sat.cli_factory.make_scapcontent( + {'title': title, 'scap-file': settings.oscap.content_path} + ) result = Scapcontent.info({'title': title}) assert result['title'] == title @@ -174,7 +169,7 @@ def test_negative_info_scap_content(self): @pytest.mark.parametrize('title', **parametrized(valid_data_list())) @pytest.mark.tier1 - def test_positive_create_scap_content_with_valid_title(self, title): + def test_positive_create_scap_content_with_valid_title(self, title, module_target_sat): """Create scap-content with valid title :id: 68e9fbe2-e3c3-48e7-a774-f1260a3b7f4f @@ -199,11 +194,13 @@ def test_positive_create_scap_content_with_valid_title(self, title): :CaseImportance: Medium """ - scap_content = make_scapcontent({'title': title, 'scap-file': settings.oscap.content_path}) + scap_content = module_target_sat.cli_factory.make_scapcontent( + {'title': title, 'scap-file': settings.oscap.content_path} + ) assert scap_content['title'] == title @pytest.mark.tier1 - def test_negative_create_scap_content_with_same_title(self): + def test_negative_create_scap_content_with_same_title(self, module_target_sat): """Create scap-content with same title :id: a8cbacc9-456a-4f6f-bd0e-4d1167a8b401 @@ -231,14 +228,18 @@ def test_negative_create_scap_content_with_same_title(self): :CaseImportance: Medium """ title = gen_string('alpha') - scap_content = make_scapcontent({'title': title, 'scap-file': settings.oscap.content_path}) + scap_content = module_target_sat.cli_factory.make_scapcontent( + {'title': title, 'scap-file': settings.oscap.content_path} + ) assert scap_content['title'] == title with pytest.raises(CLIFactoryError): - make_scapcontent({'title': title, 'scap-file': settings.oscap.content_path}) + module_target_sat.cli_factory.make_scapcontent( + {'title': title, 'scap-file': settings.oscap.content_path} + ) @pytest.mark.parametrize('title', **parametrized(invalid_names_list())) @pytest.mark.tier1 - def test_negative_create_scap_content_with_invalid_title(self, title): + def test_negative_create_scap_content_with_invalid_title(self, title, module_target_sat): """Create scap-content with invalid title :id: 90a2590e-a6ff-41f1-9e0a-67d4b16435c0 @@ -262,11 +263,15 @@ def test_negative_create_scap_content_with_invalid_title(self, title): :CaseImportance: Medium """ with pytest.raises(CLIFactoryError): - make_scapcontent({'title': title, 'scap-file': settings.oscap.content_path}) + module_target_sat.cli_factory.make_scapcontent( + {'title': title, 'scap-file': settings.oscap.content_path} + ) @pytest.mark.parametrize('name', **parametrized(valid_data_list())) @pytest.mark.tier1 - def test_positive_create_scap_content_with_valid_originalfile_name(self, name): + def test_positive_create_scap_content_with_valid_originalfile_name( + self, name, module_target_sat + ): """Create scap-content with valid original file name :id: 25441174-11cb-4d9b-9ec5-b1c69411b5bc @@ -289,14 +294,16 @@ def test_positive_create_scap_content_with_valid_originalfile_name(self, name): :CaseImportance: Medium """ - scap_content = make_scapcontent( + scap_content = module_target_sat.cli_factory.make_scapcontent( {'original-filename': name, 'scap-file': settings.oscap.content_path} ) assert scap_content['original-filename'] == name @pytest.mark.parametrize('name', **parametrized(invalid_names_list())) @pytest.mark.tier1 - def test_negative_create_scap_content_with_invalid_originalfile_name(self, name): + def test_negative_create_scap_content_with_invalid_originalfile_name( + self, name, module_target_sat + ): """Create scap-content with invalid original file name :id: 83feb67a-a6bf-4a99-923d-889e8d1013fa @@ -322,11 +329,13 @@ def test_negative_create_scap_content_with_invalid_originalfile_name(self, name) :BZ: 1482395 """ with pytest.raises(CLIFactoryError): - make_scapcontent({'original-filename': name, 'scap-file': settings.oscap.content_path}) + module_target_sat.cli_factory.make_scapcontent( + {'original-filename': name, 'scap-file': settings.oscap.content_path} + ) @pytest.mark.parametrize('title', **parametrized(valid_data_list())) @pytest.mark.tier1 - def test_negative_create_scap_content_without_dsfile(self, title): + def test_negative_create_scap_content_without_dsfile(self, title, module_target_sat): """Create scap-content without scap data stream xml file :id: ea811994-12cd-4382-9382-37fa806cc26f @@ -349,10 +358,10 @@ def test_negative_create_scap_content_without_dsfile(self, title): :CaseImportance: Medium """ with pytest.raises(CLIFactoryError): - make_scapcontent({'title': title}) + module_target_sat.cli_factory.make_scapcontent({'title': title}) @pytest.mark.tier1 - def test_positive_update_scap_content_with_newtitle(self): + def test_positive_update_scap_content_with_newtitle(self, module_target_sat): """Update scap content title :id: 2c32e94a-237d-40b9-8a3b-fca2ef26fe79 @@ -376,14 +385,16 @@ def test_positive_update_scap_content_with_newtitle(self): """ title = gen_string('alpha') new_title = gen_string('alpha') - scap_content = make_scapcontent({'title': title, 'scap-file': settings.oscap.content_path}) + scap_content = module_target_sat.cli_factory.make_scapcontent( + {'title': title, 'scap-file': settings.oscap.content_path} + ) assert scap_content['title'] == title Scapcontent.update({'title': title, 'new-title': new_title}) result = Scapcontent.info({'title': new_title}, output_format='json') assert result['title'] == new_title @pytest.mark.tier1 - def test_positive_delete_scap_content_with_id(self): + def test_positive_delete_scap_content_with_id(self, module_target_sat): """Delete a scap content with id as parameter :id: 11ae7652-65e0-4751-b1e0-246b27919238 @@ -403,13 +414,15 @@ def test_positive_delete_scap_content_with_id(self): :CaseImportance: Medium """ - scap_content = make_scapcontent({'scap-file': settings.oscap.content_path}) + scap_content = module_target_sat.cli_factory.make_scapcontent( + {'scap-file': settings.oscap.content_path} + ) Scapcontent.delete({'id': scap_content['id']}) with pytest.raises(CLIReturnCodeError): Scapcontent.info({'id': scap_content['id']}) @pytest.mark.tier1 - def test_positive_delete_scap_content_with_title(self): + def test_positive_delete_scap_content_with_title(self, module_target_sat): """Delete a scap content with title as parameter :id: aa4ca830-3250-4517-b40c-0256cdda5e0a @@ -431,14 +444,18 @@ def test_positive_delete_scap_content_with_title(self): :CaseImportance: Medium """ - scap_content = make_scapcontent({'scap-file': settings.oscap.content_path}) + scap_content = module_target_sat.cli_factory.make_scapcontent( + {'scap-file': settings.oscap.content_path} + ) Scapcontent.delete({'title': scap_content['title']}) with pytest.raises(CLIReturnCodeError): Scapcontent.info({'title': scap_content['title']}) @pytest.mark.parametrize('name', **parametrized(valid_data_list())) @pytest.mark.tier2 - def test_postive_create_scap_policy_with_valid_name(self, name, scap_content): + def test_postive_create_scap_policy_with_valid_name( + self, name, scap_content, module_target_sat + ): """Create scap policy with valid name :id: c9327675-62b2-4e22-933a-02818ef68c11 @@ -460,7 +477,7 @@ def test_postive_create_scap_policy_with_valid_name(self, name, scap_content): :CaseImportance: Medium """ - scap_policy = make_scap_policy( + scap_policy = module_target_sat.cli_factory.make_scap_policy( { 'name': name, 'deploy-by': 'ansible', @@ -478,7 +495,9 @@ def test_postive_create_scap_policy_with_valid_name(self, name, scap_content): @pytest.mark.parametrize('name', **parametrized(invalid_names_list())) @pytest.mark.tier2 - def test_negative_create_scap_policy_with_invalid_name(self, name, scap_content): + def test_negative_create_scap_policy_with_invalid_name( + self, name, scap_content, module_target_sat + ): """Create scap policy with invalid name :id: 0d163968-7759-4cfd-9c4d-98533d8db925 @@ -501,7 +520,7 @@ def test_negative_create_scap_policy_with_invalid_name(self, name, scap_content) :CaseImportance: Medium """ with pytest.raises(CLIFactoryError): - make_scap_policy( + module_target_sat.cli_factory.make_scap_policy( { 'name': name, 'deploy-by': 'ansible', @@ -513,7 +532,7 @@ def test_negative_create_scap_policy_with_invalid_name(self, name, scap_content) ) @pytest.mark.tier2 - def test_negative_create_scap_policy_without_content(self, scap_content): + def test_negative_create_scap_policy_without_content(self, scap_content, module_target_sat): """Create scap policy without scap content :id: 88a8fba3-f45a-4e22-9ee1-f0d701f1135f @@ -534,7 +553,7 @@ def test_negative_create_scap_policy_without_content(self, scap_content): :CaseImportance: Medium """ with pytest.raises(CLIFactoryError): - make_scap_policy( + module_target_sat.cli_factory.make_scap_policy( { 'deploy-by': 'ansible', 'scap-content-profile-id': scap_content["scap_profile_id"], @@ -544,7 +563,7 @@ def test_negative_create_scap_policy_without_content(self, scap_content): ) @pytest.mark.tier2 - def test_positive_associate_scap_policy_with_hostgroups(self, scap_content): + def test_positive_associate_scap_policy_with_hostgroups(self, scap_content, module_target_sat): """Associate hostgroups to scap policy :id: 916403a0-572d-4cf3-9155-3e3d0373577f @@ -566,9 +585,9 @@ def test_positive_associate_scap_policy_with_hostgroups(self, scap_content): :CaseImportance: Medium """ - hostgroup = make_hostgroup() + hostgroup = module_target_sat.cli_factory.make_hostgroup() name = gen_string('alphanumeric') - scap_policy = make_scap_policy( + scap_policy = module_target_sat.cli_factory.make_scap_policy( { 'name': name, 'deploy-by': 'ansible', @@ -582,7 +601,9 @@ def test_positive_associate_scap_policy_with_hostgroups(self, scap_content): assert scap_policy['hostgroups'][0] == hostgroup['name'] @pytest.mark.tier2 - def test_positive_associate_scap_policy_with_hostgroup_via_ansible(self, scap_content): + def test_positive_associate_scap_policy_with_hostgroup_via_ansible( + self, scap_content, module_target_sat + ): """Associate hostgroup to scap policy via ansible :id: 2df303c6-bff5-4977-a865-a3afabfb8726 @@ -604,9 +625,9 @@ def test_positive_associate_scap_policy_with_hostgroup_via_ansible(self, scap_co :expectedresults: The policy is created via ansible deploy option and associated successfully. """ - hostgroup = make_hostgroup() + hostgroup = module_target_sat.cli_factory.make_hostgroup() name = gen_string('alphanumeric') - scap_policy = make_scap_policy( + scap_policy = module_target_sat.cli_factory.make_scap_policy( { 'name': name, 'deploy-by': 'ansible', @@ -624,7 +645,7 @@ def test_positive_associate_scap_policy_with_hostgroup_via_ansible(self, scap_co @pytest.mark.upgrade @pytest.mark.tier2 def test_positive_associate_scap_policy_with_tailoringfiles( - self, deploy, scap_content, tailoring_file_path + self, deploy, scap_content, tailoring_file_path, module_target_sat ): """Associate tailoring file by name/id to scap policy with all deployments @@ -641,12 +662,16 @@ def test_positive_associate_scap_policy_with_tailoringfiles( :expectedresults: The policy is created and associated successfully. """ - tailoring_file_a = make_tailoringfile({'scap-file': tailoring_file_path['satellite']}) + tailoring_file_a = module_target_sat.cli_factory.make_tailoringfile( + {'scap-file': tailoring_file_path['satellite']} + ) tailoring_file_profile_a_id = tailoring_file_a['tailoring-file-profiles'][0]['id'] - tailoring_file_b = make_tailoringfile({'scap-file': tailoring_file_path['satellite']}) + tailoring_file_b = module_target_sat.cli_factory.make_tailoringfile( + {'scap-file': tailoring_file_path['satellite']} + ) tailoring_file_profile_b_id = tailoring_file_b['tailoring-file-profiles'][0]['id'] - scap_policy = make_scap_policy( + scap_policy = module_target_sat.cli_factory.make_scap_policy( { 'scap-content-id': scap_content["scap_id"], 'deploy-by': deploy, @@ -676,7 +701,7 @@ def test_positive_associate_scap_policy_with_tailoringfiles( with pytest.raises(CLIReturnCodeError): Scapcontent.info({'name': scap_policy['name']}) - scap_policy = make_scap_policy( + scap_policy = module_target_sat.cli_factory.make_scap_policy( { 'scap-content-id': scap_content["scap_id"], 'deploy-by': deploy, @@ -710,7 +735,7 @@ def test_positive_associate_scap_policy_with_tailoringfiles( @pytest.mark.upgrade @pytest.mark.tier2 @pytest.mark.e2e - def test_positive_scap_policy_end_to_end(self, deploy, scap_content): + def test_positive_scap_policy_end_to_end(self, deploy, scap_content, module_target_sat): """List all scap policies and read info using id, name :id: d14ab43e-c7a9-4eee-b61c-420b07ca1da9 @@ -735,9 +760,9 @@ def test_positive_scap_policy_end_to_end(self, deploy, scap_content): :CaseImportance: Critical """ - hostgroup = make_hostgroup() + hostgroup = module_target_sat.cli_factory.make_hostgroup() name = gen_string('alphanumeric') - scap_policy = make_scap_policy( + scap_policy = module_target_sat.cli_factory.make_scap_policy( { 'name': name, 'deploy-by': deploy, @@ -769,7 +794,7 @@ def test_positive_scap_policy_end_to_end(self, deploy, scap_content): @pytest.mark.upgrade @pytest.mark.tier2 - def test_positive_update_scap_policy_with_hostgroup(self, scap_content): + def test_positive_update_scap_policy_with_hostgroup(self, scap_content, module_target_sat): """Update scap policy by addition of hostgroup :id: 21b9b82b-7c6c-4944-bc2f-67631e1d4086 @@ -790,9 +815,9 @@ def test_positive_update_scap_policy_with_hostgroup(self, scap_content): :CaseImportance: Medium """ - hostgroup = make_hostgroup() + hostgroup = module_target_sat.cli_factory.make_hostgroup() name = gen_string('alphanumeric') - scap_policy = make_scap_policy( + scap_policy = module_target_sat.cli_factory.make_scap_policy( { 'name': name, 'deploy-by': 'ansible', @@ -805,7 +830,7 @@ def test_positive_update_scap_policy_with_hostgroup(self, scap_content): ) assert scap_policy['hostgroups'][0] == hostgroup['name'] assert scap_policy['deployment-option'] == 'ansible' - new_hostgroup = make_hostgroup() + new_hostgroup = module_target_sat.cli_factory.make_hostgroup() Scappolicy.update( {'id': scap_policy['id'], 'deploy-by': 'ansible', 'hostgroups': new_hostgroup['name']} ) @@ -815,7 +840,7 @@ def test_positive_update_scap_policy_with_hostgroup(self, scap_content): assert scap_info['deployment-option'] == 'ansible' @pytest.mark.tier2 - def test_positive_update_scap_policy_period(self, scap_content): + def test_positive_update_scap_policy_period(self, scap_content, module_target_sat): """Update scap policy by updating the period strategy from monthly to weekly @@ -838,7 +863,7 @@ def test_positive_update_scap_policy_period(self, scap_content): :CaseImportance: Medium """ name = gen_string('alphanumeric') - scap_policy = make_scap_policy( + scap_policy = module_target_sat.cli_factory.make_scap_policy( { 'name': name, 'deploy-by': 'ansible', @@ -862,7 +887,7 @@ def test_positive_update_scap_policy_period(self, scap_content): @pytest.mark.tier2 @pytest.mark.upgrade - def test_positive_update_scap_policy_with_content(self, scap_content): + def test_positive_update_scap_policy_with_content(self, scap_content, module_target_sat): """Update the scap policy by updating the scap content associated with the policy @@ -885,7 +910,7 @@ def test_positive_update_scap_policy_with_content(self, scap_content): :CaseImportance: Medium """ name = gen_string('alphanumeric') - scap_policy = make_scap_policy( + scap_policy = module_target_sat.cli_factory.make_scap_policy( { 'name': name, 'deploy-by': 'ansible', @@ -907,7 +932,9 @@ def test_positive_update_scap_policy_with_content(self, scap_content): assert scap_info['scap-content-profile-id'] == scap_profile_id @pytest.mark.tier2 - def test_positive_associate_scap_policy_with_single_server(self, scap_content): + def test_positive_associate_scap_policy_with_single_server( + self, scap_content, module_target_sat + ): """Assign an audit policy to a single server :id: 30566c27-f466-4b4d-beaf-0a5bfda98b89 @@ -931,7 +958,7 @@ def test_positive_associate_scap_policy_with_single_server(self, scap_content): host = entities.Host() host.create() name = gen_string('alpha') - scap_policy = make_scap_policy( + scap_policy = module_target_sat.cli_factory.make_scap_policy( { 'name': name, 'deploy-by': 'ansible', diff --git a/tests/foreman/cli/test_oscap_tailoringfiles.py b/tests/foreman/cli/test_oscap_tailoringfiles.py index 285a907df3b..c645a76fc2d 100644 --- a/tests/foreman/cli/test_oscap_tailoringfiles.py +++ b/tests/foreman/cli/test_oscap_tailoringfiles.py @@ -19,10 +19,9 @@ from fauxfactory import gen_string import pytest -from robottelo.cli.base import CLIReturnCodeError -from robottelo.cli.factory import CLIFactoryError, make_tailoringfile from robottelo.cli.scap_tailoring_files import TailoringFiles from robottelo.constants import SNIPPET_DATA_FILE, DataFile +from robottelo.exceptions import CLIFactoryError, CLIReturnCodeError from robottelo.utils.datafactory import ( invalid_names_list, parametrized, @@ -35,7 +34,7 @@ class TestTailoringFiles: @pytest.mark.parametrize('name', **parametrized(valid_data_list())) @pytest.mark.tier1 - def test_positive_create(self, tailoring_file_path, name): + def test_positive_create(self, tailoring_file_path, name, module_target_sat): """Create new Tailoring Files using different values types as name :id: e1bb4de2-1b64-4904-bc7c-f0befa9dbd6f @@ -48,7 +47,7 @@ def test_positive_create(self, tailoring_file_path, name): :parametrized: yes """ - tailoring_file = make_tailoringfile( + tailoring_file = module_target_sat.cli_factory.make_tailoringfile( {'name': name, 'scap-file': tailoring_file_path['satellite']} ) assert tailoring_file['name'] == name @@ -58,7 +57,7 @@ def test_positive_create(self, tailoring_file_path, name): TailoringFiles.info({'id': tailoring_file['id']}) @pytest.mark.tier1 - def test_positive_create_with_space(self, tailoring_file_path): + def test_positive_create_with_space(self, tailoring_file_path, module_target_sat): """Create tailoring files with space in name :id: c98ef4e7-41c5-4a8b-8a0b-8d53100b75a8 @@ -72,13 +71,13 @@ def test_positive_create_with_space(self, tailoring_file_path): :CaseImportance: Medium """ name = gen_string('alphanumeric') + ' ' + gen_string('alphanumeric') - tailoring_file = make_tailoringfile( + tailoring_file = module_target_sat.cli_factory.make_tailoringfile( {'name': name, 'scap-file': tailoring_file_path['satellite']} ) assert tailoring_file['name'] == name @pytest.mark.tier1 - def test_positive_get_info_of_tailoring_file(self, tailoring_file_path): + def test_positive_get_info_of_tailoring_file(self, tailoring_file_path, module_target_sat): """Get information of tailoring file :id: bc201194-e8c8-4385-a577-09f3455f5a4d @@ -96,12 +95,14 @@ def test_positive_get_info_of_tailoring_file(self, tailoring_file_path): :CaseImportance: Medium """ name = gen_string('alphanumeric') - make_tailoringfile({'name': name, 'scap-file': tailoring_file_path['satellite']}) + module_target_sat.cli_factory.make_tailoringfile( + {'name': name, 'scap-file': tailoring_file_path['satellite']} + ) result = TailoringFiles.info({'name': name}) assert result['name'] == name @pytest.mark.tier1 - def test_positive_list_tailoring_file(self, tailoring_file_path): + def test_positive_list_tailoring_file(self, tailoring_file_path, module_target_sat): """List all created tailoring files :id: 2ea63c4b-eebe-468d-8153-807e86d1b6a2 @@ -118,7 +119,9 @@ def test_positive_list_tailoring_file(self, tailoring_file_path): :CaseImportance: Medium """ name = gen_string('utf8', length=5) - make_tailoringfile({'name': name, 'scap-file': tailoring_file_path['satellite']}) + module_target_sat.cli_factory.make_tailoringfile( + {'name': name, 'scap-file': tailoring_file_path['satellite']} + ) result = TailoringFiles.list() assert name in [tailoringfile['name'] for tailoringfile in result] @@ -139,11 +142,13 @@ def test_negative_create_with_invalid_file(self, target_sat): target_sat.put(DataFile.SNIPPET_DATA_FILE, f'/tmp/{SNIPPET_DATA_FILE}') name = gen_string('alphanumeric') with pytest.raises(CLIFactoryError): - make_tailoringfile({'name': name, 'scap-file': f'/tmp/{SNIPPET_DATA_FILE}'}) + target_sat.cli_factory.make_tailoringfile( + {'name': name, 'scap-file': f'/tmp/{SNIPPET_DATA_FILE}'} + ) @pytest.mark.parametrize('name', **parametrized(invalid_names_list())) @pytest.mark.tier1 - def test_negative_create_with_invalid_name(self, tailoring_file_path, name): + def test_negative_create_with_invalid_name(self, tailoring_file_path, name, module_target_sat): """Create Tailoring files with invalid name :id: 973eee82-9735-49bb-b534-0de619aa0279 @@ -159,7 +164,9 @@ def test_negative_create_with_invalid_name(self, tailoring_file_path, name): :CaseImportance: Medium """ with pytest.raises(CLIFactoryError): - make_tailoringfile({'name': name, 'scap-file': tailoring_file_path['satellite']}) + module_target_sat.cli_factory.make_tailoringfile( + {'name': name, 'scap-file': tailoring_file_path['satellite']} + ) @pytest.mark.stubbed @pytest.mark.tier2 @@ -202,7 +209,7 @@ def test_positive_download_tailoring_file(self, tailoring_file_path, target_sat) """ name = gen_string('alphanumeric') file_path = f'/var{tailoring_file_path["satellite"]}' - tailoring_file = make_tailoringfile( + tailoring_file = target_sat.cli_factory.make_tailoringfile( {'name': name, 'scap-file': tailoring_file_path['satellite']} ) assert tailoring_file['name'] == name @@ -214,7 +221,7 @@ def test_positive_download_tailoring_file(self, tailoring_file_path, target_sat) @pytest.mark.tier1 @pytest.mark.upgrade - def test_positive_delete_tailoring_file(self, tailoring_file_path): + def test_positive_delete_tailoring_file(self, tailoring_file_path, module_target_sat): """Delete tailoring file :id: 8bab5478-1ef1-484f-aafd-98e5cba7b1e7 @@ -228,7 +235,9 @@ def test_positive_delete_tailoring_file(self, tailoring_file_path): :CaseImportance: Medium """ - tailoring_file = make_tailoringfile({'scap-file': tailoring_file_path['satellite']}) + tailoring_file = module_target_sat.cli_factory.make_tailoringfile( + {'scap-file': tailoring_file_path['satellite']} + ) TailoringFiles.delete({'id': tailoring_file['id']}) with pytest.raises(CLIReturnCodeError): TailoringFiles.info({'id': tailoring_file['id']}) diff --git a/tests/foreman/cli/test_ostreebranch.py b/tests/foreman/cli/test_ostreebranch.py index 23516360e48..925e8917f9f 100644 --- a/tests/foreman/cli/test_ostreebranch.py +++ b/tests/foreman/cli/test_ostreebranch.py @@ -22,12 +22,6 @@ import pytest from robottelo.cli.contentview import ContentView -from robottelo.cli.factory import ( - make_content_view, - make_org_with_credentials, - make_product_with_credentials, - make_repository_with_credentials, -) from robottelo.cli.ostreebranch import OstreeBranch from robottelo.cli.repository import Repository from robottelo.config import settings @@ -49,15 +43,17 @@ def ostree_user_credentials(): @pytest.fixture(scope='module') -def ostree_repo_with_user(ostree_user_credentials): +def ostree_repo_with_user(ostree_user_credentials, module_target_sat): """Create an user, organization, product and ostree repo, sync ostree repo for particular user, create content view and publish it for particular user """ - org = make_org_with_credentials(credentials=ostree_user_credentials) - product = make_product_with_credentials({'organization-id': org['id']}, ostree_user_credentials) + org = module_target_sat.cli_factory.org_with_credentials(credentials=ostree_user_credentials) + product = module_target_sat.cli_factory.product_with_credentials( + {'organization-id': org['id']}, ostree_user_credentials + ) # Create new custom ostree repo - ostree_repo = make_repository_with_credentials( + ostree_repo = module_target_sat.cli_factory.repository_with_credentials( { 'product-id': product['id'], 'content-type': 'ostree', @@ -67,7 +63,7 @@ def ostree_repo_with_user(ostree_user_credentials): ostree_user_credentials, ) Repository.with_user(*ostree_user_credentials).synchronize({'id': ostree_repo['id']}) - cv = make_content_view( + cv = module_target_sat.cli_factory.make_content_view( {'organization-id': org['id'], 'repository-ids': [ostree_repo['id']]}, ostree_user_credentials, ) diff --git a/tests/foreman/cli/test_partitiontable.py b/tests/foreman/cli/test_partitiontable.py index 6540a5d755b..0546dc0139e 100644 --- a/tests/foreman/cli/test_partitiontable.py +++ b/tests/foreman/cli/test_partitiontable.py @@ -21,9 +21,8 @@ from fauxfactory import gen_string import pytest -from robottelo.cli.base import CLIReturnCodeError -from robottelo.cli.factory import make_os, make_partition_table from robottelo.cli.partitiontable import PartitionTable +from robottelo.exceptions import CLIReturnCodeError from robottelo.utils.datafactory import generate_strings_list, parametrized @@ -32,7 +31,7 @@ class TestPartitionTable: @pytest.mark.tier1 @pytest.mark.parametrize('name', **parametrized(generate_strings_list(length=1))) - def test_positive_create_with_one_character_name(self, name): + def test_positive_create_with_one_character_name(self, name, target_sat): """Create Partition table with 1 character in name :id: cfec857c-ed6e-4472-93bb-70e1d4f39bae @@ -45,7 +44,7 @@ def test_positive_create_with_one_character_name(self, name): :CaseImportance: Medium """ - ptable = make_partition_table({'name': name}) + ptable = target_sat.cli_factory.make_partition_table({'name': name}) assert ptable['name'] == name @pytest.mark.tier1 @@ -61,7 +60,7 @@ def test_positive_create_with_one_character_name(self, name): ) ) ) - def test_positive_crud_with_name(self, name, new_name): + def test_positive_crud_with_name(self, name, new_name, module_target_sat): """Create, read, update and delete Partition Tables with different names :id: ce512fef-fbf2-4365-b70b-d30221111d96 @@ -72,7 +71,7 @@ def test_positive_crud_with_name(self, name, new_name): :CaseImportance: Critical """ - ptable = make_partition_table({'name': name}) + ptable = module_target_sat.cli_factory.make_partition_table({'name': name}) assert ptable['name'] == name PartitionTable.update({'id': ptable['id'], 'new-name': new_name}) ptable = PartitionTable.info({'id': ptable['id']}) @@ -82,7 +81,7 @@ def test_positive_crud_with_name(self, name, new_name): PartitionTable.info({'name': ptable['name']}) @pytest.mark.tier1 - def test_positive_create_with_content(self): + def test_positive_create_with_content(self, module_target_sat): """Create a Partition Table with content :id: 28bfbd8b-2ada-44d0-89f3-63885cfb3495 @@ -92,13 +91,13 @@ def test_positive_create_with_content(self): :CaseImportance: Critical """ content = 'Fake ptable' - ptable = make_partition_table({'content': content}) + ptable = module_target_sat.cli_factory.make_partition_table({'content': content}) ptable_content = PartitionTable().dump({'id': ptable['id']}) assert content in ptable_content @pytest.mark.tier1 @pytest.mark.upgrade - def test_positive_create_with_content_length(self): + def test_positive_create_with_content_length(self, module_target_sat): """Create a Partition Table with content length more than 4096 chars :id: 59e6f9ef-85c2-4229-8831-00edb41b19f4 @@ -108,12 +107,12 @@ def test_positive_create_with_content_length(self): :BZ: 1270181 """ content = gen_string('alpha', 5000) - ptable = make_partition_table({'content': content}) + ptable = module_target_sat.cli_factory.make_partition_table({'content': content}) ptable_content = PartitionTable().dump({'id': ptable['id']}) assert content in ptable_content @pytest.mark.tier1 - def test_positive_delete_by_id(self): + def test_positive_delete_by_id(self, module_target_sat): """Create a Partition Table then delete it by its ID :id: 4d2369eb-4dc1-4ab5-96d4-c872c39f4ff5 @@ -122,13 +121,13 @@ def test_positive_delete_by_id(self): :CaseImportance: Critical """ - ptable = make_partition_table() + ptable = module_target_sat.cli_factory.make_partition_table() PartitionTable.delete({'id': ptable['id']}) with pytest.raises(CLIReturnCodeError): PartitionTable.info({'id': ptable['id']}) @pytest.mark.tier2 - def test_positive_add_remove_os_by_id(self): + def test_positive_add_remove_os_by_id(self, module_target_sat): """Create a partition table then add and remove an operating system to it using IDs for association @@ -138,8 +137,8 @@ def test_positive_add_remove_os_by_id(self): :CaseLevel: Integration """ - ptable = make_partition_table() - os = make_os() + ptable = module_target_sat.cli_factory.make_partition_table() + os = module_target_sat.cli_factory.make_os() PartitionTable.add_operating_system({'id': ptable['id'], 'operatingsystem-id': os['id']}) ptable = PartitionTable.info({'id': ptable['id']}) assert os['title'] in ptable['operating-systems'] @@ -149,7 +148,7 @@ def test_positive_add_remove_os_by_id(self): @pytest.mark.tier2 @pytest.mark.upgrade - def test_positive_add_remove_os_by_name(self): + def test_positive_add_remove_os_by_name(self, module_target_sat): """Create a partition table then add and remove an operating system to it using names for association @@ -159,8 +158,8 @@ def test_positive_add_remove_os_by_name(self): :CaseLevel: Integration """ - ptable = make_partition_table() - os = make_os() + ptable = module_target_sat.cli_factory.make_partition_table() + os = module_target_sat.cli_factory.make_os() PartitionTable.add_operating_system( {'name': ptable['name'], 'operatingsystem': os['title']} ) diff --git a/tests/foreman/cli/test_product.py b/tests/foreman/cli/test_product.py index e11b09f6367..b6b5cc252e4 100644 --- a/tests/foreman/cli/test_product.py +++ b/tests/foreman/cli/test_product.py @@ -19,21 +19,13 @@ from fauxfactory import gen_alphanumeric, gen_integer, gen_string, gen_url import pytest -from robottelo.cli.base import CLIReturnCodeError from robottelo.cli.defaults import Defaults -from robottelo.cli.factory import ( - CLIFactoryError, - make_content_credential, - make_org, - make_product, - make_repository, - make_sync_plan, -) from robottelo.cli.package import Package from robottelo.cli.product import Product from robottelo.cli.repository import Repository from robottelo.config import settings from robottelo.constants import FAKE_0_YUM_REPO_PACKAGES_COUNT +from robottelo.exceptions import CLIFactoryError, CLIReturnCodeError from robottelo.utils.datafactory import ( invalid_values_list, parametrized, @@ -57,11 +49,11 @@ def test_positive_CRUD(module_org, target_sat): :CaseImportance: Critical """ desc = list(valid_data_list().values())[0] - gpg_key = make_content_credential({'organization-id': module_org.id}) + gpg_key = target_sat.cli_factory.make_content_credential({'organization-id': module_org.id}) name = list(valid_data_list().values())[0] label = valid_labels_list()[0] - sync_plan = make_sync_plan({'organization-id': module_org.id}) - product = make_product( + sync_plan = target_sat.cli_factory.make_sync_plan({'organization-id': module_org.id}) + product = target_sat.cli_factory.make_product( { 'description': desc, 'gpg-key-id': gpg_key['id'], @@ -80,8 +72,8 @@ def test_positive_CRUD(module_org, target_sat): # update desc = list(valid_data_list().values())[0] - new_gpg_key = make_content_credential({'organization-id': module_org.id}) - new_sync_plan = make_sync_plan({'organization-id': module_org.id}) + new_gpg_key = target_sat.cli_factory.make_content_credential({'organization-id': module_org.id}) + new_sync_plan = target_sat.cli_factory.make_sync_plan({'organization-id': module_org.id}) new_prod_name = gen_string('alpha', 8) Product.update( { @@ -101,7 +93,7 @@ def test_positive_CRUD(module_org, target_sat): assert product['sync-plan-id'] != sync_plan['id'] # synchronize - repo = make_repository( + repo = target_sat.cli_factory.make_repository( { 'organization-id': module_org.id, 'product-id': product['id'], @@ -130,7 +122,7 @@ def test_positive_CRUD(module_org, target_sat): @pytest.mark.tier2 @pytest.mark.parametrize('name', **parametrized(invalid_values_list())) -def test_negative_create_with_name(name, module_org): +def test_negative_create_with_name(name, module_org, module_target_sat): """Check that only valid names can be used :id: 2da26ab2-8d79-47ea-b4d2-defcd98a0649 @@ -142,14 +134,14 @@ def test_negative_create_with_name(name, module_org): :CaseImportance: High """ with pytest.raises(CLIFactoryError): - make_product({'name': name, 'organization-id': module_org.id}) + module_target_sat.cli_factory.make_product({'name': name, 'organization-id': module_org.id}) @pytest.mark.tier2 @pytest.mark.parametrize( 'label', **parametrized([gen_string(e, 15) for e in ('latin1', 'utf8', 'html')]) ) -def test_negative_create_with_label(label, module_org): +def test_negative_create_with_label(label, module_org, module_target_sat): """Check that only valid labels can be used :id: 7cf970aa-48dc-425b-ae37-1e15dfab0626 @@ -161,7 +153,7 @@ def test_negative_create_with_label(label, module_org): :CaseImportance: High """ with pytest.raises(CLIFactoryError): - make_product( + module_target_sat.cli_factory.make_product( { 'label': label, 'name': gen_alphanumeric(), @@ -189,13 +181,15 @@ def test_product_list_with_default_settings(module_org, target_sat): org_id = str(module_org.id) default_product_name = gen_string('alpha') non_default_product_name = gen_string('alpha') - non_default_org = make_org() - default_product = make_product({'name': default_product_name, 'organization-id': org_id}) - non_default_product = make_product( + non_default_org = target_sat.cli_factory.make_org() + default_product = target_sat.cli_factory.make_product( + {'name': default_product_name, 'organization-id': org_id} + ) + non_default_product = target_sat.cli_factory.make_product( {'name': non_default_product_name, 'organization-id': non_default_org['id']} ) for product in default_product, non_default_product: - make_repository( + target_sat.cli_factory.make_repository( { 'organization-id': org_id, 'product-id': product['id'], @@ -228,7 +222,7 @@ def test_product_list_with_default_settings(module_org, target_sat): @pytest.mark.tier2 @pytest.mark.skip_if_open('BZ:1999541') -def test_positive_product_sync_state(module_org): +def test_positive_product_sync_state(module_org, module_target_sat): """hammer product info shows correct sync state. :id: 58af6239-85d7-4b8b-bd2d-ab4cd4f29840 @@ -246,8 +240,8 @@ def test_positive_product_sync_state(module_org): :expectedresults: hammer should show 'Sync Incomplete' in both cases. """ - product = make_product({'organization-id': module_org.id}) - repo_a1 = make_repository( + product = module_target_sat.cli_factory.make_product({'organization-id': module_org.id}) + repo_a1 = module_target_sat.cli_factory.make_repository( { 'organization-id': module_org.id, 'product-id': product['id'], @@ -263,7 +257,7 @@ def test_positive_product_sync_state(module_org): product_list = Product.list({'organization-id': module_org.id}) assert product_info['sync-state-(last)'] in [p.get('sync-state') for p in product_list] - repo_a2 = make_repository( + repo_a2 = module_target_sat.cli_factory.make_repository( { 'organization-id': module_org.id, 'product-id': product['id'], diff --git a/tests/foreman/cli/test_provisioningtemplate.py b/tests/foreman/cli/test_provisioningtemplate.py index 71214e84615..663aa64a1e2 100644 --- a/tests/foreman/cli/test_provisioningtemplate.py +++ b/tests/foreman/cli/test_provisioningtemplate.py @@ -23,7 +23,7 @@ import pytest from robottelo import constants -from robottelo.cli.base import CLIReturnCodeError +from robottelo.exceptions import CLIReturnCodeError @pytest.fixture(scope='module') diff --git a/tests/foreman/cli/test_realm.py b/tests/foreman/cli/test_realm.py index 595a123e9e8..3d059dfd002 100644 --- a/tests/foreman/cli/test_realm.py +++ b/tests/foreman/cli/test_realm.py @@ -21,13 +21,12 @@ from fauxfactory import gen_string import pytest -from robottelo.cli.base import CLIReturnCodeError -from robottelo.cli.factory import CLIFactoryError, make_realm from robottelo.cli.realm import Realm +from robottelo.exceptions import CLIFactoryError, CLIReturnCodeError @pytest.mark.tier1 -def test_negative_create_name_only(): +def test_negative_create_name_only(module_target_sat): """Create a realm with just a name parameter :id: 5606279f-0707-4d36-a307-b204ebb981ad @@ -35,11 +34,13 @@ def test_negative_create_name_only(): :expectedresults: Realm creation fails, requires proxy_id and type """ with pytest.raises(CLIFactoryError): - make_realm({'name': gen_string('alpha', random.randint(1, 30))}) + module_target_sat.cli_factory.make_realm( + {'name': gen_string('alpha', random.randint(1, 30))} + ) @pytest.mark.tier1 -def test_negative_create_invalid_id(): +def test_negative_create_invalid_id(module_target_sat): """Create a realm with an invalid proxy ID :id: 916bd1fb-4649-469c-b511-b0b07301a990 @@ -47,7 +48,7 @@ def test_negative_create_invalid_id(): :expectedresults: Realm creation fails, proxy_id must be numeric """ with pytest.raises(CLIFactoryError): - make_realm( + module_target_sat.cli_factory.make_realm( { 'name': gen_string('alpha', random.randint(1, 30)), 'realm-proxy-id': gen_string('alphanumeric'), @@ -57,7 +58,7 @@ def test_negative_create_invalid_id(): @pytest.mark.tier1 -def test_negative_create_invalid_realm_type(): +def test_negative_create_invalid_realm_type(module_target_sat): """Create a realm with an invalid type :id: 423a0969-9311-48d2-9220-040a42159a89 @@ -66,7 +67,7 @@ def test_negative_create_invalid_realm_type(): e.g. Red Hat Identity Management or Active Directory """ with pytest.raises(CLIFactoryError): - make_realm( + module_target_sat.cli_factory.make_realm( { 'name': gen_string('alpha', random.randint(1, 30)), 'realm-proxy-id': '1', @@ -76,7 +77,7 @@ def test_negative_create_invalid_realm_type(): @pytest.mark.tier1 -def test_negative_create_invalid_location(): +def test_negative_create_invalid_location(module_target_sat): """Create a realm with an invalid location :id: 95335c3a-413f-4156-b727-91b525738171 @@ -84,7 +85,7 @@ def test_negative_create_invalid_location(): :expectedresults: Realm creation fails, location not found """ with pytest.raises(CLIFactoryError): - make_realm( + module_target_sat.cli_factory.make_realm( { 'name': gen_string('alpha', random.randint(1, 30)), 'realm-proxy-id': '1', @@ -95,7 +96,7 @@ def test_negative_create_invalid_location(): @pytest.mark.tier1 -def test_negative_create_invalid_organization(): +def test_negative_create_invalid_organization(module_target_sat): """Create a realm with an invalid organization :id: c0ffbc6d-a2da-484b-9627-5454687a3abb @@ -103,7 +104,7 @@ def test_negative_create_invalid_organization(): :expectedresults: Realm creation fails, organization not found """ with pytest.raises(CLIFactoryError): - make_realm( + module_target_sat.cli_factory.make_realm( { 'name': gen_string('alpha', random.randint(1, 30)), 'realm-proxy-id': '1', diff --git a/tests/foreman/cli/test_remoteexecution.py b/tests/foreman/cli/test_remoteexecution.py index d360f1be8f7..7b5bf64a7ed 100644 --- a/tests/foreman/cli/test_remoteexecution.py +++ b/tests/foreman/cli/test_remoteexecution.py @@ -27,14 +27,6 @@ import pytest from robottelo import constants -from robottelo.cli.factory import ( - make_filter, - make_job_invocation, - make_job_invocation_with_credentials, - make_job_template, - make_role, - make_user, -) from robottelo.cli.filter import Filter from robottelo.cli.globalparam import GlobalParameter from robottelo.cli.host import Host @@ -128,7 +120,9 @@ class TestRemoteExecution: @pytest.mark.pit_client @pytest.mark.pit_server @pytest.mark.rhel_ver_list([8]) - def test_positive_run_default_job_template(self, module_org, rex_contenthost): + def test_positive_run_default_job_template( + self, module_org, rex_contenthost, module_target_sat + ): """Run default template on host connected and list task :id: 811c7747-bec6-4a2d-8e5c-b5045d3fbc0d @@ -144,7 +138,7 @@ def test_positive_run_default_job_template(self, module_org, rex_contenthost): """ client = rex_contenthost command = f'echo {gen_string("alpha")}' - invocation_command = make_job_invocation( + invocation_command = module_target_sat.cli_factory.make_job_invocation( { 'job-template': 'Run Command - Script Default', 'inputs': f'command={command}', @@ -169,7 +163,7 @@ def test_positive_run_default_job_template(self, module_org, rex_contenthost): @pytest.mark.pit_client @pytest.mark.pit_server @pytest.mark.rhel_ver_list([7, 8, 9]) - def test_positive_run_job_effective_user(self, rex_contenthost): + def test_positive_run_job_effective_user(self, rex_contenthost, module_target_sat): """Run default job template as effective user on a host :id: 0cd75cab-f699-47e6-94d3-4477d2a94bb7 @@ -185,7 +179,7 @@ def test_positive_run_job_effective_user(self, rex_contenthost): # create a user on client via remote job username = gen_string('alpha') filename = gen_string('alpha') - make_user_job = make_job_invocation( + make_user_job = module_target_sat.cli_factory.make_job_invocation( { 'job-template': 'Run Command - Script Default', 'inputs': f"command=useradd -m {username}", @@ -194,7 +188,7 @@ def test_positive_run_job_effective_user(self, rex_contenthost): ) assert_job_invocation_result(make_user_job['id'], client.hostname) # create a file as new user - invocation_command = make_job_invocation( + invocation_command = module_target_sat.cli_factory.make_job_invocation( { 'job-template': 'Run Command - Script Default', 'inputs': f"command=touch /home/{username}/{filename}", @@ -233,10 +227,10 @@ def test_positive_run_custom_job_template(self, rex_contenthost, module_org, tar template_file = 'template_file.txt' target_sat.execute(f'echo "echo Enforcing" > {template_file}') template_name = gen_string('alpha', 7) - make_job_template( + target_sat.cli_factory.make_job_template( {'organizations': self.org.name, 'name': template_name, 'file': template_file} ) - invocation_command = make_job_invocation( + invocation_command = target_sat.cli_factory.make_job_invocation( {'job-template': template_name, 'search-query': f'name ~ {client.hostname}'} ) assert_job_invocation_result(invocation_command['id'], client.hostname) @@ -245,7 +239,9 @@ def test_positive_run_custom_job_template(self, rex_contenthost, module_org, tar @pytest.mark.upgrade @pytest.mark.no_containers @pytest.mark.rhel_ver_list([8]) - def test_positive_run_default_job_template_multiple_hosts(self, registered_hosts, module_org): + def test_positive_run_default_job_template_multiple_hosts( + self, registered_hosts, module_target_sat + ): """Run default job template against multiple hosts :id: 694a21d3-243b-4296-8bd0-4bad9663af15 @@ -255,7 +251,7 @@ def test_positive_run_default_job_template_multiple_hosts(self, registered_hosts :parametrized: yes """ clients = registered_hosts - invocation_command = make_job_invocation( + invocation_command = module_target_sat.cli_factory.make_job_invocation( { 'job-template': 'Run Command - Script Default', 'inputs': 'command=ls', @@ -306,7 +302,7 @@ def test_positive_install_remove_multiple_packages_with_a_job( repo=settings.repos.yum_3.url, ) # Install packages - invocation_command = make_job_invocation( + invocation_command = target_sat.cli_factory.make_job_invocation( { 'job-template': 'Install Package - Katello Script Default', 'inputs': f'package={" ".join(packages)}', @@ -320,7 +316,7 @@ def test_positive_install_remove_multiple_packages_with_a_job( pre_versions = result.stdout.splitlines() result = client.run(f'dnf -y downgrade {" ".join(packages)}') assert result.status == 0 - invocation_command = make_job_invocation( + invocation_command = target_sat.cli_factory.make_job_invocation( { 'job-template': 'Update Package - Katello Script Default', 'inputs': f'package={" ".join(packages)}', @@ -331,7 +327,7 @@ def test_positive_install_remove_multiple_packages_with_a_job( post_versions = client.run(f'rpm -q {" ".join(packages)}').stdout.splitlines() assert set(pre_versions) == set(post_versions) # Remove packages - invocation_command = make_job_invocation( + invocation_command = target_sat.cli_factory.make_job_invocation( { 'job-template': 'Remove Package - Katello Script Default', 'inputs': f'package={" ".join(packages)}', @@ -370,7 +366,7 @@ def test_positive_install_remove_packagegroup_with_a_job( repo=settings.repos.yum_1.url, ) # Install the package groups - invocation_command = make_job_invocation( + invocation_command = target_sat.cli_factory.make_job_invocation( { 'job-template': 'Install Group - Katello Script Default', 'inputs': f'package={" ".join(groups)}', @@ -382,7 +378,7 @@ def test_positive_install_remove_packagegroup_with_a_job( assert all(item in result.stdout for item in groups) # Remove one of the installed package groups remove = random.choice(groups) - invocation_command = make_job_invocation( + invocation_command = target_sat.cli_factory.make_job_invocation( { 'job-template': 'Remove Group - Katello Script Default', 'inputs': f'package={remove}', @@ -420,7 +416,7 @@ def test_positive_install_errata_with_a_job( ) client.run(f'dnf install -y {constants.FAKE_1_CUSTOM_PACKAGE}') # Install errata - invocation_command = make_job_invocation( + invocation_command = target_sat.cli_factory.make_job_invocation( { 'job-template': 'Install Errata - Katello Script Default', 'inputs': f'errata={settings.repos.yum_0.errata[1]}', @@ -447,7 +443,7 @@ def test_positive_match_feature_templates(self, target_sat, feature): @pytest.mark.tier3 @pytest.mark.rhel_ver_list([8]) - def test_positive_run_recurring_job_with_max_iterations(self, rex_contenthost): + def test_positive_run_recurring_job_with_max_iterations(self, rex_contenthost, target_sat): """Run default job template multiple times with max iteration :id: 0a3d1627-95d9-42ab-9478-a908f2a7c509 @@ -458,7 +454,7 @@ def test_positive_run_recurring_job_with_max_iterations(self, rex_contenthost): :parametrized: yes """ client = rex_contenthost - invocation_command = make_job_invocation( + invocation_command = target_sat.cli_factory.make_job_invocation( { 'job-template': 'Run Command - Script Default', 'inputs': 'command=ls', @@ -476,7 +472,7 @@ def test_positive_run_recurring_job_with_max_iterations(self, rex_contenthost): @pytest.mark.tier3 @pytest.mark.rhel_ver_list([8]) - def test_positive_time_expressions(self, rex_contenthost): + def test_positive_time_expressions(self, rex_contenthost, target_sat): """Test various expressions for extended cronline syntax :id: 584e7b27-9484-436a-b850-11acb900a7d8 @@ -541,7 +537,7 @@ def test_positive_time_expressions(self, rex_contenthost): ], ] for exp in fugit_expressions: - invocation_command = make_job_invocation( + invocation_command = target_sat.cli_factory.make_job_invocation( { 'job-template': 'Run Command - Script Default', 'inputs': 'command=ls', @@ -573,7 +569,7 @@ def test_positive_run_scheduled_job_template(self, rex_contenthost, target_sat): system_current_time = target_sat.execute('date --utc +"%b %d %Y %I:%M%p"').stdout current_time_object = datetime.strptime(system_current_time.strip('\n'), '%b %d %Y %I:%M%p') plan_time = (current_time_object + timedelta(seconds=30)).strftime("%Y-%m-%d %H:%M") - invocation_command = make_job_invocation( + invocation_command = target_sat.cli_factory.make_job_invocation( { 'job-template': 'Run Command - Script Default', 'inputs': 'command=ls', @@ -598,7 +594,7 @@ class TestAnsibleREX: @pytest.mark.pit_client @pytest.mark.pit_server @pytest.mark.rhel_ver_list([7, 8, 9]) - def test_positive_run_effective_user_job(self, rex_contenthost): + def test_positive_run_effective_user_job(self, rex_contenthost, target_sat): """Tests Ansible REX job having effective user runs successfully :id: a5fa20d8-c2bd-4bbf-a6dc-bf307b59dd8c @@ -625,7 +621,7 @@ def test_positive_run_effective_user_job(self, rex_contenthost): # create a user on client via remote job username = gen_string('alpha') filename = gen_string('alpha') - make_user_job = make_job_invocation( + make_user_job = target_sat.cli_factory.make_job_invocation( { 'job-template': 'Run Command - Ansible Default', 'inputs': f"command=useradd -m {username}", @@ -634,7 +630,7 @@ def test_positive_run_effective_user_job(self, rex_contenthost): ) assert_job_invocation_result(make_user_job['id'], client.hostname) # create a file as new user - invocation_command = make_job_invocation( + invocation_command = target_sat.cli_factory.make_job_invocation( { 'job-template': 'Run Command - Ansible Default', 'inputs': f"command=touch /home/{username}/{filename}", @@ -653,7 +649,7 @@ def test_positive_run_effective_user_job(self, rex_contenthost): @pytest.mark.tier3 @pytest.mark.upgrade @pytest.mark.rhel_ver_list([8]) - def test_positive_run_reccuring_job(self, rex_contenthost): + def test_positive_run_reccuring_job(self, rex_contenthost, target_sat): """Tests Ansible REX reccuring job runs successfully multiple times :id: 49b0d31d-58f9-47f1-aa5d-561a1dcb0d66 @@ -679,7 +675,7 @@ def test_positive_run_reccuring_job(self, rex_contenthost): :parametrized: yes """ client = rex_contenthost - invocation_command = make_job_invocation( + invocation_command = target_sat.cli_factory.make_job_invocation( { 'job-template': 'Run Command - Ansible Default', 'inputs': 'command=ls', @@ -705,7 +701,7 @@ def test_positive_run_reccuring_job(self, rex_contenthost): @pytest.mark.tier3 @pytest.mark.no_containers - def test_positive_run_concurrent_jobs(self, registered_hosts, module_org): + def test_positive_run_concurrent_jobs(self, registered_hosts, target_sat): """Tests Ansible REX concurent jobs without batch trigger :id: ad0f108c-03f2-49c7-8732-b1056570567b @@ -732,7 +728,7 @@ def test_positive_run_concurrent_jobs(self, registered_hosts, module_org): GlobalParameter().set({'name': param_name, 'value': 'false'}) clients = registered_hosts output_msgs = [] - invocation_command = make_job_invocation( + invocation_command = target_sat.cli_factory.make_job_invocation( { 'job-template': 'Run Command - Ansible Default', 'inputs': 'command=ls', @@ -808,7 +804,7 @@ def test_positive_run_packages_and_services_job( repo=settings.repos.yum_3.url, ) # install package - invocation_command = make_job_invocation( + invocation_command = target_sat.cli_factory.make_job_invocation( { 'job-template': 'Package Action - Ansible Default', 'inputs': 'state=latest, name={}'.format(*packages), @@ -821,7 +817,7 @@ def test_positive_run_packages_and_services_job( # stop a service service = "rsyslog" - invocation_command = make_job_invocation( + invocation_command = target_sat.cli_factory.make_job_invocation( { 'job-template': 'Service Action - Ansible Default', 'inputs': f'state=stopped, name={service}', @@ -833,7 +829,7 @@ def test_positive_run_packages_and_services_job( assert result.status == 3 # start it again - invocation_command = make_job_invocation( + invocation_command = target_sat.cli_factory.make_job_invocation( { 'job-template': 'Service Action - Ansible Default', 'inputs': f'state=started, name={service}', @@ -849,7 +845,7 @@ def test_positive_run_packages_and_services_job( 'fixture_sca_vmsetup', [{'nick': 'rhel8'}], ids=['rhel8'], indirect=True ) def test_positive_install_ansible_collection( - self, fixture_sca_vmsetup, module_sca_manifest_org + self, fixture_sca_vmsetup, module_sca_manifest_org, target_sat ): """Test whether Ansible collection can be installed via REX @@ -888,7 +884,7 @@ def test_positive_install_ansible_collection( client.execute('subscription-manager refresh') client.execute(f'subscription-manager repos --enable {REPOS["rhae2.9_el8"]["id"]}') client.execute('dnf -y install ansible') - collection_job = make_job_invocation( + collection_job = target_sat.cli_factory.make_job_invocation( { 'job-template': 'Ansible Collection - Install from Galaxy', 'inputs': 'ansible_collections_list="oasis_roles.system"', @@ -901,7 +897,7 @@ def test_positive_install_ansible_collection( assert 'oasis_roles' in collection_path # Extend test with custom collections_path advanced input field - collection_job = make_job_invocation( + collection_job = target_sat.cli_factory.make_job_invocation( { 'job-template': 'Ansible Collection - Install from Galaxy', 'inputs': 'ansible_collections_list="oasis_roles.system", collections_path="~/"', @@ -918,21 +914,25 @@ class TestRexUsers: """Tests related to remote execution users""" @pytest.fixture(scope='class') - def class_rexmanager_user(self, module_org): + def class_rexmanager_user(self, module_org, class_target_sat): """Creates a user with Remote Execution Manager role""" password = gen_string('alpha') rexmanager = gen_string('alpha') - make_user({'login': rexmanager, 'password': password, 'organization-ids': module_org.id}) + class_target_sat.cli_factory.make_user( + {'login': rexmanager, 'password': password, 'organization-ids': module_org.id} + ) User.add_role({'login': rexmanager, 'role': 'Remote Execution Manager'}) yield (rexmanager, password) @pytest.fixture(scope='class') - def class_rexinfra_user(self, module_org): + def class_rexinfra_user(self, module_org, class_target_sat): """Creates a user with all Remote Execution related permissions""" password = gen_string('alpha') rexinfra = gen_string('alpha') - make_user({'login': rexinfra, 'password': password, 'organization-ids': module_org.id}) - role = make_role({'organization-ids': module_org.id}) + class_target_sat.cli_factory.make_user( + {'login': rexinfra, 'password': password, 'organization-ids': module_org.id} + ) + role = class_target_sat.cli_factory.make_role({'organization-ids': module_org.id}) invocation_permissions = [ permission['name'] for permission in Filter.available_permissions( @@ -944,10 +944,14 @@ def class_rexinfra_user(self, module_org): for permission in Filter.available_permissions({'search': 'resource_type=JobTemplate'}) ] permissions = ','.join(invocation_permissions) - make_filter({'role-id': role['id'], 'permissions': permissions}) + class_target_sat.cli_factory.make_filter( + {'role-id': role['id'], 'permissions': permissions} + ) permissions = ','.join(template_permissions) # needs execute_jobs_on_infrastructure_host permission - make_filter({'role-id': role['id'], 'permissions': permissions}) + class_target_sat.cli_factory.make_filter( + {'role-id': role['id'], 'permissions': permissions} + ) User.add_role({'login': rexinfra, 'role': role['name']}) User.add_role({'login': rexinfra, 'role': 'Remote Execution Manager'}) yield (rexinfra, password) @@ -996,7 +1000,7 @@ def test_positive_rex_against_infra_hosts( # run job as admin command = f"echo {gen_string('alpha')}" - invocation_command = make_job_invocation( + invocation_command = target_sat.cli_factory.make_job_invocation( { 'job-template': 'Run Command - Script Default', 'inputs': f'command={command}', @@ -1014,7 +1018,7 @@ def test_positive_rex_against_infra_hosts( assert result['success'] == '2', output_msgs # run job as regular rex user on all hosts - invocation_command = make_job_invocation_with_credentials( + invocation_command = target_sat.cli_factory.make_job_invocation_with_credentials( { 'job-template': 'Run Command - Script Default', 'inputs': f'command={command}', @@ -1027,7 +1031,7 @@ def test_positive_rex_against_infra_hosts( assert result['success'] == '1' # run job as regular rex user just on infra hosts - invocation_command = make_job_invocation_with_credentials( + invocation_command = target_sat.cli_factory.make_job_invocation_with_credentials( { 'job-template': 'Run Command - Script Default', 'inputs': f'command={command}', @@ -1039,7 +1043,7 @@ def test_positive_rex_against_infra_hosts( assert result['success'] == '0' # run job as rex user on Satellite - invocation_command = make_job_invocation_with_credentials( + invocation_command = target_sat.cli_factory.make_job_invocation_with_credentials( { 'job-template': 'Run Command - Script Default', 'inputs': f'command={command}', @@ -1100,7 +1104,7 @@ def test_positive_run_job_on_host_registered_to_async_ssh_provider( assert result.status == 0, f'Failed to register host: {result.stderr}' # run script provider rex command, longer-running command is needed to # verify the connection is not shut down too soon - invocation_command = make_job_invocation( + invocation_command = module_target_sat.cli_factory.make_job_invocation( { 'job-template': 'Run Command - Script Default', 'inputs': 'command=echo start; sleep 10; echo done', @@ -1173,7 +1177,7 @@ def test_positive_run_job_on_host_converted_to_pull_provider( result = rhel_contenthost.execute('systemctl status yggdrasild') assert result.status == 0, f'Failed to start yggdrasil on client: {result.stderr}' # run script provider rex command - invocation_command = make_job_invocation( + invocation_command = module_target_sat.cli_factory.make_job_invocation( { 'job-template': 'Run Command - Script Default', 'inputs': 'command=ls', @@ -1186,7 +1190,7 @@ def test_positive_run_job_on_host_converted_to_pull_provider( assert result.status == 0, 'Failed to start goferd on client' # run Ansible rex command to prove ssh provider works, remove katello-agent - invocation_command = make_job_invocation( + invocation_command = module_target_sat.cli_factory.make_job_invocation( { 'job-template': 'Package Action - Ansible Default', 'inputs': 'state=absent, name=katello-agent', @@ -1200,7 +1204,7 @@ def test_positive_run_job_on_host_converted_to_pull_provider( assert result.status == 0, f'Failed to start yggdrasil on client: {result.stderr}' result = rhel_contenthost.execute('systemctl status yggdrasild') assert result.status == 0, f'Failed to start yggdrasil on client: {result.stderr}' - invocation_command = make_job_invocation( + invocation_command = module_target_sat.cli_factory.make_job_invocation( { 'job-template': 'Run Command - Script Default', 'inputs': 'command=ls', @@ -1223,6 +1227,7 @@ def test_positive_run_job_on_host_registered_to_pull_provider( module_ak_with_cv, module_capsule_configured_mqtt, rhel_contenthost, + target_sat, ): """Run custom template on host registered to mqtt, check effective user setting @@ -1267,7 +1272,7 @@ def test_positive_run_job_on_host_registered_to_pull_provider( result = rhel_contenthost.execute('systemctl status yggdrasild') assert result.status == 0, f'Failed to start yggdrasil on client: {result.stderr}' # run script provider rex command - invocation_command = make_job_invocation( + invocation_command = target_sat.cli_factory.make_job_invocation( { 'job-template': 'Service Action - Script Default', 'inputs': 'action=status, service=yggdrasild', @@ -1278,7 +1283,7 @@ def test_positive_run_job_on_host_registered_to_pull_provider( # create user on host username = gen_string('alpha') filename = gen_string('alpha') - make_user_job = make_job_invocation( + make_user_job = target_sat.cli_factory.make_job_invocation( { 'job-template': 'Run Command - Script Default', 'inputs': f"command=useradd -m {username}", @@ -1287,7 +1292,7 @@ def test_positive_run_job_on_host_registered_to_pull_provider( ) assert_job_invocation_result(make_user_job['id'], rhel_contenthost.hostname) # create a file as new user - invocation_command = make_job_invocation( + invocation_command = module_target_sat.make_job_invocation( { 'job-template': 'Run Command - Script Default', 'inputs': f"command=touch /home/{username}/{filename}", @@ -1360,7 +1365,7 @@ def test_positive_run_pull_job_on_offline_host( result = rhel_contenthost.execute('systemctl stop yggdrasild') assert result.status == 0, f'Failed to stop yggdrasil on client: {result.stderr}' # run script provider rex command - invocation_command = make_job_invocation( + invocation_command = module_target_sat.cli_factory.make_job_invocation( { 'job-template': 'Run Command - Script Default', 'inputs': 'command=ls', diff --git a/tests/foreman/cli/test_report.py b/tests/foreman/cli/test_report.py index b2d84d3adb8..94946b88e66 100644 --- a/tests/foreman/cli/test_report.py +++ b/tests/foreman/cli/test_report.py @@ -20,7 +20,7 @@ import pytest -from robottelo.cli.base import CLIReturnCodeError +from robottelo.exceptions import CLIReturnCodeError @pytest.fixture(scope='module') diff --git a/tests/foreman/cli/test_reporttemplates.py b/tests/foreman/cli/test_reporttemplates.py index 8f2729046b3..d222542dc87 100644 --- a/tests/foreman/cli/test_reporttemplates.py +++ b/tests/foreman/cli/test_reporttemplates.py @@ -20,28 +20,8 @@ import pytest from robottelo.cli.activationkey import ActivationKey -from robottelo.cli.base import Base, CLIReturnCodeError +from robottelo.cli.base import Base from robottelo.cli.contentview import ContentView -from robottelo.cli.factory import ( - CLIFactoryError, - make_activation_key, - make_architecture, - make_content_view, - make_fake_host, - make_filter, - make_lifecycle_environment, - make_medium, - make_os, - make_partition_table, - make_product, - make_report_template, - make_repository, - make_role, - make_template_input, - make_user, - setup_org_for_a_custom_repo, - setup_org_for_a_rh_repo, -) from robottelo.cli.filter import Filter from robottelo.cli.host import Host from robottelo.cli.location import Location @@ -65,22 +45,29 @@ REPOS, REPOSET, ) +from robottelo.exceptions import CLIFactoryError, CLIReturnCodeError from robottelo.hosts import ContentHost @pytest.fixture(scope='module') -def local_environment(module_entitlement_manifest_org): +def local_environment(module_entitlement_manifest_org, module_target_sat): """Create a lifecycle environment with CLI factory""" - return make_lifecycle_environment({'organization-id': module_entitlement_manifest_org.id}) + return module_target_sat.cli_factory.make_lifecycle_environment( + {'organization-id': module_entitlement_manifest_org.id} + ) @pytest.fixture(scope='module') -def local_content_view(module_entitlement_manifest_org): +def local_content_view(module_entitlement_manifest_org, module_target_sat): """Create content view, repository, and product""" - new_product = make_product({'organization-id': module_entitlement_manifest_org.id}) - new_repo = make_repository({'product-id': new_product['id']}) + new_product = module_target_sat.cli_factory.make_product( + {'organization-id': module_entitlement_manifest_org.id} + ) + new_repo = module_target_sat.cli_factory.make_repository({'product-id': new_product['id']}) Repository.synchronize({'id': new_repo['id']}) - content_view = make_content_view({'organization-id': module_entitlement_manifest_org.id}) + content_view = module_target_sat.cli_factory.make_content_view( + {'organization-id': module_entitlement_manifest_org.id} + ) ContentView.add_repository( { 'id': content_view['id'], @@ -93,13 +80,15 @@ def local_content_view(module_entitlement_manifest_org): @pytest.fixture(scope='module') -def local_ak(module_entitlement_manifest_org, local_environment, local_content_view): +def local_ak( + module_entitlement_manifest_org, local_environment, local_content_view, module_target_sat +): """Promote a content view version and create an activation key with CLI Factory""" cvv = ContentView.info({'id': local_content_view['id']})['versions'][0] ContentView.version_promote( {'id': cvv['id'], 'to-lifecycle-environment-id': local_environment['id']} ) - return make_activation_key( + return module_target_sat.cli_factory.make_activation_key( { 'lifecycle-environment-id': local_environment['id'], 'content-view': local_content_view['name'], @@ -169,7 +158,7 @@ def test_positive_report_help(): @pytest.mark.tier1 @pytest.mark.e2e -def test_positive_end_to_end_crud_and_list(): +def test_positive_end_to_end_crud_and_list(target_sat): """CRUD test + list test for report templates :id: 2a143ddf-683f-49e2-badb-f9a387cfc53c @@ -197,12 +186,12 @@ def test_positive_end_to_end_crud_and_list(): """ # create name = gen_alpha() - report_template = make_report_template({'name': name}) + report_template = target_sat.cli_factory.make_report_template({'name': name}) assert report_template['name'] == name # list - create second template tmp_name = gen_alpha() - tmp_report_template = make_report_template({'name': tmp_name}) + tmp_report_template = target_sat.cli_factory.make_report_template({'name': tmp_name}) result_list = ReportTemplate.list() assert name in [rt['name'] for rt in result_list] @@ -224,7 +213,7 @@ def test_positive_end_to_end_crud_and_list(): @pytest.mark.tier1 -def test_positive_generate_report_nofilter_and_with_filter(): +def test_positive_generate_report_nofilter_and_with_filter(module_target_sat): """Generate Host Status report without filter and with filter :id: 5af03399-b918-468a-9306-1c76dda6a369 @@ -243,10 +232,10 @@ def test_positive_generate_report_nofilter_and_with_filter(): :CaseImportance: Critical """ host_name = gen_alpha() - host1 = make_fake_host({'name': host_name}) + host1 = module_target_sat.cli_factory.make_fake_host({'name': host_name}) host_name_2 = gen_alpha() - host2 = make_fake_host({'name': host_name_2}) + host2 = module_target_sat.cli_factory.make_fake_host({'name': host_name_2}) result_list = ReportTemplate.list() assert 'Host - Statuses' in [rt['name'] for rt in result_list] @@ -270,7 +259,7 @@ def test_positive_generate_report_nofilter_and_with_filter(): @pytest.mark.tier2 -def test_positive_lock_and_unlock_report(): +def test_positive_lock_and_unlock_report(module_target_sat): """Lock and unlock report template :id: df306515-8798-4ce3-9430-6bc3bf9b9b33 @@ -287,7 +276,7 @@ def test_positive_lock_and_unlock_report(): :CaseImportance: Medium """ name = gen_alpha() - report_template = make_report_template({'name': name}) + report_template = module_target_sat.cli_factory.make_report_template({'name': name}) ReportTemplate.update({'name': report_template['name'], 'locked': 1}) new_name = gen_alpha() with pytest.raises(CLIReturnCodeError): @@ -299,7 +288,7 @@ def test_positive_lock_and_unlock_report(): @pytest.mark.tier2 -def test_positive_report_add_userinput(): +def test_positive_report_add_userinput(module_target_sat): """Add user input to template :id: 84b577db-144e-4761-a46e-e83887464986 @@ -314,9 +303,9 @@ def test_positive_report_add_userinput(): """ name = gen_alpha() - report_template = make_report_template({'name': name}) + report_template = module_target_sat.cli_factory.make_report_template({'name': name}) ti_name = gen_alpha() - template_input = make_template_input( + template_input = module_target_sat.cli_factory.make_template_input( {'name': ti_name, 'input-type': 'user', 'template-id': report_template['id']} ) result = ReportTemplate.info({'name': report_template['name']}) @@ -324,7 +313,7 @@ def test_positive_report_add_userinput(): @pytest.mark.tier2 -def test_positive_dump_report(): +def test_positive_dump_report(module_target_sat): """Export report template :id: 84b577db-144e-4761-a42e-a83887464986 @@ -341,13 +330,15 @@ def test_positive_dump_report(): """ name = gen_alpha() content = gen_alpha() - report_template = make_report_template({'name': name, 'content': content}) + report_template = module_target_sat.cli_factory.make_report_template( + {'name': name, 'content': content} + ) result = ReportTemplate.dump({'id': report_template['id']}) assert content in result @pytest.mark.tier2 -def test_positive_clone_locked_report(): +def test_positive_clone_locked_report(module_target_sat): """Clone locked report template :id: cc843731-b9c2-4fc9-9e15-d1ee5d967cda @@ -364,7 +355,7 @@ def test_positive_clone_locked_report(): """ name = gen_alpha() - report_template = make_report_template({'name': name}) + report_template = module_target_sat.cli_factory.make_report_template({'name': name}) ReportTemplate.update({'name': report_template['name'], 'locked': 1, 'default': 1}) new_name = gen_alpha() ReportTemplate.clone({'id': report_template['id'], 'new-name': new_name}) @@ -376,7 +367,7 @@ def test_positive_clone_locked_report(): @pytest.mark.tier2 -def test_positive_generate_report_sanitized(): +def test_positive_generate_report_sanitized(module_target_sat): """Generate report template where there are values in comma outputted which might brake CSV format @@ -395,10 +386,10 @@ def test_positive_generate_report_sanitized(): """ # create a name that has a comma in it, some randomized text, and no spaces. os_name = gen_alpha(start='test', separator=',').replace(' ', '') - architecture = make_architecture() - partition_table = make_partition_table() - medium = make_medium() - os = make_os( + architecture = module_target_sat.cli_factory.make_architecture() + partition_table = module_target_sat.cli_factory.make_partition_table() + medium = module_target_sat.cli_factory.make_medium() + os = module_target_sat.cli_factory.make_os( { 'name': os_name, 'architecture-ids': architecture['id'], @@ -408,7 +399,7 @@ def test_positive_generate_report_sanitized(): ) host_name = gen_alpha() - host = make_fake_host( + host = module_target_sat.cli_factory.make_fake_host( { 'name': host_name, 'architecture-id': architecture['id'], @@ -418,7 +409,9 @@ def test_positive_generate_report_sanitized(): } ) - report_template = make_report_template({'content': REPORT_TEMPLATE_FILE}) + report_template = module_target_sat.cli_factory.make_report_template( + {'content': REPORT_TEMPLATE_FILE} + ) result = ReportTemplate.generate({'name': report_template['name']}) assert 'Name,Operating System' in result # verify header of custom template @@ -494,7 +487,7 @@ def test_positive_generate_email_uncompressed(): @pytest.mark.tier2 -def test_negative_create_report_without_name(): +def test_negative_create_report_without_name(module_target_sat): """Try to create a report template with empty name :id: 84b577db-144e-4771-a42e-e93887464986 @@ -510,11 +503,11 @@ def test_negative_create_report_without_name(): :CaseImportance: Medium """ with pytest.raises(CLIFactoryError): - make_report_template({'name': ''}) + module_target_sat.cli_factory.make_report_template({'name': ''}) @pytest.mark.tier2 -def test_negative_delete_locked_report(): +def test_negative_delete_locked_report(module_target_sat): """Try to delete a locked report template :id: 84b577db-144e-4871-a42e-e93887464986 @@ -530,7 +523,7 @@ def test_negative_delete_locked_report(): :CaseImportance: Medium """ name = gen_alpha() - report_template = make_report_template({'name': name}) + report_template = module_target_sat.cli_factory.make_report_template({'name': name}) ReportTemplate.update({'name': report_template['name'], 'locked': 1}) @@ -539,7 +532,7 @@ def test_negative_delete_locked_report(): @pytest.mark.tier2 -def test_negative_bad_email(): +def test_negative_bad_email(module_target_sat): """Report can't be generated when incorrectly formed mail specified :id: a4ba77db-144e-4871-a42e-e93887464986 @@ -555,14 +548,14 @@ def test_negative_bad_email(): :CaseImportance: Medium """ name = gen_alpha() - report_template = make_report_template({'name': name}) + report_template = module_target_sat.cli_factory.make_report_template({'name': name}) with pytest.raises(CLIReturnCodeError): ReportTemplate.schedule({'name': report_template['name'], 'mail-to': gen_alpha()}) @pytest.mark.tier3 -def test_negative_nonauthor_of_report_cant_download_it(): +def test_negative_nonauthor_of_report_cant_download_it(module_target_sat): """The resulting report should only be downloadable by the user that generated it or admin. Check. @@ -584,7 +577,7 @@ def test_negative_nonauthor_of_report_cant_download_it(): loc = Location.info({'name': DEFAULT_LOC}) org = Org.info({'name': DEFAULT_ORG}) - user1 = make_user( + user1 = module_target_sat.cli_factory.make_user( { 'login': uname_viewer, 'password': password, @@ -593,7 +586,7 @@ def test_negative_nonauthor_of_report_cant_download_it(): } ) - user2 = make_user( + user2 = module_target_sat.cli_factory.make_user( { 'login': uname_viewer2, 'password': password, @@ -602,7 +595,7 @@ def test_negative_nonauthor_of_report_cant_download_it(): } ) - role = make_role() + role = module_target_sat.cli_factory.make_role() # Pick permissions by its resource type permissions_org = [ permission['name'] @@ -628,7 +621,7 @@ def test_negative_nonauthor_of_report_cant_download_it(): ] # Assign filters to created role for perm in [permissions_org, permissions_loc, permissions_rt, permissions_pt, permissions_jt]: - make_filter({'role-id': role['id'], 'permissions': perm}) + module_target_sat.cli_factory.make_filter({'role-id': role['id'], 'permissions': perm}) User.add_role({'login': user1['login'], 'role-id': role['id']}) User.add_role({'login': user2['login'], 'role-id': role['id']}) @@ -657,7 +650,7 @@ def test_negative_nonauthor_of_report_cant_download_it(): @pytest.mark.tier2 @pytest.mark.skip_if_open('BZ:1750924') -def test_positive_generate_with_name_and_org(): +def test_positive_generate_with_name_and_org(module_target_sat): """Generate Host Status report, specifying template name and organization :id: 5af03399-b918-468a-1306-1c76dda6f369 @@ -680,7 +673,7 @@ def test_positive_generate_with_name_and_org(): :BZ: 1750924 """ host_name = gen_alpha() - host = make_fake_host({'name': host_name}) + host = module_target_sat.cli_factory.make_fake_host({'name': host_name}) result = ReportTemplate.generate({'name': 'Host - Statuses', 'organization': DEFAULT_ORG}) @@ -689,7 +682,7 @@ def test_positive_generate_with_name_and_org(): @pytest.mark.tier2 @pytest.mark.skip_if_open('BZ:1782807') -def test_positive_generate_ansible_template(): +def test_positive_generate_ansible_template(module_target_sat): """Report template named 'Ansible Inventory' (default name is specified in settings) must be present in Satellite 6.7 and later in order to provide enhanced functionality for Ansible Tower inventory synchronization with Satellite. @@ -722,7 +715,7 @@ def test_positive_generate_ansible_template(): loc = Location.info({'name': DEFAULT_LOC}) org = Org.info({'name': DEFAULT_ORG}) - user = make_user( + user = module_target_sat.cli_factory.make_user( { 'login': login, 'password': password, @@ -734,7 +727,7 @@ def test_positive_generate_ansible_template(): User.add_role({'login': user['login'], 'role': 'Ansible Tower Inventory Reader'}) host_name = gen_alpha().lower() - host = make_fake_host({'name': host_name}) + host = module_target_sat.cli_factory.make_fake_host({'name': host_name}) schedule = ReportTemplate.with_user(username=user['login'], password=password).schedule( {'name': template_name} @@ -879,7 +872,7 @@ def test_positive_generate_hostpkgcompare( :BZ: 1860430 """ # Add subscription to Satellite Tools repo to activation key - setup_org_for_a_rh_repo( + target_sat.cli_factory.setup_org_for_a_rh_repo( { 'product': PRDS['rhel'], 'repository-set': REPOSET['rhst7'], @@ -890,7 +883,7 @@ def test_positive_generate_hostpkgcompare( 'activationkey-id': local_ak['id'], } ) - setup_org_for_a_custom_repo( + target_sat.cli_factory.setup_org_for_a_custom_repo( { 'url': settings.repos.yum_6.url, 'organization-id': module_entitlement_manifest_org.id, @@ -1021,7 +1014,7 @@ def test_positive_generate_installed_packages_report( :customerscenario: true """ - setup_org_for_a_custom_repo( + target_sat.cli_factory.setup_org_for_a_custom_repo( { 'url': settings.repos.yum_6.url, 'organization-id': module_entitlement_manifest_org.id, diff --git a/tests/foreman/cli/test_repository.py b/tests/foreman/cli/test_repository.py index 85a9d751bd4..31d6d7869e7 100644 --- a/tests/foreman/cli/test_repository.py +++ b/tests/foreman/cli/test_repository.py @@ -25,23 +25,9 @@ import requests from wait_for import wait_for -from robottelo.cli.base import CLIReturnCodeError from robottelo.cli.content_export import ContentExport from robottelo.cli.content_import import ContentImport from robottelo.cli.contentview import ContentView -from robottelo.cli.factory import ( - CLIFactoryError, - make_content_credential, - make_content_view, - make_filter, - make_lifecycle_environment, - make_location, - make_org, - make_product, - make_repository, - make_role, - make_user, -) from robottelo.cli.file import File from robottelo.cli.filter import Filter from robottelo.cli.module_stream import ModuleStream @@ -79,6 +65,7 @@ FAKE_YUM_MD5_REPO, FAKE_YUM_SRPM_REPO, ) +from robottelo.exceptions import CLIFactoryError, CLIReturnCodeError from robottelo.logging import logger from robottelo.utils.datafactory import ( invalid_values_list, @@ -136,15 +123,15 @@ def repo_options(request, module_org, module_product): @pytest.fixture -def repo(repo_options): +def repo(repo_options, target_sat): """create a new repository.""" - return make_repository(repo_options) + return target_sat.cli_factory.make_repository(repo_options) @pytest.fixture -def gpg_key(module_org): +def gpg_key(module_org, module_target_sat): """Create a new GPG key.""" - return make_content_credential({'organization-id': module_org.id}) + return module_target_sat.cli_factory.make_content_credential({'organization-id': module_org.id}) class TestRepository: @@ -413,7 +400,7 @@ def test_positive_create_on_demand_update_to_immediate(self, repo_options, repo) @pytest.mark.tier1 @pytest.mark.upgrade - def test_positive_create_with_gpg_key_by_id(self, repo_options, gpg_key): + def test_positive_create_with_gpg_key_by_id(self, repo_options, gpg_key, target_sat): """Check if repository can be created with gpg key ID :id: 6d22f0ea-2d27-4827-9b7a-3e1550a47285 @@ -425,7 +412,7 @@ def test_positive_create_with_gpg_key_by_id(self, repo_options, gpg_key): :CaseImportance: Critical """ repo_options['gpg-key-id'] = gpg_key['id'] - repo = make_repository(repo_options) + repo = target_sat.cli_factory.make_repository(repo_options) assert repo['gpg-key']['id'] == gpg_key['id'] assert repo['gpg-key']['name'] == gpg_key['name'] @@ -590,14 +577,14 @@ def test_positive_create_repo_with_new_organization_and_location(self, target_sa :CaseImportance: High """ - new_org = make_org() - new_location = make_location() - new_product = make_product( + new_org = target_sat.cli_factory.make_org() + new_location = target_sat.cli_factory.make_location() + new_product = target_sat.cli_factory.make_product( {'organization-id': new_org['id'], 'description': 'test_product'} ) Org.add_location({'location-id': new_location['id'], 'name': new_org['name']}) assert new_location['name'] in Org.info({'id': new_org['id']})['locations'] - make_repository( + target_sat.cli_factory.make_repository( { 'location-id': new_location['id'], 'organization-id': new_org['id'], @@ -617,7 +604,7 @@ def test_positive_create_repo_with_new_organization_and_location(self, target_sa **parametrized([{'name': name} for name in invalid_values_list()]), indirect=True, ) - def test_negative_create_with_name(self, repo_options): + def test_negative_create_with_name(self, repo_options, target_sat): """Repository name cannot be 300-characters long :id: af0652d3-012d-4846-82ac-047918f74722 @@ -629,7 +616,7 @@ def test_negative_create_with_name(self, repo_options): :CaseImportance: Critical """ with pytest.raises(CLIFactoryError): - make_repository(repo_options) + target_sat.cli_factory.make_repository(repo_options) @pytest.mark.tier1 @pytest.mark.parametrize( @@ -637,7 +624,9 @@ def test_negative_create_with_name(self, repo_options): **parametrized([{'url': f'http://{gen_string("alpha")}{punctuation}.com'}]), indirect=True, ) - def test_negative_create_with_url_with_special_characters(self, repo_options): + def test_negative_create_with_url_with_special_characters( + self, repo_options, module_target_sat + ): """Verify that repository URL cannot contain unquoted special characters :id: 2bd5ee17-0fe5-43cb-9cdc-dc2178c5374c @@ -649,7 +638,7 @@ def test_negative_create_with_url_with_special_characters(self, repo_options): :CaseImportance: Critical """ with pytest.raises(CLIFactoryError): - make_repository(repo_options) + module_target_sat.cli_factory.make_repository(repo_options) @pytest.mark.tier1 @pytest.mark.parametrize( @@ -657,7 +646,7 @@ def test_negative_create_with_url_with_special_characters(self, repo_options): **parametrized([{'content-type': 'yum', 'download-policy': gen_string('alpha', 5)}]), indirect=True, ) - def test_negative_create_with_invalid_download_policy(self, repo_options): + def test_negative_create_with_invalid_download_policy(self, repo_options, module_target_sat): """Verify that YUM repository cannot be created with invalid download policy @@ -671,7 +660,7 @@ def test_negative_create_with_invalid_download_policy(self, repo_options): :CaseImportance: Critical """ with pytest.raises(CLIFactoryError): - make_repository(repo_options) + module_target_sat.cli_factory.make_repository(repo_options) @pytest.mark.tier1 @pytest.mark.parametrize( @@ -706,7 +695,7 @@ def test_negative_update_to_invalid_download_policy(self, repo_options, repo): ), indirect=True, ) - def test_negative_create_non_yum_with_download_policy(self, repo_options): + def test_negative_create_non_yum_with_download_policy(self, repo_options, module_target_sat): """Verify that non-YUM repositories cannot be created with download policy TODO: Remove ostree from exceptions when ostree is added back in Satellite 7 @@ -725,7 +714,7 @@ def test_negative_create_non_yum_with_download_policy(self, repo_options): CLIFactoryError, match='Download policy Cannot set attribute download_policy for content type', ): - make_repository(repo_options) + module_target_sat.cli_factory.make_repository(repo_options) @pytest.mark.tier1 @pytest.mark.parametrize( @@ -1177,7 +1166,7 @@ def test_positive_resynchronize_rpm_repo(self, repo): ), ) @pytest.mark.tier2 - def test_mirror_on_sync_removes_rpm(self, module_org, repo, repo_options_2): + def test_mirror_on_sync_removes_rpm(self, module_org, repo, repo_options_2, module_target_sat): """ Check that a package removed upstream is removed downstream when the repo is next synced if mirror-on-sync is enabled (the default setting). @@ -1212,11 +1201,13 @@ def test_mirror_on_sync_removes_rpm(self, module_org, repo, repo_options_2): assert repo['sync']['status'] == 'Success' assert repo['content-counts']['packages'] == '32' # Make 2nd repo - prod_2 = make_product({'organization-id': module_org.id, 'description': 'Downstream'}) + prod_2 = module_target_sat.cli_factory.make_product( + {'organization-id': module_org.id, 'description': 'Downstream'} + ) repo_options_2['organization-id'] = module_org.id repo_options_2['product-id'] = prod_2['id'] repo_options_2['url'] = repo.get('published-at') - repo_2 = make_repository(repo_options_2) + repo_2 = module_target_sat.cli_factory.make_repository(repo_options_2) Repository.update({'id': repo_2['id'], 'description': ['Downstream']}) repo_2 = Repository.info({'id': repo_2['id']}) Repository.synchronize({'id': repo_2['id']}) @@ -1311,7 +1302,7 @@ def test_negative_update_url_with_special_characters(self, new_repo_options, rep assert result['url'] == repo['url'] @pytest.mark.tier1 - def test_positive_update_gpg_key(self, repo_options, module_org, repo, gpg_key): + def test_positive_update_gpg_key(self, repo_options, module_org, repo, gpg_key, target_sat): """Update the original gpg key :id: 367ff375-4f52-4a8c-b974-8c1c54e3fdd3 @@ -1324,7 +1315,9 @@ def test_positive_update_gpg_key(self, repo_options, module_org, repo, gpg_key): """ Repository.update({'id': repo['id'], 'gpg-key-id': gpg_key['id']}) - gpg_key_new = make_content_credential({'organization-id': module_org.id}) + gpg_key_new = target_sat.cli_factory.make_content_credential( + {'organization-id': module_org.id} + ) Repository.update({'id': repo['id'], 'gpg-key-id': gpg_key_new['id']}) result = Repository.info({'id': repo['id']}) assert result['gpg-key']['id'] == gpg_key_new['id'] @@ -1408,7 +1401,7 @@ def test_positive_update_checksum_type(self, repo_options, repo, checksum_type): ), indirect=True, ) - def test_negative_create_checksum_with_on_demand_policy(self, repo_options): + def test_negative_create_checksum_with_on_demand_policy(self, repo_options, module_target_sat): """Attempt to create repository with checksum and on_demand policy. :id: 33d712e6-e91f-42bb-8c5d-35bdc427182c @@ -1422,7 +1415,7 @@ def test_negative_create_checksum_with_on_demand_policy(self, repo_options): :BZ: 1732056 """ with pytest.raises(CLIFactoryError): - make_repository(repo_options) + module_target_sat.cli_factory.make_repository(repo_options) @pytest.mark.tier1 @pytest.mark.parametrize( @@ -1662,7 +1655,7 @@ def test_positive_upload_content_to_file_repo(self, repo, target_sat): **parametrized([{'content-type': 'yum', 'url': settings.repos.yum_1.url}]), indirect=True, ) - def test_negative_restricted_user_cv_add_repository(self, module_org, repo): + def test_negative_restricted_user_cv_add_repository(self, module_org, repo, module_target_sat): """Attempt to add a product repository to content view with a restricted user, using product name not visible to restricted user. @@ -1731,7 +1724,7 @@ def test_negative_restricted_user_cv_add_repository(self, module_org, repo): content_view_name = f"Test_{gen_string('alpha', 20)}" # Create a non admin user, for the moment without any permissions - user = make_user( + user = module_target_sat.cli_factory.make_user( { 'admin': False, 'default-organization-id': module_org.id, @@ -1741,7 +1734,7 @@ def test_negative_restricted_user_cv_add_repository(self, module_org, repo): } ) # Create a new role - role = make_role() + role = module_target_sat.cli_factory.make_role() # Get the available permissions available_permissions = Filter.available_permissions() # group the available permissions by resource type @@ -1764,7 +1757,9 @@ def test_negative_restricted_user_cv_add_repository(self, module_org, repo): # assert that all the required permissions are available assert set(permission_names) == set(available_permission_names) # Create the current resource type role permissions - make_filter({'role-id': role['id'], 'permissions': permission_names, 'search': search}) + module_target_sat.cli_factory.make_filter( + {'role-id': role['id'], 'permissions': permission_names, 'search': search} + ) # Add the created and initiated role with permissions to user User.add_role({'id': user['id'], 'role-id': role['id']}) # assert that the user is not an admin one and cannot read the current @@ -1778,7 +1773,7 @@ def test_negative_restricted_user_cv_add_repository(self, module_org, repo): Repository.synchronize({'id': repo['id']}) # Create a content view - content_view = make_content_view( + content_view = module_target_sat.cli_factory.make_content_view( {'organization-id': module_org.id, 'name': content_view_name} ) # assert that the user can read the content view info as per required @@ -1951,7 +1946,7 @@ def test_positive_srpm_list_end_to_end(self, repo, target_sat): indirect=True, ) def test_positive_create_get_update_delete_module_streams( - self, repo_options, module_org, module_product, repo + self, repo_options, module_org, module_product, repo, module_target_sat ): """Check module-stream get for each create, get, update, delete. @@ -1987,7 +1982,7 @@ def test_positive_create_get_update_delete_module_streams( ), 'Module Streams not synced correctly' # adding repo with same yum url should not change count. - duplicate_repo = make_repository(repo_options) + duplicate_repo = module_target_sat.cli_factory.make_repository(repo_options) Repository.synchronize({'id': duplicate_repo['id']}) module_streams = ModuleStream.list({'organization-id': module_org.id}) @@ -2019,7 +2014,9 @@ def test_positive_create_get_update_delete_module_streams( 'repo_options_2', **parametrized([{'content-type': 'yum', 'url': settings.repos.module_stream_1.url}]), ) - def test_module_stream_list_validation(self, module_org, repo, repo_options_2): + def test_module_stream_list_validation( + self, module_org, repo, repo_options_2, module_target_sat + ): """Check module-stream get with list on hammer. :id: 9842a0c3-8532-4b16-a00a-534fc3b0a776ff89f23e-cd00-4d20-84d3-add0ea24abf8 @@ -2040,10 +2037,10 @@ def test_module_stream_list_validation(self, module_org, repo, repo_options_2): """ Repository.synchronize({'id': repo['id']}) - prod_2 = make_product({'organization-id': module_org.id}) + prod_2 = module_target_sat.cli_factory.make_product({'organization-id': module_org.id}) repo_options_2['organization-id'] = module_org.id repo_options_2['product-id'] = prod_2['id'] - repo_2 = make_repository(repo_options_2) + repo_2 = module_target_sat.cli_factory.make_repository(repo_options_2) Repository.synchronize({'id': repo_2['id']}) module_streams = ModuleStream.list() @@ -2164,7 +2161,7 @@ def test_positive_accessible_content_status( **parametrized([{'content_type': 'yum', 'url': CUSTOM_RPM_SHA}]), indirect=True, ) - def test_positive_sync_sha_repo(self, repo_options): + def test_positive_sync_sha_repo(self, repo_options, module_target_sat): """Sync a 'sha' repo successfully :id: 20579f52-a67b-4d3f-be07-41eec059a891 @@ -2177,7 +2174,7 @@ def test_positive_sync_sha_repo(self, repo_options): :SubComponent: Candlepin """ - sha_repo = make_repository(repo_options) + sha_repo = module_target_sat.cli_factory.make_repository(repo_options) sha_repo = Repository.info({'id': sha_repo['id']}) Repository.synchronize({'id': sha_repo['id']}) sha_repo = Repository.info({'id': sha_repo['id']}) @@ -2189,7 +2186,7 @@ def test_positive_sync_sha_repo(self, repo_options): **parametrized([{'content_type': 'yum', 'url': CUSTOM_3RD_PARTY_REPO}]), indirect=True, ) - def test_positive_sync_third_party_repo(self, repo_options): + def test_positive_sync_third_party_repo(self, repo_options, module_target_sat): """Sync third party repo successfully :id: 45936ab8-46b7-4f07-8b71-d7c8a4a2d984 @@ -2202,7 +2199,7 @@ def test_positive_sync_third_party_repo(self, repo_options): :SubComponent: Pulp """ - repo = make_repository(repo_options) + repo = module_target_sat.cli_factory.make_repository(repo_options) repo = Repository.info({'id': repo['id']}) Repository.synchronize({'id': repo['id']}) repo = Repository.info({'id': repo['id']}) @@ -2437,7 +2434,7 @@ def test_positive_sync_publish_cv(self, module_org, module_product, repo, target :expectedresults: srpms can be listed in content view """ Repository.synchronize({'id': repo['id']}) - cv = make_content_view({'organization-id': module_org.id}) + cv = target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) ContentView.add_repository({'id': cv['id'], 'repository-id': repo['id']}) ContentView.publish({'id': cv['id']}) result = target_sat.execute( @@ -2465,9 +2462,9 @@ def test_positive_sync_publish_promote_cv(self, repo, module_org, module_product :expectedresults: srpms can be listed in content view in proper lifecycle environment """ - lce = make_lifecycle_environment({'organization-id': module_org.id}) + lce = target_sat.cli_factory.make_lifecycle_environment({'organization-id': module_org.id}) Repository.synchronize({'id': repo['id']}) - cv = make_content_view({'organization-id': module_org.id}) + cv = target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) ContentView.add_repository({'id': cv['id'], 'repository-id': repo['id']}) ContentView.publish({'id': cv['id']}) content_view = ContentView.info({'id': cv['id']}) @@ -2555,7 +2552,7 @@ def test_positive_export_ansible_collection(self, repo, module_org, module_produ :CaseImportance: High """ - import_org = make_org() + import_org = target_sat.cli_factory.make_org() Repository.synchronize({'id': repo['id']}) repo = Repository.info({'id': repo['id']}) assert repo['sync']['status'] == 'Success' @@ -2609,16 +2606,16 @@ def test_positive_sync_ansible_collection_from_satellite( :CaseImportance: High """ - import_org = make_org() + import_org = target_sat.cli_factory.make_org() Repository.synchronize({'id': repo['id']}) repo = Repository.info({'id': repo['id']}) assert repo['sync']['status'] == 'Success' published_url = repo['published-at'] # sync from different org - prod_2 = make_product( + prod_2 = target_sat.cli_factory.make_product( {'organization-id': import_org['id'], 'description': 'Sync from Satellite'} ) - repo_2 = make_repository( + repo_2 = target_sat.cli_factory.make_repository( { 'organization-id': import_org['id'], 'product-id': prod_2['id'], @@ -2652,12 +2649,12 @@ def test_positive_sync_publish_promote_cv(self, repo, module_org, module_product :expectedresults: rpms can be listed in content view in proper lifecycle environment """ - lce = make_lifecycle_environment({'organization-id': module_org.id}) + lce = target_sat.cli_factory.make_lifecycle_environment({'organization-id': module_org.id}) Repository.synchronize({'id': repo['id']}) synced_repo = Repository.info({'id': repo['id']}) assert synced_repo['sync']['status'].lower() == 'success' assert synced_repo['content-counts']['packages'] == '35' - cv = make_content_view({'organization-id': module_org.id}) + cv = target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) ContentView.add_repository({'id': cv['id'], 'repository-id': repo['id']}) ContentView.publish({'id': cv['id']}) content_view = ContentView.info({'id': cv['id']}) @@ -2710,7 +2707,7 @@ def test_positive_sync_publish_cv(self, repo, module_org, module_product, target :expectedresults: drpms can be listed in content view """ Repository.synchronize({'id': repo['id']}) - cv = make_content_view({'organization-id': module_org.id}) + cv = target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) ContentView.add_repository({'id': cv['id'], 'repository-id': repo['id']}) ContentView.publish({'id': cv['id']}) result = target_sat.execute( @@ -2737,9 +2734,9 @@ def test_positive_sync_publish_promote_cv(self, repo, module_org, module_product :expectedresults: drpms can be listed in content view in proper lifecycle environment """ - lce = make_lifecycle_environment({'organization-id': module_org.id}) + lce = target_sat.cli_factory.make_lifecycle_environment({'organization-id': module_org.id}) Repository.synchronize({'id': repo['id']}) - cv = make_content_view({'organization-id': module_org.id}) + cv = target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) ContentView.add_repository({'id': cv['id'], 'repository-id': repo['id']}) ContentView.publish({'id': cv['id']}) content_view = ContentView.info({'id': cv['id']}) diff --git a/tests/foreman/cli/test_role.py b/tests/foreman/cli/test_role.py index feeb1c928be..057089acfd0 100644 --- a/tests/foreman/cli/test_role.py +++ b/tests/foreman/cli/test_role.py @@ -23,19 +23,12 @@ from fauxfactory import gen_string import pytest -from robottelo.cli.base import CLIDataBaseError, CLIReturnCodeError -from robottelo.cli.factory import ( - make_filter, - make_location, - make_org, - make_role, - make_user, -) from robottelo.cli.filter import Filter from robottelo.cli.role import Role from robottelo.cli.settings import Settings from robottelo.cli.user import User from robottelo.constants import PERMISSIONS, ROLES +from robottelo.exceptions import CLIDataBaseError, CLIReturnCodeError from robottelo.utils.datafactory import generate_strings_list, parametrized @@ -49,7 +42,7 @@ class TestRole: list(zip(generate_strings_list(length=10), generate_strings_list(length=10))) ), ) - def test_positive_crud_with_name(self, name, new_name): + def test_positive_crud_with_name(self, name, new_name, module_target_sat): """Create new role with provided name, update name and delete role by ID :id: f77b8e84-e964-4007-b12b-142949134d8b @@ -63,7 +56,7 @@ def test_positive_crud_with_name(self, name, new_name): :CaseImportance: Critical """ - role = make_role({'name': name}) + role = module_target_sat.cli_factory.make_role({'name': name}) assert role['name'] == name Role.update({'id': role['id'], 'new-name': new_name}) role = Role.info({'id': role['id']}) @@ -74,7 +67,7 @@ def test_positive_crud_with_name(self, name, new_name): @pytest.mark.tier1 @pytest.mark.upgrade - def test_positive_create_with_permission(self): + def test_positive_create_with_permission(self, module_target_sat): """Create new role with a set of permission :id: 7cb2b2e2-ad4d-41e9-b6b2-c0366eb09b9a @@ -83,18 +76,20 @@ def test_positive_create_with_permission(self): :CaseImportance: Critical """ - role = make_role() + role = module_target_sat.cli_factory.make_role() # Pick permissions by its resource type permissions = [ permission['name'] for permission in Filter.available_permissions({"search": "resource_type=Organization"}) ] # Assign filter to created role - make_filter({'role-id': role['id'], 'permissions': permissions}) + module_target_sat.cli_factory.make_filter( + {'role-id': role['id'], 'permissions': permissions} + ) assert set(Role.filters({'id': role['id']})[0]['permissions']) == set(permissions) @pytest.mark.tier1 - def test_positive_list_filters_by_id(self): + def test_positive_list_filters_by_id(self, module_target_sat): """Create new role with a filter and list it by role id :id: 6979ad8d-629b-481e-9d3a-8f3b3bca53f9 @@ -103,19 +98,21 @@ def test_positive_list_filters_by_id(self): :CaseImportance: Critical """ - role = make_role() + role = module_target_sat.cli_factory.make_role() # Pick permissions by its resource type permissions = [ permission['name'] for permission in Filter.available_permissions({"search": "resource_type=Organization"}) ] # Assign filter to created role - filter_ = make_filter({'role-id': role['id'], 'permissions': permissions}) + filter_ = module_target_sat.cli_factory.make_filter( + {'role-id': role['id'], 'permissions': permissions} + ) assert role['name'] == filter_['role'] assert Role.filters({'id': role['id']})[0]['id'] == filter_['id'] @pytest.mark.tier1 - def test_positive_list_filters_by_name(self): + def test_positive_list_filters_by_name(self, module_target_sat): """Create new role with a filter and list it by role name :id: bbcb3982-f484-4dde-a3ea-7145fd28ab1f @@ -124,14 +121,16 @@ def test_positive_list_filters_by_name(self): :CaseImportance: Critical """ - role = make_role() + role = module_target_sat.cli_factory.make_role() # Pick permissions by its resource type permissions = [ permission['name'] for permission in Filter.available_permissions({"search": "resource_type=Organization"}) ] # Assign filter to created role - filter_ = make_filter({'role': role['name'], 'permissions': permissions}) + filter_ = module_target_sat.cli_factory.make_filter( + {'role': role['name'], 'permissions': permissions} + ) assert role['name'] == filter_['role'] assert Role.filters({'name': role['name']})[0]['id'] == filter_['id'] @@ -155,9 +154,9 @@ def test_negative_list_filters_without_parameters(self): assert re.search('At least one of options .* is required', err.value.msg) @pytest.fixture() - def make_role_with_permissions(self): + def make_role_with_permissions(self, target_sat): """Create new role with a filter""" - role = make_role() + role = target_sat.cli_factory.make_role() res_types = iter(PERMISSIONS.keys()) permissions = [] # Collect more than 20 different permissions @@ -170,7 +169,7 @@ def make_role_with_permissions(self): ] # Create a filter for each permission for perm in permissions: - make_filter({'role': role['name'], 'permissions': perm}) + target_sat.cli_factory.make_filter({'role': role['name'], 'permissions': perm}) return { 'role': role, 'permissions': permissions, @@ -249,7 +248,7 @@ def tearDown(self): @pytest.mark.upgrade @pytest.mark.tier3 @pytest.mark.e2e - def test_system_admin_role_end_to_end(self): + def test_system_admin_role_end_to_end(self, target_sat): """Test System admin role with a end to end workflow :id: da6b3549-d1cf-44fc-869f-08d15d407fa2 @@ -277,11 +276,11 @@ def test_system_admin_role_end_to_end(self): :CaseLevel: System """ - org = make_org() - location = make_location() + org = target_sat.cli_factory.make_org() + location = target_sat.cli_factory.make_location() common_pass = gen_string('alpha') role = Role.info({'name': 'System admin'}) - system_admin_1 = make_user( + system_admin_1 = target_sat.cli_factory.make_user( { 'password': common_pass, 'organization-ids': org['id'], diff --git a/tests/foreman/cli/test_satellitesync.py b/tests/foreman/cli/test_satellitesync.py index d5a5cfdf9f6..5a818f4d7b9 100644 --- a/tests/foreman/cli/test_satellitesync.py +++ b/tests/foreman/cli/test_satellitesync.py @@ -22,16 +22,9 @@ from manifester import Manifester import pytest -from robottelo.cli.base import CLIReturnCodeError from robottelo.cli.content_export import ContentExport from robottelo.cli.content_import import ContentImport from robottelo.cli.contentview import ContentView -from robottelo.cli.factory import ( - make_content_view, - make_org, - make_product, - make_repository, -) from robottelo.cli.package import Package from robottelo.cli.product import Product from robottelo.cli.repository import Repository @@ -48,6 +41,7 @@ REPOS, ) from robottelo.constants.repos import ANSIBLE_GALAXY +from robottelo.exceptions import CLIReturnCodeError @pytest.fixture(scope='class') @@ -100,8 +94,8 @@ def function_import_org_with_manifest(target_sat, function_import_org): @pytest.fixture(scope='class') def docker_repo(module_target_sat, module_org): - product = make_product({'organization-id': module_org.id}) - repo = make_repository( + product = module_target_sat.cli_factory.make_product({'organization-id': module_org.id}) + repo = module_target_sat.cli_factory.make_repository( { 'organization-id': module_org.id, 'product-id': product['id'], @@ -322,7 +316,9 @@ def test_positive_export_complete_library_rh_repo( """ # Create cv and publish cv_name = gen_string('alpha') - cv = make_content_view({'name': cv_name, 'organization-id': function_sca_manifest_org.id}) + cv = target_sat.cli_factory.make_content_view( + {'name': cv_name, 'organization-id': function_sca_manifest_org.id} + ) ContentView.add_repository( { 'id': cv['id'], @@ -399,7 +395,9 @@ def test_positive_export_version_docker( """ # Create CV and publish cv_name = gen_string('alpha') - cv = make_content_view({'name': cv_name, 'organization-id': module_org.id}) + cv = target_sat.cli_factory.make_content_view( + {'name': cv_name, 'organization-id': module_org.id} + ) target_sat.cli.ContentView.add_repository( { 'id': cv['id'], @@ -430,12 +428,14 @@ def test_positive_export_version_docker( @pytest.fixture(scope='class') -def class_export_entities(module_org): +def class_export_entities(module_org, module_target_sat): """Setup custom repos for export""" exporting_prod_name = gen_string('alpha') - product = make_product({'organization-id': module_org.id, 'name': exporting_prod_name}) + product = module_target_sat.cli_factory.make_product( + {'organization-id': module_org.id, 'name': exporting_prod_name} + ) exporting_repo_name = gen_string('alpha') - exporting_repo = make_repository( + exporting_repo = module_target_sat.cli_factory.make_repository( { 'name': exporting_repo_name, 'mirror-on-sync': 'no', @@ -457,7 +457,7 @@ def class_export_entities(module_org): } -def _create_cv(cv_name, repo, module_org, publish=True): +def _create_cv(cv_name, repo, module_org, module_target_sat, publish=True): """Creates CV and/or publishes in organization with given name and repository :param cv_name: The name of CV to create @@ -467,7 +467,7 @@ def _create_cv(cv_name, repo, module_org, publish=True): :return: The directory of CV and Content View ID """ description = gen_string('alpha') - content_view = make_content_view( + content_view = module_target_sat.cli_factory.make_content_view( {'name': cv_name, 'description': description, 'organization-id': module_org.id} ) ContentView.add_repository( @@ -486,7 +486,7 @@ def _create_cv(cv_name, repo, module_org, publish=True): return content_view, cvv_id -def _import_entities(product, repo, cv, mos='no'): +def _import_entities(product, repo, cv, sat, mos='no'): """Sets same CV, product and repository in importing organization as exporting organization @@ -496,9 +496,11 @@ def _import_entities(product, repo, cv, mos='no'): :param str mos: Mirror on Sync repo, by default 'no' can override to 'yes' :returns dictionary with CLI entities created in this function """ - importing_org = make_org() - importing_prod = make_product({'organization-id': importing_org['id'], 'name': product}) - importing_repo = make_repository( + importing_org = sat.cli_factory.make_org() + importing_prod = sat.cli_factory.make_product( + {'organization-id': importing_org['id'], 'name': product} + ) + importing_repo = sat.cli_factory.make_repository( { 'name': repo, 'mirror-on-sync': mos, @@ -506,7 +508,9 @@ def _import_entities(product, repo, cv, mos='no'): 'product-id': importing_prod['id'], } ) - importing_cv = make_content_view({'name': cv, 'organization-id': importing_org['id']}) + importing_cv = sat.cli_factory.make_content_view( + {'name': cv, 'organization-id': importing_org['id']} + ) ContentView.add_repository( { 'id': importing_cv['id'], @@ -791,7 +795,7 @@ def test_positive_export_import_filtered_cvv( import_path = target_sat.move_pulp_archive(module_org, export['message']) # Import section - importing_org = make_org() + importing_org = target_sat.cli_factory.make_org() # set disconnected mode Settings.set({'name': 'subscription_connection_enabled', 'value': "No"}) # check that files are present in import_path @@ -1195,13 +1199,13 @@ def test_postive_export_cv_with_mixed_content_repos( :customerscenario: true """ - product = make_product( + product = target_sat.cli_factory.make_product( { 'organization-id': module_org.id, 'name': gen_string('alpha'), } ) - nonyum_repo = make_repository( + nonyum_repo = target_sat.cli_factory.make_repository( { 'content-type': 'docker', 'docker-upstream-name': 'quay/busybox', @@ -1211,7 +1215,7 @@ def test_postive_export_cv_with_mixed_content_repos( }, ) Repository.synchronize({'id': nonyum_repo['id']}) - yum_repo = make_repository( + yum_repo = target_sat.cli_factory.make_repository( { 'name': gen_string('alpha'), 'download-policy': 'immediate', @@ -1220,7 +1224,7 @@ def test_postive_export_cv_with_mixed_content_repos( } ) Repository.synchronize({'id': yum_repo['id']}) - content_view = make_content_view({'organization-id': module_org.id}) + content_view = target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) # Add docker and yum repo ContentView.add_repository( { diff --git a/tests/foreman/cli/test_settings.py b/tests/foreman/cli/test_settings.py index 3a47b6500a5..27d3d7a5756 100644 --- a/tests/foreman/cli/test_settings.py +++ b/tests/foreman/cli/test_settings.py @@ -21,9 +21,9 @@ import pytest -from robottelo.cli.base import CLIReturnCodeError from robottelo.cli.settings import Settings from robottelo.config import settings +from robottelo.exceptions import CLIReturnCodeError from robottelo.utils.datafactory import ( gen_string, generate_strings_list, diff --git a/tests/foreman/cli/test_subnet.py b/tests/foreman/cli/test_subnet.py index 6dc36a640f7..6bb3353acb6 100644 --- a/tests/foreman/cli/test_subnet.py +++ b/tests/foreman/cli/test_subnet.py @@ -22,10 +22,9 @@ from fauxfactory import gen_choice, gen_integer, gen_ipaddr import pytest -from robottelo.cli.base import CLIReturnCodeError -from robottelo.cli.factory import CLIFactoryError, make_domain, make_subnet from robottelo.cli.subnet import Subnet from robottelo.constants import SUBNET_IPAM_TYPES +from robottelo.exceptions import CLIFactoryError, CLIReturnCodeError from robottelo.utils.datafactory import ( filtered_datapoint, parametrized, @@ -72,7 +71,7 @@ def invalid_missing_attributes(): @pytest.mark.tier1 @pytest.mark.upgrade -def test_positive_CRUD(): +def test_positive_CRUD(module_target_sat): """Create, update and delete subnet :id: d74a52a7-df56-44ef-89a3-081c14e81e43 @@ -89,10 +88,10 @@ def test_positive_CRUD(): from_ip = re.sub(r'\d+$', str(pool[0]), network) to_ip = re.sub(r'\d+$', str(pool[1]), network) domains_amount = random.randint(2, 3) - domains = [make_domain() for _ in range(domains_amount)] + domains = [module_target_sat.cli_factory.make_domain() for _ in range(domains_amount)] gateway = gen_ipaddr(ip3=True) ipam_type = SUBNET_IPAM_TYPES['dhcp'] - subnet = make_subnet( + subnet = module_target_sat.cli_factory.make_subnet( { 'name': name, 'from': from_ip, @@ -153,7 +152,7 @@ def test_positive_CRUD(): @pytest.mark.tier2 @pytest.mark.parametrize('options', **parametrized(invalid_missing_attributes())) -def test_negative_create_with_attributes(options): +def test_negative_create_with_attributes(options, module_target_sat): """Create subnet with invalid or missing required attributes :id: de468dd3-7ba8-463e-881a-fd1cb3cfc7b6 @@ -165,13 +164,13 @@ def test_negative_create_with_attributes(options): :CaseImportance: Medium """ with pytest.raises(CLIFactoryError, match='Could not create the subnet:'): - make_subnet(options) + module_target_sat.cli_factory.make_subnet(options) @pytest.mark.tier2 @pytest.mark.upgrade @pytest.mark.parametrize('pool', **parametrized(invalid_addr_pools())) -def test_negative_create_with_address_pool(pool): +def test_negative_create_with_address_pool(pool, module_target_sat): """Create subnet with invalid address pool range :parametrized: yes @@ -189,13 +188,13 @@ def test_negative_create_with_address_pool(pool): for key, val in pool.items(): opts[key] = re.sub(r'\d+$', str(val), network) with pytest.raises(CLIFactoryError) as raise_ctx: - make_subnet(opts) + module_target_sat.cli_factory.make_subnet(opts) assert 'Could not create the subnet:' in str(raise_ctx.value) @pytest.mark.tier2 @pytest.mark.parametrize('options', **parametrized(invalid_missing_attributes())) -def test_negative_update_attributes(options): +def test_negative_update_attributes(options, module_target_sat): """Update subnet with invalid or missing required attributes :parametrized: yes @@ -206,7 +205,7 @@ def test_negative_update_attributes(options): :CaseImportance: Medium """ - subnet = make_subnet() + subnet = module_target_sat.cli_factory.make_subnet() options['id'] = subnet['id'] with pytest.raises(CLIReturnCodeError, match='Could not update the subnet:'): Subnet.update(options) @@ -218,7 +217,7 @@ def test_negative_update_attributes(options): @pytest.mark.tier2 @pytest.mark.parametrize('options', **parametrized(invalid_addr_pools())) -def test_negative_update_address_pool(options): +def test_negative_update_address_pool(options, module_target_sat): """Update subnet with invalid address pool :parametrized: yes @@ -229,7 +228,7 @@ def test_negative_update_address_pool(options): :CaseImportance: Medium """ - subnet = make_subnet() + subnet = module_target_sat.cli_factory.make_subnet() opts = {'id': subnet['id']} # generate pool range from network address for key, val in options.items(): diff --git a/tests/foreman/cli/test_subscription.py b/tests/foreman/cli/test_subscription.py index d6feeb1381d..561b9d7061f 100644 --- a/tests/foreman/cli/test_subscription.py +++ b/tests/foreman/cli/test_subscription.py @@ -20,23 +20,24 @@ from nailgun import entities import pytest -from robottelo.cli.base import CLIReturnCodeError -from robottelo.cli.factory import make_activation_key, make_product, make_repository from robottelo.cli.host import Host from robottelo.cli.repository import Repository from robottelo.cli.repository_set import RepositorySet from robottelo.cli.subscription import Subscription from robottelo.constants import PRDS, REPOS, REPOSET +from robottelo.exceptions import CLIReturnCodeError pytestmark = [pytest.mark.run_in_one_thread] @pytest.fixture(scope='module') -def golden_ticket_host_setup(request, module_sca_manifest_org): - new_product = make_product({'organization-id': module_sca_manifest_org.id}) - new_repo = make_repository({'product-id': new_product['id']}) +def golden_ticket_host_setup(request, module_sca_manifest_org, module_target_sat): + new_product = module_target_sat.cli_factory.make_product( + {'organization-id': module_sca_manifest_org.id} + ) + new_repo = module_target_sat.cli_factory.make_repository({'product-id': new_product['id']}) Repository.synchronize({'id': new_repo['id']}) - new_ak = make_activation_key( + new_ak = module_target_sat.cli_factory.make_activation_key( { 'lifecycle-environment': 'Library', 'content-view': 'Default Organization View', diff --git a/tests/foreman/cli/test_syncplan.py b/tests/foreman/cli/test_syncplan.py index c22dcbe198e..64987ef8cd6 100644 --- a/tests/foreman/cli/test_syncplan.py +++ b/tests/foreman/cli/test_syncplan.py @@ -23,18 +23,12 @@ from nailgun import entities import pytest -from robottelo.cli.base import CLIReturnCodeError -from robottelo.cli.factory import ( - CLIFactoryError, - make_product, - make_repository, - make_sync_plan, -) from robottelo.cli.product import Product from robottelo.cli.repository import Repository from robottelo.cli.repository_set import RepositorySet from robottelo.cli.syncplan import SyncPlan from robottelo.constants import PRDS, REPOS, REPOSET +from robottelo.exceptions import CLIFactoryError, CLIReturnCodeError from robottelo.logging import logger from robottelo.utils.datafactory import ( filtered_datapoint, @@ -131,7 +125,7 @@ def validate_repo_content(repo, content_types, after_sync=True): @pytest.mark.parametrize('name', **parametrized(valid_data_list())) @pytest.mark.tier1 -def test_positive_create_with_name(module_org, name): +def test_positive_create_with_name(module_org, name, module_target_sat): """Check if syncplan can be created with random names :id: dc0a86f7-4219-427e-92fd-29352dbdbfce @@ -142,14 +136,16 @@ def test_positive_create_with_name(module_org, name): :CaseImportance: Critical """ - sync_plan = make_sync_plan({'enabled': 'false', 'name': name, 'organization-id': module_org.id}) + sync_plan = module_target_sat.cli_factory.make_sync_plan( + {'enabled': 'false', 'name': name, 'organization-id': module_org.id} + ) result = SyncPlan.info({'id': sync_plan['id']}) assert result['name'] == name @pytest.mark.parametrize('desc', **parametrized(valid_data_list())) @pytest.mark.tier1 -def test_positive_create_with_description(module_org, desc): +def test_positive_create_with_description(module_org, desc, module_target_sat): """Check if syncplan can be created with random description :id: a1bbe81b-60f5-4a19-b400-a02a23fa1dfa @@ -160,7 +156,7 @@ def test_positive_create_with_description(module_org, desc): :CaseImportance: Critical """ - new_sync_plan = make_sync_plan( + new_sync_plan = module_target_sat.cli_factory.make_sync_plan( {'enabled': 'false', 'description': desc, 'organization-id': module_org.id} ) result = SyncPlan.info({'id': new_sync_plan['id']}) @@ -169,7 +165,7 @@ def test_positive_create_with_description(module_org, desc): @pytest.mark.parametrize('test_data', **parametrized(valid_name_interval_create_tests())) @pytest.mark.tier1 -def test_positive_create_with_interval(module_org, test_data): +def test_positive_create_with_interval(module_org, test_data, module_target_sat): """Check if syncplan can be created with varied intervals :id: 32eb0c1d-0c9a-4fb5-a185-68d0d705fbce @@ -180,7 +176,7 @@ def test_positive_create_with_interval(module_org, test_data): :CaseImportance: Critical """ - new_sync_plan = make_sync_plan( + new_sync_plan = module_target_sat.cli_factory.make_sync_plan( { 'enabled': 'false', 'interval': test_data['interval'], @@ -195,7 +191,7 @@ def test_positive_create_with_interval(module_org, test_data): @pytest.mark.parametrize('name', **parametrized(invalid_values_list())) @pytest.mark.tier1 -def test_negative_create_with_name(module_org, name): +def test_negative_create_with_name(module_org, name, module_target_sat): """Check if syncplan can be created with random invalid names :id: 4c1aee35-271e-4ed8-9369-d2abfea8cfd9 @@ -207,12 +203,14 @@ def test_negative_create_with_name(module_org, name): :CaseImportance: Critical """ with pytest.raises(CLIFactoryError, match='Could not create the sync plan:'): - make_sync_plan({'enabled': 'false', 'name': name, 'organization-id': module_org.id}) + module_target_sat.cli_factory.make_sync_plan( + {'enabled': 'false', 'name': name, 'organization-id': module_org.id} + ) @pytest.mark.parametrize('new_desc', **parametrized(valid_data_list())) @pytest.mark.tier2 -def test_positive_update_description(module_org, new_desc): +def test_positive_update_description(module_org, new_desc, module_target_sat): """Check if syncplan description can be updated :id: 00a279cd-1f49-4ebb-a59a-6f0b4e4cb83c @@ -221,7 +219,9 @@ def test_positive_update_description(module_org, new_desc): :expectedresults: Sync plan is created and description is updated """ - new_sync_plan = make_sync_plan({'enabled': 'false', 'organization-id': module_org.id}) + new_sync_plan = module_target_sat.cli_factory.make_sync_plan( + {'enabled': 'false', 'organization-id': module_org.id} + ) SyncPlan.update({'description': new_desc, 'id': new_sync_plan['id']}) result = SyncPlan.info({'id': new_sync_plan['id']}) assert result['description'] == new_desc @@ -240,7 +240,7 @@ def test_positive_update_interval(module_org, test_data, request, target_sat): :CaseImportance: Critical """ - new_sync_plan = make_sync_plan( + new_sync_plan = target_sat.cli_factory.make_sync_plan( { 'enabled': 'false', 'interval': test_data['interval'], @@ -271,7 +271,7 @@ def test_positive_update_sync_date(module_org, request, target_sat): # Set the sync date to today/right now today = datetime.now() sync_plan_name = gen_string('alphanumeric') - new_sync_plan = make_sync_plan( + new_sync_plan = target_sat.cli_factory.make_sync_plan( { 'name': sync_plan_name, 'sync-date': today.strftime(SYNC_DATE_FMT), @@ -297,7 +297,7 @@ def test_positive_update_sync_date(module_org, request, target_sat): @pytest.mark.parametrize('name', **parametrized(valid_data_list())) @pytest.mark.tier1 @pytest.mark.upgrade -def test_positive_delete_by_id(module_org, name): +def test_positive_delete_by_id(module_org, module_target_sat, name): """Check if syncplan can be created and deleted :id: b5d97c6b-aead-422b-8d9f-4a192bbe4a3b @@ -308,7 +308,9 @@ def test_positive_delete_by_id(module_org, name): :CaseImportance: Critical """ - new_sync_plan = make_sync_plan({'name': name, 'organization-id': module_org.id}) + new_sync_plan = module_target_sat.cli_factory.make_sync_plan( + {'name': name, 'organization-id': module_org.id} + ) SyncPlan.delete({'id': new_sync_plan['id']}) with pytest.raises(CLIReturnCodeError): SyncPlan.info({'id': new_sync_plan['id']}) @@ -324,7 +326,7 @@ def test_positive_info_enabled_field_is_displayed(module_org, request, target_sa :CaseImportance: Critical """ - new_sync_plan = make_sync_plan({'organization-id': module_org.id}) + new_sync_plan = target_sat.cli_factory.make_sync_plan({'organization-id': module_org.id}) sync_plan = entities.SyncPlan(organization=module_org.id, id=new_sync_plan['id']).read() request.addfinalizer(lambda: target_sat.api_factory.disable_syncplan(sync_plan)) result = SyncPlan.info({'id': new_sync_plan['id']}) @@ -333,7 +335,7 @@ def test_positive_info_enabled_field_is_displayed(module_org, request, target_sa @pytest.mark.tier2 @pytest.mark.upgrade -def test_positive_info_with_assigned_product(module_org): +def test_positive_info_with_assigned_product(module_org, module_target_sat): """Verify that sync plan info command returns list of products which are assigned to that sync plan @@ -352,7 +354,7 @@ def test_positive_info_with_assigned_product(module_org): """ prod1 = gen_string('alpha') prod2 = gen_string('alpha') - sync_plan = make_sync_plan( + sync_plan = module_target_sat.cli_factory.make_sync_plan( { 'enabled': 'false', 'organization-id': module_org.id, @@ -360,7 +362,9 @@ def test_positive_info_with_assigned_product(module_org): } ) for prod_name in [prod1, prod2]: - product = make_product({'organization-id': module_org.id, 'name': prod_name}) + product = module_target_sat.cli_factory.make_product( + {'organization-id': module_org.id, 'name': prod_name} + ) Product.set_sync_plan({'id': product['id'], 'sync-plan-id': sync_plan['id']}) updated_plan = SyncPlan.info({'id': sync_plan['id']}) assert len(updated_plan['products']) == 2 @@ -381,7 +385,7 @@ def test_negative_synchronize_custom_product_past_sync_date(module_org, request, :CaseLevel: System """ - new_sync_plan = make_sync_plan( + new_sync_plan = target_sat.cli_factory.make_sync_plan( { 'enabled': 'true', 'organization-id': module_org.id, @@ -390,8 +394,8 @@ def test_negative_synchronize_custom_product_past_sync_date(module_org, request, ) sync_plan = entities.SyncPlan(organization=module_org.id, id=new_sync_plan['id']).read() request.addfinalizer(lambda: target_sat.api_factory.disable_syncplan(sync_plan)) - product = make_product({'organization-id': module_org.id}) - repo = make_repository({'product-id': product['id']}) + product = target_sat.cli_factory.make_product({'organization-id': module_org.id}) + repo = target_sat.cli_factory.make_repository({'product-id': product['id']}) Product.set_sync_plan({'id': product['id'], 'sync-plan-id': new_sync_plan['id']}) with pytest.raises(AssertionError): validate_task_status(target_sat, repo['id'], module_org.id, max_tries=2) @@ -414,9 +418,9 @@ def test_positive_synchronize_custom_product_past_sync_date(module_org, request, """ interval = 60 * 60 # 'hourly' sync interval in seconds delay = 2 * 60 - product = make_product({'organization-id': module_org.id}) - repo = make_repository({'product-id': product['id']}) - new_sync_plan = make_sync_plan( + product = target_sat.cli_factory.make_product({'organization-id': module_org.id}) + repo = target_sat.cli_factory.make_repository({'product-id': product['id']}) + new_sync_plan = target_sat.cli_factory.make_sync_plan( { 'enabled': 'true', 'interval': 'hourly', @@ -468,12 +472,12 @@ def test_positive_synchronize_custom_product_future_sync_date(module_org, reques cron_multiple = 5 # sync event is on every multiple of this value, starting from 00 mins delay = (cron_multiple) * 60 # delay for sync date in seconds guardtime = 180 # do not start test less than 3 mins before the next sync event - product = make_product({'organization-id': module_org.id}) - repo = make_repository({'product-id': product['id']}) + product = target_sat.cli_factory.make_product({'organization-id': module_org.id}) + repo = target_sat.cli_factory.make_repository({'product-id': product['id']}) # if < 3 mins before the target event rather wait 3 mins for the next test window if int(datetime.utcnow().strftime('%M')) % (cron_multiple) > int(guardtime / 60): sleep(guardtime) - new_sync_plan = make_sync_plan( + new_sync_plan = target_sat.cli_factory.make_sync_plan( { 'enabled': 'true', 'organization-id': module_org.id, @@ -527,14 +531,18 @@ def test_positive_synchronize_custom_products_future_sync_date(module_org, reque cron_multiple = 5 # sync event is on every multiple of this value, starting from 00 mins delay = (cron_multiple) * 60 # delay for sync date in seconds guardtime = 210 # do not start test less than 3.5 mins before the next sync event - products = [make_product({'organization-id': module_org.id}) for _ in range(2)] + products = [ + target_sat.cli_factory.make_product({'organization-id': module_org.id}) for _ in range(2) + ] repos = [ - make_repository({'product-id': product['id']}) for product in products for _ in range(2) + target_sat.cli_factory.make_repository({'product-id': product['id']}) + for product in products + for _ in range(2) ] # if < 3 mins before the target event rather wait 3 mins for the next test window if int(datetime.utcnow().strftime('%M')) % (cron_multiple) > int(guardtime / 60): sleep(guardtime) - new_sync_plan = make_sync_plan( + new_sync_plan = target_sat.cli_factory.make_sync_plan( { 'enabled': 'true', 'organization-id': module_org.id, @@ -613,7 +621,7 @@ def test_positive_synchronize_rh_product_past_sync_date( repo = Repository.info( {'name': REPOS['rhva6']['name'], 'product': product['name'], 'organization-id': org.id} ) - new_sync_plan = make_sync_plan( + new_sync_plan = target_sat.cli_factory.make_sync_plan( { 'enabled': 'true', 'interval': 'hourly', @@ -685,7 +693,7 @@ def test_positive_synchronize_rh_product_future_sync_date( # if < 3 mins before the target event rather wait 3 mins for the next test window if int(datetime.utcnow().strftime('%M')) % (cron_multiple) > int(guardtime / 60): sleep(guardtime) - new_sync_plan = make_sync_plan( + new_sync_plan = target_sat.cli_factory.make_sync_plan( { 'enabled': 'true', 'organization-id': org.id, @@ -738,10 +746,10 @@ def test_positive_synchronize_custom_product_daily_recurrence(module_org, reques :CaseLevel: System """ delay = 2 * 60 - product = make_product({'organization-id': module_org.id}) - repo = make_repository({'product-id': product['id']}) + product = target_sat.cli_factory.make_product({'organization-id': module_org.id}) + repo = target_sat.cli_factory.make_repository({'product-id': product['id']}) start_date = datetime.utcnow() - timedelta(days=1) + timedelta(seconds=delay) - new_sync_plan = make_sync_plan( + new_sync_plan = target_sat.cli_factory.make_sync_plan( { 'enabled': 'true', 'interval': 'daily', @@ -789,10 +797,10 @@ def test_positive_synchronize_custom_product_weekly_recurrence(module_org, reque :CaseLevel: System """ delay = 2 * 60 - product = make_product({'organization-id': module_org.id}) - repo = make_repository({'product-id': product['id']}) + product = target_sat.cli_factory.make_product({'organization-id': module_org.id}) + repo = target_sat.cli_factory.make_repository({'product-id': product['id']}) start_date = datetime.utcnow() - timedelta(weeks=1) + timedelta(seconds=delay) - new_sync_plan = make_sync_plan( + new_sync_plan = target_sat.cli_factory.make_sync_plan( { 'enabled': 'true', 'interval': 'weekly', diff --git a/tests/foreman/cli/test_user.py b/tests/foreman/cli/test_user.py index 9f3537b139a..5269c8bf5ce 100644 --- a/tests/foreman/cli/test_user.py +++ b/tests/foreman/cli/test_user.py @@ -30,19 +30,12 @@ from nailgun import entities import pytest -from robottelo.cli.base import CLIReturnCodeError -from robottelo.cli.factory import ( - make_filter, - make_location, - make_org, - make_role, - make_user, -) from robottelo.cli.filter import Filter from robottelo.cli.org import Org from robottelo.cli.user import User from robottelo.config import settings from robottelo.constants import LOCALES +from robottelo.exceptions import CLIReturnCodeError from robottelo.utils import gen_ssh_keypairs from robottelo.utils.datafactory import ( parametrized, @@ -56,7 +49,7 @@ class TestUser: """Implements Users tests in CLI""" @pytest.fixture(scope='module') - def module_roles(self): + def module_roles(self, module_target_sat): """ Initializes class attribute ``dct_roles`` with several random roles saved on sat. roles is a dict so keys are role's id respective value is @@ -69,14 +62,14 @@ def roles_helper(): tests """ for role_name in valid_usernames_list() + include_list: - yield make_role({'name': role_name}) + yield module_target_sat.cli_factory.make_role({'name': role_name}) stubbed_roles = {role['id']: role for role in roles_helper()} yield stubbed_roles @pytest.mark.parametrize('email', **parametrized(valid_emails_list())) @pytest.mark.tier2 - def test_positive_CRUD(self, email): + def test_positive_CRUD(self, email, module_target_sat): """Create User with various parameters, updating and deleting :id: 2d430243-8512-46ee-8d21-7ccf0c7af807 @@ -99,7 +92,7 @@ def test_positive_CRUD(self, email): 'mail': mail.replace('"', r'\"').replace('`', r'\`'), 'description': random.choice(list(valid_data_list().values())), } - user = make_user(user_params) + user = module_target_sat.cli_factory.make_user(user_params) user['firstname'], user['lastname'] = user['name'].split() user_params.pop('mail') user_params['email'] = mail @@ -144,7 +137,7 @@ def test_positive_CRUD(self, email): @pytest.mark.tier1 @pytest.mark.upgrade - def test_positive_CRUD_admin(self): + def test_positive_CRUD_admin(self, target_sat): """Create an Admin user :id: 0d0384ad-d85a-492e-8630-7f48912a4fd5 @@ -153,7 +146,7 @@ def test_positive_CRUD_admin(self): :CaseImportance: Critical """ - user = make_user({'admin': '1'}) + user = target_sat.cli_factory.make_user({'admin': '1'}) assert user['admin'] == 'yes' # update to non admin by id User.update({'id': user['id'], 'admin': '0'}) @@ -169,7 +162,7 @@ def test_positive_CRUD_admin(self): User.info({'id': user['id']}) @pytest.mark.tier1 - def test_positive_create_with_default_loc(self): + def test_positive_create_with_default_loc(self, target_sat): """Check if user with default location can be created :id: efe7256d-8c8f-444c-8d59-43500e1319c3 @@ -178,13 +171,15 @@ def test_positive_create_with_default_loc(self): :CaseImportance: Critical """ - location = make_location() - user = make_user({'default-location-id': location['id'], 'location-ids': location['id']}) + location = target_sat.cli_factory.make_location() + user = target_sat.cli_factory.make_user( + {'default-location-id': location['id'], 'location-ids': location['id']} + ) assert location['name'] in user['locations'] assert location['name'] == user['default-location'] @pytest.mark.tier1 - def test_positive_create_with_defaut_org(self): + def test_positive_create_with_defaut_org(self, module_target_sat): """Check if user with default organization can be created :id: cc692b6f-2519-429b-8ecb-c4bb51ed3544 @@ -194,13 +189,15 @@ def test_positive_create_with_defaut_org(self): :CaseImportance: Critical """ - org = make_org() - user = make_user({'default-organization-id': org['id'], 'organization-ids': org['id']}) + org = module_target_sat.cli_factory.make_org() + user = module_target_sat.cli_factory.make_user( + {'default-organization-id': org['id'], 'organization-ids': org['id']} + ) assert org['name'] in user['organizations'] assert org['name'] == user['default-organization'] @pytest.mark.tier2 - def test_positive_create_with_orgs_and_update(self): + def test_positive_create_with_orgs_and_update(self, module_target_sat): """Create User associated to multiple Organizations, update them :id: f537296c-a8a8-45ef-8996-c1d32b8f64de @@ -210,12 +207,14 @@ def test_positive_create_with_orgs_and_update(self): :CaseLevel: Integration """ orgs_amount = 2 - orgs = [make_org() for _ in range(orgs_amount)] - user = make_user({'organization-ids': [org['id'] for org in orgs]}) + orgs = [module_target_sat.cli_factory.make_org() for _ in range(orgs_amount)] + user = module_target_sat.cli_factory.make_user( + {'organization-ids': [org['id'] for org in orgs]} + ) assert len(user['organizations']) == orgs_amount for org in orgs: assert org['name'] in user['organizations'] - orgs = [make_org() for _ in range(orgs_amount)] + orgs = [module_target_sat.cli_factory.make_org() for _ in range(orgs_amount)] User.update({'id': user['id'], 'organization-ids': [org['id'] for org in orgs]}) user = User.info({'id': user['id']}) for org in orgs: @@ -236,7 +235,7 @@ def test_negative_delete_internal_admin(self): assert User.info({'login': settings.server.admin_username}) @pytest.mark.tier2 - def test_positive_last_login_for_new_user(self): + def test_positive_last_login_for_new_user(self, module_target_sat): """Create new user with admin role and check last login updated for that user :id: 967282d3-92d0-42ce-9ef3-e542d2883408 @@ -253,7 +252,7 @@ def test_positive_last_login_for_new_user(self): password = gen_string('alpha') org_name = gen_string('alpha') - make_user({'login': login, 'password': password}) + module_target_sat.cli_factory.make_user({'login': login, 'password': password}) User.add_role({'login': login, 'role': 'System admin'}) result_before_login = User.list({'search': f'login = {login}'}) @@ -273,7 +272,7 @@ def test_positive_last_login_for_new_user(self): assert after_login_time > before_login_time @pytest.mark.tier1 - def test_positive_update_all_locales(self): + def test_positive_update_all_locales(self, module_target_sat): """Update Language in My Account :id: f0993495-5117-461d-a116-44867b820139 @@ -286,14 +285,14 @@ def test_positive_update_all_locales(self): :CaseImportance: Critical """ - user = make_user() + user = module_target_sat.cli_factory.make_user() for locale in LOCALES: User.update({'id': user['id'], 'locale': locale}) assert locale == User.info({'id': user['id']})['locale'] @pytest.mark.tier2 @pytest.mark.upgrade - def test_positive_add_and_delete_roles(self, module_roles): + def test_positive_add_and_delete_roles(self, module_roles, module_target_sat): """Add multiple roles to User, then delete them For now add-role user sub command does not allow multiple role ids @@ -309,7 +308,7 @@ def test_positive_add_and_delete_roles(self, module_roles): :CaseLevel: Integration """ - user = make_user() + user = module_target_sat.cli_factory.make_user() original_role_names = set(user['roles']) expected_role_names = set(original_role_names) @@ -409,7 +408,7 @@ def test_personal_access_token_admin_user(self, target_sat): :CaseImportance: High """ - user = make_user({'admin': '1'}) + user = target_sat.cli_factory.make_user({'admin': '1'}) token_name = gen_alphanumeric() result = User.access_token( action="create", options={'name': token_name, 'user-id': user['id']} @@ -445,7 +444,7 @@ def test_positive_personal_access_token_user_with_role(self, target_sat): :CaseImportance: High """ - user = make_user() + user = target_sat.cli_factory.make_user() User.add_role({'login': user['login'], 'role': 'Viewer'}) token_name = gen_alphanumeric() result = User.access_token( @@ -479,7 +478,7 @@ def test_expired_personal_access_token(self, target_sat): :CaseImportance: Medium """ - user = make_user() + user = target_sat.cli_factory.make_user() User.add_role({'login': user['login'], 'role': 'Viewer'}) token_name = gen_alphanumeric() datetime_now = datetime.datetime.utcnow() @@ -521,7 +520,7 @@ def test_custom_personal_access_token_role(self, target_sat): :BZ: 1974685, 1996048 """ - role = make_role() + role = target_sat.cli_factory.make_role() permissions = [ permission['name'] for permission in Filter.available_permissions( @@ -529,9 +528,9 @@ def test_custom_personal_access_token_role(self, target_sat): ) ] permissions = ','.join(permissions) - make_filter({'role-id': role['id'], 'permissions': permissions}) - make_filter({'role-id': role['id'], 'permissions': 'view_users'}) - user = make_user() + target_sat.cli_factory.make_filter({'role-id': role['id'], 'permissions': permissions}) + target_sat.cli_factory.make_filter({'role-id': role['id'], 'permissions': 'view_users'}) + user = target_sat.cli_factory.make_user() User.add_role({'login': user['login'], 'role': role['name']}) token_name = gen_alphanumeric() result = User.access_token( diff --git a/tests/foreman/cli/test_usergroup.py b/tests/foreman/cli/test_usergroup.py index 57e3c8b9b17..28b9d6eef5c 100644 --- a/tests/foreman/cli/test_usergroup.py +++ b/tests/foreman/cli/test_usergroup.py @@ -20,29 +20,23 @@ import pytest -from robottelo.cli.base import CLIReturnCodeError -from robottelo.cli.factory import ( - make_role, - make_user, - make_usergroup, - make_usergroup_external, -) from robottelo.cli.ldapauthsource import LDAPAuthSource from robottelo.cli.task import Task from robottelo.cli.user import User from robottelo.cli.usergroup import UserGroup, UserGroupExternal +from robottelo.exceptions import CLIReturnCodeError from robottelo.utils.datafactory import valid_usernames_list @pytest.fixture(scope='function') -def function_user_group(): +def function_user_group(target_sat): """Create new usergroup per each test""" - user_group = make_usergroup() + user_group = target_sat.cli_factory.make_usergroup() yield user_group @pytest.mark.tier1 -def test_positive_CRUD(): +def test_positive_CRUD(module_target_sat): """Create new user group with valid elements that attached group. List the user group, update and delete it. @@ -53,14 +47,14 @@ def test_positive_CRUD(): :CaseImportance: Critical """ - user = make_user() + user = module_target_sat.cli_factory.make_user() ug_name = random.choice(valid_usernames_list()) role_name = random.choice(valid_usernames_list()) - role = make_role({'name': role_name}) - sub_user_group = make_usergroup() + role = module_target_sat.cli_factory.make_role({'name': role_name}) + sub_user_group = module_target_sat.cli_factory.make_usergroup() # Create - user_group = make_usergroup( + user_group = module_target_sat.cli_factory.make_usergroup( { 'user-ids': user['id'], 'name': ug_name, @@ -93,7 +87,7 @@ def test_positive_CRUD(): @pytest.mark.tier1 -def test_positive_create_with_multiple_elements(): +def test_positive_create_with_multiple_elements(module_target_sat): """Create new user group using multiple users, roles and user groups attached to that group. @@ -105,17 +99,19 @@ def test_positive_create_with_multiple_elements(): :CaseImportance: Critical """ count = 2 - users = [make_user()['login'] for _ in range(count)] - roles = [make_role()['name'] for _ in range(count)] - sub_user_groups = [make_usergroup()['name'] for _ in range(count)] - user_group = make_usergroup({'users': users, 'roles': roles, 'user-groups': sub_user_groups}) + users = [module_target_sat.cli_factory.make_user()['login'] for _ in range(count)] + roles = [module_target_sat.cli_factory.make_role()['name'] for _ in range(count)] + sub_user_groups = [module_target_sat.cli_factory.make_usergroup()['name'] for _ in range(count)] + user_group = module_target_sat.cli_factory.make_usergroup( + {'users': users, 'roles': roles, 'user-groups': sub_user_groups} + ) assert sorted(users) == sorted(user_group['users']) assert sorted(roles) == sorted(user_group['roles']) assert sorted(sub_user_groups) == sorted(ug['usergroup'] for ug in user_group['user-groups']) @pytest.mark.tier2 -def test_positive_add_and_remove_elements(): +def test_positive_add_and_remove_elements(module_target_sat): """Create new user group. Add and remove several element from the group. :id: a4ce8724-d3c8-4c00-9421-aaa40394134d @@ -127,10 +123,10 @@ def test_positive_add_and_remove_elements(): :CaseLevel: Integration """ - role = make_role() - user_group = make_usergroup() - user = make_user() - sub_user_group = make_usergroup() + role = module_target_sat.cli_factory.make_role() + user_group = module_target_sat.cli_factory.make_usergroup() + user = module_target_sat.cli_factory.make_user() + sub_user_group = module_target_sat.cli_factory.make_usergroup() # Add elements by id UserGroup.add_role({'id': user_group['id'], 'role-id': role['id']}) @@ -158,7 +154,7 @@ def test_positive_add_and_remove_elements(): @pytest.mark.tier2 @pytest.mark.upgrade -def test_positive_remove_user_assigned_to_usergroup(): +def test_positive_remove_user_assigned_to_usergroup(module_target_sat): """Create new user and assign it to user group. Then remove that user. :id: 2a2623ce-4723-4402-aae7-8675473fd8bd @@ -171,8 +167,8 @@ def test_positive_remove_user_assigned_to_usergroup(): :BZ: 1667704 """ - user = make_user() - user_group = make_usergroup() + user = module_target_sat.cli_factory.make_user() + user_group = module_target_sat.cli_factory.make_usergroup() UserGroup.add_user({'id': user_group['id'], 'user-id': user['id']}) User.delete({'id': user['id']}) user_group = UserGroup.info({'id': user_group['id']}) @@ -181,7 +177,7 @@ def test_positive_remove_user_assigned_to_usergroup(): @pytest.mark.tier2 @pytest.mark.parametrize("ldap_auth_source", ["AD"], indirect=True) -def test_positive_automate_bz1426957(ldap_auth_source, function_user_group): +def test_positive_automate_bz1426957(ldap_auth_source, function_user_group, target_sat): """Verify role is properly reflected on AD user. :id: 1c1209a6-5bb8-489c-a151-bb2fce4dbbfc @@ -196,7 +192,7 @@ def test_positive_automate_bz1426957(ldap_auth_source, function_user_group): :BZ: 1426957, 1667704 """ - ext_user_group = make_usergroup_external( + ext_user_group = target_sat.cli_factory.make_usergroup_external( { 'auth-source-id': ldap_auth_source[1].id, 'user-group-id': function_user_group['id'], @@ -204,7 +200,7 @@ def test_positive_automate_bz1426957(ldap_auth_source, function_user_group): } ) assert ext_user_group['auth-source'] == ldap_auth_source[1].name - role = make_role() + role = target_sat.cli_factory.make_role() UserGroup.add_role({'id': function_user_group['id'], 'role-id': role['id']}) Task.with_user( username=ldap_auth_source[0]['ldap_user_name'], diff --git a/tests/foreman/cli/test_vm_install_products_package.py b/tests/foreman/cli/test_vm_install_products_package.py index 1e16997457d..53777235341 100644 --- a/tests/foreman/cli/test_vm_install_products_package.py +++ b/tests/foreman/cli/test_vm_install_products_package.py @@ -19,7 +19,6 @@ from broker import Broker import pytest -from robottelo.cli.factory import make_lifecycle_environment from robottelo.config import settings from robottelo.constants import ( CONTAINER_REGISTRY_HUB, @@ -31,8 +30,10 @@ @pytest.fixture -def lce(function_entitlement_manifest_org): - return make_lifecycle_environment({'organization-id': function_entitlement_manifest_org.id}) +def lce(function_entitlement_manifest_org, target_sat): + return target_sat.cli_factory.make_lifecycle_environment( + {'organization-id': function_entitlement_manifest_org.id} + ) @pytest.mark.tier4 diff --git a/tests/foreman/cli/test_webhook.py b/tests/foreman/cli/test_webhook.py index 3ca83dbe70f..9b816ef8813 100644 --- a/tests/foreman/cli/test_webhook.py +++ b/tests/foreman/cli/test_webhook.py @@ -23,9 +23,9 @@ from fauxfactory import gen_alphanumeric import pytest -from robottelo.cli.base import CLIReturnCodeError from robottelo.cli.webhook import Webhook from robottelo.constants import WEBHOOK_EVENTS, WEBHOOK_METHODS +from robottelo.exceptions import CLIReturnCodeError @pytest.fixture(scope='function') diff --git a/tests/foreman/destructive/test_ldap_authentication.py b/tests/foreman/destructive/test_ldap_authentication.py index 39f5a6b4f65..450460e7d91 100644 --- a/tests/foreman/destructive/test_ldap_authentication.py +++ b/tests/foreman/destructive/test_ldap_authentication.py @@ -23,9 +23,9 @@ import pyotp import pytest -from robottelo.cli.base import CLIReturnCodeError from robottelo.config import settings from robottelo.constants import CERT_PATH, HAMMER_CONFIG, HAMMER_SESSIONS, LDAP_ATTR +from robottelo.exceptions import CLIReturnCodeError from robottelo.logging import logger from robottelo.utils.datafactory import gen_string diff --git a/tests/foreman/destructive/test_ldapauthsource.py b/tests/foreman/destructive/test_ldapauthsource.py index fdbc2da11ba..4a87090acaa 100644 --- a/tests/foreman/destructive/test_ldapauthsource.py +++ b/tests/foreman/destructive/test_ldapauthsource.py @@ -20,9 +20,9 @@ import pytest -from robottelo.cli.base import CLIReturnCodeError from robottelo.config import settings from robottelo.constants import HAMMER_CONFIG +from robottelo.exceptions import CLIReturnCodeError pytestmark = [pytest.mark.destructive] diff --git a/tests/foreman/destructive/test_realm.py b/tests/foreman/destructive/test_realm.py index de5a9b1ebc3..9b58910f74d 100644 --- a/tests/foreman/destructive/test_realm.py +++ b/tests/foreman/destructive/test_realm.py @@ -21,7 +21,7 @@ from fauxfactory import gen_string import pytest -from robottelo.cli.base import CLIReturnCodeError +from robottelo.exceptions import CLIReturnCodeError pytestmark = [pytest.mark.run_in_one_thread, pytest.mark.destructive] diff --git a/tests/foreman/endtoend/test_cli_endtoend.py b/tests/foreman/endtoend/test_cli_endtoend.py index 0001e482043..576bbcc229d 100644 --- a/tests/foreman/endtoend/test_cli_endtoend.py +++ b/tests/foreman/endtoend/test_cli_endtoend.py @@ -24,7 +24,6 @@ from robottelo.cli.computeresource import ComputeResource from robottelo.cli.contentview import ContentView from robottelo.cli.domain import Domain -from robottelo.cli.factory import make_user from robottelo.cli.host import Host from robottelo.cli.hostgroup import HostGroup from robottelo.cli.lifecycleenvironment import LifecycleEnvironment @@ -126,7 +125,7 @@ def test_positive_cli_end_to_end(function_entitlement_manifest, target_sat, rhel """ # step 1: Create a new user with admin permissions password = gen_alphanumeric() - user = make_user({'admin': 'true', 'password': password}) + user = target_sat.cli_factory.make_user({'admin': 'true', 'password': password}) user['password'] = password # step 2.1: Create a new organization diff --git a/tests/foreman/longrun/test_oscap.py b/tests/foreman/longrun/test_oscap.py index 3d292092c86..13c697551d0 100644 --- a/tests/foreman/longrun/test_oscap.py +++ b/tests/foreman/longrun/test_oscap.py @@ -23,7 +23,6 @@ from robottelo.cli.ansible import Ansible from robottelo.cli.arfreport import Arfreport -from robottelo.cli.factory import make_hostgroup, make_scap_policy from robottelo.cli.host import Host from robottelo.cli.job_invocation import JobInvocation from robottelo.cli.proxy import Proxy @@ -173,7 +172,7 @@ def test_positive_oscap_run_via_ansible( hgrp_name = gen_string('alpha') policy_name = gen_string('alpha') # Creates host_group for rhel7 - make_hostgroup( + target_sat.cli_factory.make_hostgroup( { 'content-source-id': default_proxy, 'name': hgrp_name, @@ -185,7 +184,7 @@ def test_positive_oscap_run_via_ansible( Ansible.roles_import({'proxy-id': default_proxy}) Ansible.variables_import({'proxy-id': default_proxy}) role_id = Ansible.roles_list({'search': 'foreman_scap_client'})[0].get('id') - make_scap_policy( + target_sat.cli_factory.make_scap_policy( { 'scap-content-id': scap_id, 'hostgroups': hgrp_name, @@ -270,7 +269,7 @@ def test_positive_oscap_run_via_ansible_bz_1814988( hgrp_name = gen_string('alpha') policy_name = gen_string('alpha') # Creates host_group for rhel7 - make_hostgroup( + target_sat.cli_factory.make_hostgroup( { 'content-source-id': default_proxy, 'name': hgrp_name, @@ -284,7 +283,7 @@ def test_positive_oscap_run_via_ansible_bz_1814988( Ansible.roles_import({'proxy-id': default_proxy}) Ansible.variables_import({'proxy-id': default_proxy}) role_id = Ansible.roles_list({'search': 'foreman_scap_client'})[0].get('id') - make_scap_policy( + target_sat.cli_factory.make_scap_policy( { 'scap-content-id': scap_id, 'hostgroups': hgrp_name, diff --git a/tests/foreman/ui/test_activationkey.py b/tests/foreman/ui/test_activationkey.py index d0664d86e27..c5546e26bae 100644 --- a/tests/foreman/ui/test_activationkey.py +++ b/tests/foreman/ui/test_activationkey.py @@ -25,7 +25,6 @@ import pytest from robottelo import constants -from robottelo.cli.factory import setup_org_for_a_custom_repo from robottelo.config import settings from robottelo.hosts import ContentHost from robottelo.utils.datafactory import parametrized, valid_data_list @@ -1051,7 +1050,7 @@ def test_positive_host_associations(session, target_sat): :CaseLevel: System """ org = entities.Organization().create() - org_entities = setup_org_for_a_custom_repo( + org_entities = target_sat.cli_factory.setup_org_for_a_custom_repo( {'url': settings.repos.yum_1.url, 'organization-id': org.id} ) ak1 = entities.ActivationKey(id=org_entities['activationkey-id']).read() @@ -1115,7 +1114,7 @@ def test_positive_service_level_subscription_with_custom_product( :CaseLevel: System """ org = function_entitlement_manifest_org - entities_ids = setup_org_for_a_custom_repo( + entities_ids = target_sat.cli_factory.setup_org_for_a_custom_repo( {'url': settings.repos.yum_1.url, 'organization-id': org.id} ) product = entities.Product(id=entities_ids['product-id']).read() diff --git a/tests/foreman/ui/test_contenthost.py b/tests/foreman/ui/test_contenthost.py index 1db98df1d70..da74c1b4117 100644 --- a/tests/foreman/ui/test_contenthost.py +++ b/tests/foreman/ui/test_contenthost.py @@ -25,7 +25,6 @@ from nailgun import entities import pytest -from robottelo.cli.factory import CLIFactoryError, make_fake_host, make_virt_who_config from robottelo.config import setting_is_set, settings from robottelo.constants import ( DEFAULT_SYSPURPOSE_ATTRIBUTES, @@ -41,6 +40,7 @@ VDC_SUBSCRIPTION_NAME, VIRT_WHO_HYPERVISOR_TYPES, ) +from robottelo.exceptions import CLIFactoryError from robottelo.utils.issue_handlers import is_open from robottelo.utils.virtwho import create_fake_hypervisor_content @@ -902,7 +902,7 @@ def test_positive_virt_who_hypervisor_subscription_status( # TODO move this to either hack around virt-who service or use an env-* compute resource provisioning_server = settings.libvirt.libvirt_hostname # Create a new virt-who config - virt_who_config = make_virt_who_config( + virt_who_config = target_sat.cli_factory.make_virt_who_config( { 'organization-id': org.id, 'hypervisor-type': VIRT_WHO_HYPERVISOR_TYPES['libvirt'], @@ -1725,7 +1725,7 @@ def test_syspurpose_mismatched(session, default_location, vm_module_streams): @pytest.mark.tier3 -def test_pagination_multiple_hosts_multiple_pages(session, module_host_template): +def test_pagination_multiple_hosts_multiple_pages(session, module_host_template, target_sat): """Create hosts to fill more than one page, sort on OS, check pagination. Search for hosts based on operating system and assert that more than one page @@ -1750,7 +1750,7 @@ def test_pagination_multiple_hosts_multiple_pages(session, module_host_template) # Create more than one page of fake hosts. Need two digits in name to ensure sort order. for count in range(host_num): host_name = f'test-{count + 1:0>2}' - make_fake_host( + target_sat.cli_factory.make_fake_host( { 'name': host_name, 'organization-id': module_host_template.organization.id, diff --git a/tests/foreman/ui/test_subscription.py b/tests/foreman/ui/test_subscription.py index 617c9753403..09673e5c79c 100644 --- a/tests/foreman/ui/test_subscription.py +++ b/tests/foreman/ui/test_subscription.py @@ -24,7 +24,6 @@ from nailgun import entities import pytest -from robottelo.cli.factory import make_virt_who_config from robottelo.config import settings from robottelo.constants import ( DEFAULT_SUBSCRIPTION_NAME, @@ -370,7 +369,7 @@ def test_positive_view_vdc_guest_subscription_products( rh_product_repository = target_sat.cli_factory.RHELAnsibleEngineRepository(cdn=True) product_name = rh_product_repository.data['product'] # Create a new virt-who config - virt_who_config = make_virt_who_config( + virt_who_config = target_sat.cli_factory.make_virt_who_config( { 'organization-id': org.id, 'hypervisor-type': VIRT_WHO_HYPERVISOR_TYPES['libvirt'], diff --git a/tests/robottelo/test_cli.py b/tests/robottelo/test_cli.py index 78b0f6f0cf8..94922f72068 100644 --- a/tests/robottelo/test_cli.py +++ b/tests/robottelo/test_cli.py @@ -4,8 +4,8 @@ import pytest -from robottelo.cli.base import ( - Base, +from robottelo.cli.base import Base +from robottelo.exceptions import ( CLIBaseError, CLIDataBaseError, CLIError,