Skip to content

Commit

Permalink
Rewrite test_modify.py using pytest
Browse files Browse the repository at this point in the history
fixes: #326
  • Loading branch information
git-hyagi committed Jan 29, 2024
1 parent b93b930 commit e09f13c
Show file tree
Hide file tree
Showing 4 changed files with 304 additions and 262 deletions.
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

0 comments on commit e09f13c

Please sign in to comment.