Skip to content

Commit

Permalink
WIP: Add duplicate package tests
Browse files Browse the repository at this point in the history
  • Loading branch information
quba42 committed Nov 9, 2023
1 parent 36d1520 commit 2e2d11f
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 0 deletions.
47 changes: 47 additions & 0 deletions pulp_deb/tests/functional/api/test_duplicate_packages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"""Tests that perform actions over packages."""
from uuid import uuid4

from pulp_deb.tests.functional.constants import DEB_PACKAGE_RELPATH
from pulp_deb.tests.functional.utils import (
get_local_package_absolute_path,
get_local_duplicate_package_absolute_path,
)


def test_upload_package_and_duplicate(
deb_get_repository_by_href,
deb_package_factory,
deb_repository_factory,
):
"""Test whether uploading a structured package works and creates the correct paths."""
attrs = {
"file": get_local_package_absolute_path(DEB_PACKAGE_RELPATH),
"relative_path": DEB_PACKAGE_RELPATH,
"distribution": str(uuid4()),
"component": str(uuid4()),
}

repository = deb_repository_factory()
assert repository.latest_version_href.endswith("/0/")
repository_href = repository.pulp_href
attrs["repository"] = repository_href

deb_package_factory(**attrs)
repository = deb_get_repository_by_href(repository_href)
assert repository.latest_version_href.endswith("/1/")
# TODO: Assert the added content counts on the new repo version!

attrs["file"] = get_local_duplicate_package_absolute_path(DEB_PACKAGE_RELPATH)
deb_package_factory(**attrs)
repository = deb_get_repository_by_href(repository_href)
assert repository.latest_version_href.endswith("/2/")
# TODO: Assert the added and removed content counts on the new repo version!


# TODO: Add a second test for the following workflow:
# NAME=duplicate-upload-test
# PACAKGE_HREF_1=$(pulp deb content upload --file=frigg_1.0_ppc64.deb | jq -r .pulp_href)
# PACAKGE_HREF_2=$(pulp deb content upload --file=duplicates/frigg_1.0_ppc64.deb | jq -r .pulp_href)
# pulp deb repository create --name=${NAME}
# pulp deb repository content modify --repository=${NAME} \
# --add-content "[{\"pulp_href\": \"${PACAKGE_HREF_1}\"}, {\"pulp_href\": \"${PACAKGE_HREF_2}\"}]"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is a duplicate of the package with a different checksum!
Binary file not shown.
11 changes: 11 additions & 0 deletions pulp_deb/tests/functional/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,17 @@ def get_local_package_absolute_path(package_name):
return p.joinpath(f"data/packages/{package_name}")


def get_local_duplicate_package_absolute_path(package_name):
"""Looks up the local package of the given name under the relative path
'data/packages/' and returns the absolute path.
:param package_name: Name of the package to look up.
:returns: The absolute path to the package.
"""
p = Path(__file__).parent.absolute()
return p.joinpath(f"data/packages/duplicates/{package_name}")


def gen_distribution(**kwargs):
"""Returns a semi-random dict for use in creating a Distribution."""
data = {"base_path": str(uuid4()), "name": str(uuid4())}
Expand Down

0 comments on commit 2e2d11f

Please sign in to comment.