def pytest_runtest_setup(item): """Skip in setup if settings mark isn't met settings validate method is used, so required fields are checked This will be getting updated before too long when dynaconf consolidation happens """ skip_marker = item.get_closest_marker('skip_if_not_set', None) if skip_marker and skip_marker.args: options_set = {arg.upper() for arg in skip_marker.args} settings_set = { key for key in settings.keys() if not key.endswith('_FOR_DYNACONF') } if not options_set.issubset(settings_set): invalid = options_set.difference(settings_set) raise ValueError( f'Feature(s): {invalid} not found. Available ones are: {settings_set}.' ) missing = [] for option in options_set: # Example: `settings.clients` if not setting_is_set(option): # List of all sections that are not fully configured missing.append(option) if missing: pytest.skip(f'Missing configuration for: {missing}.')
def client_provisioning(self, activation_key_name, organization_label, package_name='python-kitchen'): """Provision a Satellite's client. Do the following: 1. Install Katello CA cert on the client 2. Register the client using Activation Key 3. Install a package on the client served by the Satellite server. :param activation_key_name: Name of the Activation Key to register. :param organization_label: Organization label where the Activation Key is available. :param package_name: Name of the package to be installed on the client. """ if not setting_is_set('clients'): return with VMBroker(nick='rhel6', host_classes={'host': ContentHost}) as host: # Pull rpm from Foreman server and install on client host.install_katello_ca() # Register client with foreman server using act keys host.register_contenthost(organization_label, activation_key_name) assert host.subscribed # Install rpm on client result = host.run(f'yum install -y {package_name}') assert result.status == 0 # Verify that the package is installed by querying it result = host.run(f'rpm -q {package_name}') assert result.status == 0
def pytest_report_header(config): """Called when pytest session starts""" messages = [] shared_function_enabled = 'OFF' scope = '' storage = 'file' if setting_is_set('shared_function'): if settings.shared_function.enabled: shared_function_enabled = 'ON' scope = settings.shared_function.scope if not scope: scope = '' storage = settings.shared_function.storage messages.append( f'shared_function enabled - {shared_function_enabled} - ' f'scope: {scope} - storage: {storage}' ) return messages
def _check_config(): global _configured global DEFAULT_STORAGE_HANDLER global ENABLED global NAMESPACE_SCOPE global SHARE_DEFAULT_TIMEOUT global DEFAULT_CALL_RETRIES if not _configured and setting_is_set('shared_function'): DEFAULT_STORAGE_HANDLER = settings.shared_function.storage ENABLED = settings.shared_function.enabled NAMESPACE_SCOPE = settings.shared_function.scope SHARE_DEFAULT_TIMEOUT = settings.shared_function.share_timeout DEFAULT_CALL_RETRIES = settings.shared_function.call_retries file_storage.LOCK_TIMEOUT = settings.shared_function.lock_timeout redis_storage.LOCK_TIMEOUT = settings.shared_function.lock_timeout redis_storage.REDIS_HOST = settings.shared_function.redis_host redis_storage.REDIS_PORT = settings.shared_function.redis_port redis_storage.REDIS_DB = settings.shared_function.redis_db redis_storage.REDIS_PASSWORD = settings.shared_function.redis_password _set_configured(True)
def fake_manifest_is_set(self): return setting_is_set('fake_manifest')
import pytest import requests from nailgun import entities from wait_for import wait_for from robottelo.api.utils import check_create_os_with_title from robottelo.config import setting_is_set from robottelo.config import settings from robottelo.constants import COMPUTE_PROFILE_LARGE from robottelo.constants import DEFAULT_LOC from robottelo.constants import FOREMAN_PROVIDERS from robottelo.datafactory import gen_string # TODO mark this on the module with a lambda for skip condition # so that this is executed during the session at run loop, instead of at module import if not setting_is_set('rhev'): pytest.skip('skipping tests due to missing rhev settings', allow_module_level=True) @pytest.fixture(scope='module') def module_ca_cert(): return (None if settings.rhev.ca_cert is None else requests.get( settings.rhev.ca_cert).content.decode()) @pytest.fixture(scope='module') def rhev_data(): return { 'rhev_url': settings.rhev.hostname, 'username': settings.rhev.username,