Skip to content

Commit

Permalink
Add a dedicated content filter test
Browse files Browse the repository at this point in the history
[noissue]
  • Loading branch information
hstct committed Oct 12, 2023
1 parent 8ca8fbe commit caba94d
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 33 deletions.
71 changes: 71 additions & 0 deletions pulp_deb/tests/functional/api/test_api_filters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import pytest

from pulp_deb.tests.functional.constants import DEB_FIXTURE_SINGLE_DIST, DEB_FIXTURE_UPDATE_REPOSITORY_NAME


@pytest.fixture
def deb_content_filters_init(deb_init_and_sync):

def _deb_content_filters_init():
remote_args = {"distributions": DEB_FIXTURE_SINGLE_DIST}
repo, _ = deb_init_and_sync(remote_args=remote_args)
repo_v1_href = repo.latest_version_href
assert repo_v1_href.endswith("/1/")

repo, _ = deb_init_and_sync(
repository=repo,
url=DEB_FIXTURE_UPDATE_REPOSITORY_NAME,
remote_args=remote_args
)
repo_v2_href = repo.latest_version_href
assert repo_v2_href.endswith("/2/")
return (repo, repo_v1_href, repo_v2_href)

return _deb_content_filters_init


@pytest.fixture
def deb_content_filters_get_hrefs(apt_release_api, apt_release_component_api):

def _deb_content_filters_get_hrefs(repo_version_href, component):
releases = apt_release_api.list(repository_version=repo_version_href)
release_href = releases.results[0].pulp_href
release_components = apt_release_component_api.list(repository_version=repo_version_href)
rc = [x for x in release_components.results if x.component == component]
rc_href = rc[0].pulp_href
return (release_href, rc_href)

return _deb_content_filters_get_hrefs

@pytest.mark.parallel
def test_content_filters(
deb_content_filters_init,
deb_content_filters_get_hrefs,
apt_package_api,
apt_release_api,
apt_release_component_api
):
repo, repo_v1_href, repo_v2_href = deb_content_filters_init()
assert repo_v1_href.endswith("/1/")
assert repo_v2_href.endswith("/2/")

release_href, rc_href = deb_content_filters_get_hrefs(repo_v2_href, "asgard")

assert apt_package_api.list(release=f"{release_href},{repo_v1_href}").count == 4
assert apt_package_api.list(release=f"{release_href},{repo_v2_href}").count == 6
assert apt_package_api.list(release=f"{release_href},{repo.pulp_href}").count == 6

assert apt_package_api.list(release_component=f"{rc_href},{repo_v1_href}").count == 3
assert apt_package_api.list(release_component=f"{rc_href},{repo_v2_href}").count == 5
packages = apt_package_api.list(release_component=f"{rc_href},{repo.pulp_href}")
assert packages.count == 5

package_href = [x for x in packages.results if x.package == "heimdallr"][0].pulp_href

assert apt_release_api.list(package=f"{package_href},{repo_v1_href}").count == 0
assert apt_release_api.list(package=f"{package_href},{repo_v2_href}").count == 1
assert apt_release_api.list(package=f"{package_href},{repo.pulp_href}").count == 1

