pulp_smash.pulp3.utils

Location: Pulp SmashAPI Documentationpulp_smash.pulp3.utils

Utility functions for Pulp 3 tests.

pulp_smash.pulp3.utils.delete_orphans(cfg=None)

Clean all content units present in pulp.

An orphaned artifact is an artifact that is not in any content units. An orphaned content unit is a content unit that is not in any repository version.

Parameters:cfg (pulp_smash.config.PulpSmashConfig) – Information about the Pulp host.
pulp_smash.pulp3.utils.delete_version(repo, version_href=None)

Delete a given repository version.

Parameters:
  • repo – A dict of information about the repository.
  • version_href – The repository version that should be deleted.
Returns:

A tuple. The tasks spawned by Pulp.

pulp_smash.pulp3.utils.download_content_unit(_cfg, distribution, unit_path, **kwargs)

Download the content unit distribution using pulp-smash config.

Parameters:
  • cfg (pulp_smash.config.PulpSmashConfig) – Information about the Pulp host.
  • distribution – A dict of information about the distribution.
  • unit_path – A string path to the unit to be downloaded.
  • kwargs – Extra arguments passed to requests.get.
pulp_smash.pulp3.utils.gen_distribution(**kwargs)

Return a semi-random dict for use in creating a Distribution.

pulp_smash.pulp3.utils.gen_publisher(**kwargs)

Return a semi-random dict for use in creating an Publisher.

pulp_smash.pulp3.utils.gen_remote(url, **kwargs)

Return a semi-random dict for use in creating a Remote.

Parameters:url – The URL of an external content source.
pulp_smash.pulp3.utils.gen_repo(**kwargs)

Return a semi-random dict for use in creating a Repository.

pulp_smash.pulp3.utils.get_added_content(repo, version_href=None)

Read the content units of a given repository.

Parameters:
  • repo – A dict of information about the repository.
  • version_href – The repository version to read. If none, read the latest repository version.
Returns:

A list of information about the content units present in a given repository version.

pulp_smash.pulp3.utils.get_added_content_summary(repo, version_href=None)

Read the “content summary” of a given repository version.

Repository versions have a “content_summary” which lists the content types and the number of units of that type present in the repo version.

Parameters:
  • repo – A dict of information about the repository.
  • version_href – The repository version to read. If none, read the latest repository version.
Returns:

The “content_summary” of the repo version.

pulp_smash.pulp3.utils.get_artifact_paths(repo, version_href=None)

Return the paths of artifacts present in a given repository version.

Parameters:
  • repo – A dict of information about the repository.
  • version_href – The repository version to read.
Returns:

A set with the paths of units present in a given repository.

pulp_smash.pulp3.utils.get_content(repo, version_href=None)

Read the content units of a given repository.

Parameters:
  • repo – A dict of information about the repository.
  • version_href – The repository version to read. If none, read the latest repository version.
Returns:

A list of information about the content units present in a given repository version.

pulp_smash.pulp3.utils.get_content_summary(repo, version_href=None)

Read the “content summary” of a given repository version.

Repository versions have a “content_summary” which lists the content types and the number of units of that type present in the repo version.

Parameters:
  • repo – A dict of information about the repository.
  • version_href – The repository version to read. If none, read the latest repository version.
Returns:

The “content_summary” of the repo version.

pulp_smash.pulp3.utils.get_plugins(cfg=None)

Return the set of plugins installed on the Pulp application.

Parameters:cfg (pulp_smash.config.PulpSmashConfig) – Information about the Pulp application under test.
Returns:A set of plugin names, e.g. {'pulpcore', 'pulp_file'}.
pulp_smash.pulp3.utils.get_removed_content(repo, version_href=None)

Read the content units of a given repository.

Parameters:
  • repo – A dict of information about the repository.
  • version_href – The repository version to read. If none, read the latest repository version.
Returns:

A list of information about the content units present in a given repository version.

pulp_smash.pulp3.utils.get_removed_content_summary(repo, version_href=None)

Read the “content summary” of a given repository version.

Repository versions have a “content_summary” which lists the content types and the number of units of that type present in the repo version.

Parameters:
  • repo – A dict of information about the repository.
  • version_href – The repository version to read. If none, read the latest repository version.
Returns:

The “content_summary” of the repo version.

pulp_smash.pulp3.utils.get_versions(repo, params=None)

Return repository versions, sorted by version ID.

Parameters:
  • repo – A dict of information about the repository.
  • params – Dictionary or bytes to be sent in the query string. Used to filter which versions are returned.
Returns:

A sorted list of dicts of information about repository versions.

pulp_smash.pulp3.utils.modify_repo(cfg, repo, base_version=None, add_units=None, remove_units=None)

Modify a repository.

Parameters:
  • cfg (pulp_smash.config.PulpSmashConfig) – Information about the Pulp host.
  • repo – A dict of information about the repository.
  • base_version – If provided, use a specific repository version instead of the latest one.
  • add_units – A list of dicts of information about the content units to add.
  • remove_units – A list of dicts of information about the content units to remove.
Returns:

The server’s response. A dict of information about the just created modification operation.

pulp_smash.pulp3.utils.publish(cfg, publisher, repo, version_href=None)

Publish a repository.

Parameters:
  • cfg (pulp_smash.config.PulpSmashConfig) – Information about the Pulp host.
  • publisher – A dict of information about the publisher of the repository to be published.
  • repo – A dict of information about the repository.
  • version_href – The repository version to be published.
Returns:

A publication. A dict of information about the just created publication.

pulp_smash.pulp3.utils.require_pulp_3(exc)

Raise an exception if Pulp 3 isn’t under test.

If the same exception should be pased each time this method is called, consider using functools.partial.

Parameters:exc – A class to instantiate and raise as an exception. Its constructor must accept one string argument.
pulp_smash.pulp3.utils.require_pulp_plugins(required_plugins, exc)

Raise an exception if one or more plugins are missing.

If the same exception should be pased each time this method is called, consider using functools.partial.

Parameters:
  • required_plugins – A set of plugin names, e.g. {'pulp-file'}.
  • exc – A class to instantiate and raise as an exception. Its constructor must accept one string argument.
pulp_smash.pulp3.utils.sync(cfg, remote, repo, **kwargs)

Sync a repository.

Parameters:
  • cfg (pulp_smash.config.PulpSmashConfig) – Information about the Pulp host.
  • remote – A dict of information about the remote of the repository to be synced.
  • repo – A dict of information about the repository.
  • kwargs – Keyword arguments to be merged in to the request data.
Returns:

The server’s response. A dict of information about the just created sync.