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

Replace usage of _pulp_client with pubtools-pulplib [RHELDST-141] #223

Merged
merged 1 commit into from
Apr 5, 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
52 changes: 18 additions & 34 deletions tests/integration/test_association.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
import json
import logging
import os
import subprocess
import logging

import pytest
import requests
import ubiconfig
import ubipop
import json

from ubipop._pulp_client import Pulp
from ubipop.ubi_manifest_client.client import Client

from pubtools.pulplib import (
Client,
Criteria,
Matcher,
ModulemdDefaultsUnit,
ModulemdUnit,
RpmUnit,
ModulemdDefaultsUnit,
)

import ubipop

PULP_HOSTNAME = os.getenv("TEST_PULP_HOSTNAME")
PULP_USER = os.getenv("TEST_PULP_USER")
PULP_PWD = os.getenv("TEST_PULP_PWD")
Expand Down Expand Up @@ -79,37 +77,23 @@ def run_ubipop_tool(content_set, workers=10, dry_run=False):


def get_repos_from_cs(cs, skip_dot_version=False):
kwargs = {"verify": PULP_SECURE}
if PULP_CERT_PATH is not None:
p = Pulp(
PULP_HOSTNAME, cert=(PULP_CERT_PATH, PULP_KEY_PATH), verify=PULP_SECURE
)
kwargs["cert"] = (PULP_CERT_PATH, PULP_KEY_PATH)
else:
p = Pulp(PULP_HOSTNAME, auth=(PULP_USER, PULP_PWD), verify=PULP_SECURE)

ret = p.do_request(
"post",
"repositories/search/",
{
"criteria": {
"filters": {"notes.content_set": cs},
},
"distributors": False,
},
)

ret.raise_for_status()
kwargs["auth"] = (PULP_USER, PULP_PWD)
p = Client("https://" + PULP_HOSTNAME, **kwargs)

for item in ret.json():
notes = item["notes"]
repos = p.search_repository(Criteria.with_field("notes.content_set", cs))

if skip_dot_version and "." in notes["platform_full_version"]:
for repo in repos:
if skip_dot_version and "." in repo.platform_full_version:
continue

yield {
"id": item["id"],
"name": item["display_name"],
"url": notes["relative_url"],
"arch": notes["arch"],
"id": repo.id,
"url": repo.relative_url,
"arch": repo.arch,
}


Expand Down Expand Up @@ -644,10 +628,10 @@ def test_ubipop_not_filter_module_rpm_with_different_version(pulp_client):
mod_name, mod_profile = separate_modules(modulemds)[1]
assert (
mod_name == "container-tools"
), "Expected modulemd: httpd, found modulemd: {}".format(mod_name)
), "Expected modulemd: container-tools, found modulemd: {}".format(mod_name)
assert (
"common [d]" in mod_profile
), "Modulemd httpd should have common profile as default."
), "Modulemd container-tools should have common profile as default."


@pytest.mark.skipif(INTEGRATION_NOT_SETUP, reason="Integration test is not set up.")
Expand Down
Loading
Loading