assert apt_release_component_api.list(package=f"{package_href},{repo_v1_href}").count == 0
assert apt_release_component_api.list(package=f"{package_href},{repo_v2_href}").count == 1
assert apt_release_component_api.list(package=f"{package_href},{repo.pulp_href}").count == 1
66 changes: 33 additions & 33 deletions pulp_deb/tests/functional/api/test_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,39 +268,39 @@ def test_sync_optimize_skip_unchanged_package_index(
assert not is_sync_skipped(task_diff, DEB_REPORT_CODE_SKIP_RELEASE)
assert is_sync_skipped(task_diff, DEB_REPORT_CODE_SKIP_PACKAGE)

# === Test whether the content filters are working. ===
# This doesn't _technically_ have anything to do with testing syncing, but it's a
# convenient place to do it since we've already created a repo with content and
# multiple versions. Repo version 1 synced from debian/ragnarok and version 2 synced
# from debian-update/ragnarok.
releases = apt_release_api.list(repository_version=repo_v2_href)
assert releases.count == 1
release_href = releases.results[0].pulp_href
release_components = apt_release_component_api.list(repository_version=repo_v2_href)
assert release_components.count == 2
rc = [x for x in release_components.results if x.component == "asgard"]
rc_href = rc[0].pulp_href

# some simple "happy path" tests to ensure the filters are working properly
assert apt_package_api.list(release=f"{release_href},{repo_v1_href}").count == 4
assert apt_package_api.list(release=f"{release_href},{repo_v2_href}").count == 6
assert apt_package_api.list(release=f"{release_href},{repo.pulp_href}").count == 6

assert apt_package_api.list(release_component=f"{rc_href},{repo_v1_href}").count == 3
assert apt_package_api.list(release_component=f"{rc_href},{repo_v2_href}").count == 5
assert apt_package_api.list(release_component=f"{rc_href},{repo.pulp_href}").count == 5

packages = apt_package_api.list(release_component=f"{rc_href},{repo.pulp_href}")
# The package that was added to asgard in debian-update.
package_href = [x for x in packages.results if x.package == "heimdallr"][0].pulp_href

assert apt_release_api.list(package=f"{package_href},{repo_v1_href}").count == 0
assert apt_release_api.list(package=f"{package_href},{repo_v2_href}").count == 1
assert apt_release_api.list(package=f"{package_href},{repo.pulp_href}").count == 1

assert apt_release_component_api.list(package=f"{package_href},{repo_v1_href}").count == 0
assert apt_release_component_api.list(package=f"{package_href},{repo_v2_href}").count == 1
assert apt_release_component_api.list(package=f"{package_href},{repo.pulp_href}").count == 1
# # === Test whether the content filters are working. ===
# # This doesn't _technically_ have anything to do with testing syncing, but it's a
# # convenient place to do it since we've already created a repo with content and
# # multiple versions. Repo version 1 synced from debian/ragnarok and version 2 synced
# # from debian-update/ragnarok.
# releases = apt_release_api.list(repository_version=repo_v2_href)
# assert releases.count == 1
# release_href = releases.results[0].pulp_href
# release_components = apt_release_component_api.list(repository_version=repo_v2_href)
# assert release_components.count == 2
# rc = [x for x in release_components.results if x.component == "asgard"]
# rc_href = rc[0].pulp_href
#
# # some simple "happy path" tests to ensure the filters are working properly
# assert apt_package_api.list(release=f"{release_href},{repo_v1_href}").count == 4
# assert apt_package_api.list(release=f"{release_href},{repo_v2_href}").count == 6
# assert apt_package_api.list(release=f"{release_href},{repo.pulp_href}").count == 6
#
# assert apt_package_api.list(release_component=f"{rc_href},{repo_v1_href}").count == 3
# assert apt_package_api.list(release_component=f"{rc_href},{repo_v2_href}").count == 5
# assert apt_package_api.list(release_component=f"{rc_href},{repo.pulp_href}").count == 5
#
# packages = apt_package_api.list(release_component=f"{rc_href},{repo.pulp_href}")
# # The package that was added to asgard in debian-update.
# package_href = [x for x in packages.results if x.package == "heimdallr"][0].pulp_href
#
# assert apt_release_api.list(package=f"{package_href},{repo_v1_href}").count == 0
# assert apt_release_api.list(package=f"{package_href},{repo_v2_href}").count == 1
# assert apt_release_api.list(package=f"{package_href},{repo.pulp_href}").count == 1
#
# assert apt_release_component_api.list(package=f"{package_href},{repo_v1_href}").count == 0
# assert apt_release_component_api.list(package=f"{package_href},{repo_v2_href}").count == 1
# assert apt_release_component_api.list(package=f"{package_href},{repo.pulp_href}").count == 1


@pytest.mark.parallel
Expand Down

0 comments on commit caba94d

Please sign in to comment.