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

Rewrite test_modify.py using pytest #333

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGES/326.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Rewritten test_modify.py using pytest.
32 changes: 8 additions & 24 deletions pulp_ostree/tests/functional/api/test_filter.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,17 @@
import pytest

from pulp_ostree.tests.functional.constants import OSTREE_FIXTURE_URL


@pytest.fixture
def synced_repo(
ostree_repositories_api_client, ostree_repository_factory, ostree_remote_factory, monitor_task
):
"""
Fixture that syncs a Remote ostree Repository,
waits until the sync task completes and returns the
created repository object.
"""
repo = ostree_repository_factory()
remote = ostree_remote_factory(url=OSTREE_FIXTURE_URL, policy="immediate")
result = ostree_repositories_api_client.sync(repo.pulp_href, {"remote": remote.pulp_href})
monitor_task(result.task)
return ostree_repositories_api_client.read(repo.pulp_href)


@pytest.mark.parallel
def test_filter_refs(
ostree_content_refs_api_client,
ostree_content_commits_api_client,
synced_repo,
synced_repo_version,
):
"""Check if refs can be filtered by their names and related commits' checksums."""
# check by name
_, _, repo = synced_repo_version
refs_stable = ostree_content_refs_api_client.list(
repository_version_added=synced_repo.latest_version_href, name="stable"
repository_version_added=repo.latest_version_href, name="stable"
).to_dict()

assert refs_stable["count"] == 1, refs_stable
Expand All @@ -37,7 +20,7 @@ def test_filter_refs(
# check by commit
commit = ostree_content_commits_api_client.read(refs_stable["results"][0]["commit"])
refs_commit_checksum = ostree_content_refs_api_client.list(
repository_version_added=synced_repo.latest_version_href, checksum=commit.checksum
repository_version_added=repo.latest_version_href, checksum=commit.checksum
).to_dict()

assert refs_commit_checksum["count"] == 1, refs_commit_checksum
Expand All @@ -48,16 +31,17 @@ def test_filter_refs(
def test_filter_commits(
ostree_content_refs_api_client,
ostree_content_commits_api_client,
synced_repo,
synced_repo_version,
):
"""Check if commits can be filtered by their checksums."""
_, _, repo = synced_repo_version
refs_rawhide = ostree_content_refs_api_client.list(
repository_version_added=synced_repo.latest_version_href, name="rawhide"
repository_version_added=repo.latest_version_href, name="rawhide"
).to_dict()
ref_rawhide = refs_rawhide["results"][0]

commits_rawhide = ostree_content_commits_api_client.list(
repository_version_added=synced_repo.latest_version_href,
repository_version_added=repo.latest_version_href,
checksum=ref_rawhide["checksum"],
).to_dict()
assert commits_rawhide["count"] == 1, commits_rawhide
Expand Down
Loading
Loading