pulp_smash.utils

Location: Pulp SmashAPI Documentationpulp_smash.utils

Utility functions for Pulp tests.

This module may make use of pulp_smash.api and pulp_smash.cli, but the reverse should not be done.

pulp_smash.utils.ensure_teardownclass(testcase)

Ensure the call of tearDownClass on classmethods.

Unittest will not execute tearDownClass if an error occurs on classmethods this contextmanager will ensure that method is executed in case of error.

Usage::

# in a test case class @classmethod def setUpClass(cls):

with ensure_teardownclass(cls):
# this raises error tearDownClass should be executed after 1 / 0
pulp_smash.utils.execute_pulpcore_python(cli_client, command)

Execute command in pulpcore-manager on system under test.

pulp_smash.utils.fips_is_enabled(cfg, pulp_host=None)

Return True if the Fips is enabled in server, or False otherwise.

Parameters:
  • cfg (pulp_smash.config.PulpSmashConfig) – Information about the system being targeted
  • pulp_host – A :class : pulp_smash.config.PulpHost to target, instead of the default chosen by :class: pulp_smash.cli.Client`.
Returns:

True of False

pulp_smash.utils.fips_is_supported(cfg, pulp_host=None)

Return True if the server supports Fips, or False otherwise.

Parameters:
  • cfg (pulp_smash.config.PulpSmashConfig) – Information about the system being targeted
  • pulp_host – A :class : pulp_smash.config.PulpHost to target, instead of the default chosen by :class: pulp_smash.cli.Client`.
Returns:

True of False

pulp_smash.utils.get_os_release_id(cfg, pulp_host=None)

Get ID from /etc/os-release.

Parameters:
Returns:

A string such as “rhel,” “fedora,” or “arch.” (These values come from Red Hat Enterprise Linux, Fedora, and Arch Linux respectively.)

pulp_smash.utils.get_os_release_version_id(cfg, pulp_host=None)

Get VERSION_ID from /etc/os-release.

Parameters:
Returns:

A string such as “7.5” or “27”. (These values come from RHEL 7.5 and Fedora 27, respectively.) Make sure to convert this string to an actual version object if doing version number comparisons. packaging.version.Version can be used for this purpose.

pulp_smash.utils.get_pulp_setting(cli_client, setting_name)

Retrieves the value of a Pulp setting from system under test.

pulp_smash.utils.get_sha256_checksum(url)

Return the sha256 checksum of the file at the given URL.

When a URL is encountered for the first time, do the following:

  1. Download the file and calculate its sha256 checksum.
  2. Cache the URL-checksum pair.
  3. Return the checksum.

On subsequent calls, return a cached checksum.

pulp_smash.utils.http_get(url, verify=False, **kwargs)

Issue a HTTP request to the url and return the response content.

This is useful for downloading file contents over HTTP[S].

Parameters:
  • url – the URL where the content should be get.
  • kwargs – additional kwargs to be passed to requests.get.
Returns:

the response content of a GET request to url.

pulp_smash.utils.uuid4()

Return a random UUID4 as a string.