Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add publication() #1194

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions pulp_smash/pulp3/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,27 @@ def publish(cfg, publisher, repo, version_href=None):
return client.get(tasks[-1]["created_resources"][0])


def publication(cfg, path, repo, version_href=None, **kwargs):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides @rochacbruno comments.

path is not listed in the docstrings.

**kwargs not used in the code.

"""Create a publication.

:param pulp_smash.config.PulpSmashConfig cfg: Information about the Pulp
host.
:param repo: A dict of information about the repository.
:param version_href: The repository version to be published.
:returns: A publication. A dict of information about the just created
publication.
"""

if version_href is None:
data = {"repository": repo["_href"]}
else:
data = {"repository_version": version_href}
client = api.Client(cfg, api.json_handler)
call_report = client.post(path, data)
tasks = tuple(api.poll_spawned_tasks(cfg, call_report))
return client.get(tasks[-1]["created_resources"][0])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The task_handler already does this for generic task based resource creation
https://github.com/PulpQE/pulp-smash/blob/master/pulp_smash/api.py#L205-L268

The only difference right now is that it is reading tasks[0] assuming it has only one, we can change to read tasks[-1] or make it a parameter.



def _build_content_fetcher(content_field):
"""Build closure for fetching content from a repository.

Expand Down