From caba94db515af5f162431118a14ea612f34ddb18 Mon Sep 17 00:00:00 2001 From: Tobias Grigo Date: Thu, 12 Oct 2023 12:13:51 +0200 Subject: [PATCH] Add a dedicated content filter test [noissue] --- .../tests/functional/api/test_api_filters.py | 71 +++++++++++++++++++ pulp_deb/tests/functional/api/test_sync.py | 66 ++++++++--------- 2 files changed, 104 insertions(+), 33 deletions(-) create mode 100644 pulp_deb/tests/functional/api/test_api_filters.py diff --git a/pulp_deb/tests/functional/api/test_api_filters.py b/pulp_deb/tests/functional/api/test_api_filters.py new file mode 100644 index 000000000..0de8a0e8e --- /dev/null +++ b/pulp_deb/tests/functional/api/test_api_filters.py @@ -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 diff --git a/pulp_deb/tests/functional/api/test_sync.py b/pulp_deb/tests/functional/api/test_sync.py index 9a137b7a5..3cdbcbe79 100644 --- a/pulp_deb/tests/functional/api/test_sync.py +++ b/pulp_deb/tests/functional/api/test_sync.py @@ -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