From 3743654178d01b221c4f5c838c3c3f69edf7e2b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hozza?= Date: Fri, 14 Feb 2025 13:29:54 +0100 Subject: [PATCH] tools/test/depsolve: clean up test_depsolve_result_api() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `test_depsolve_result_api()` test case was parametrized based on `dnf_config`, but in reality, the `depsolve()` call always used an empty dict as `dnf_config`. Effectively, it was being tested three times with DNF4. In addition, don't pass optional arguments to `depsolve()`. Signed-off-by: Tomáš Hozza --- tools/test/test_depsolve.py | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/tools/test/test_depsolve.py b/tools/test/test_depsolve.py index e6410b61..68a8d5fd 100644 --- a/tools/test/test_depsolve.py +++ b/tools/test/test_depsolve.py @@ -1544,18 +1544,17 @@ def test_search(tmp_path, repo_servers, dnf_config, detect_fn, test_case): assert n_filelist_files == 0 -@pytest.mark.parametrize("dnf_config, detect_fn", [ - (None, assert_dnf), - ('{"use_dnf5": false}', assert_dnf), - ('{"use_dnf5": true}', assert_dnf5), -], ids=["no-config", "dnf4", "dnf5"]) -def test_depsolve_result_api(tmp_path, repo_servers, dnf_config, detect_fn): +def test_depsolve_result_api(tmp_path, repo_servers): + """ + Test the result of depsolve() API. + + Note tha this test runs only with dnf4, as the dnf5 depsolver does not support modules. + """ try: - detect_fn() + assert_dnf() except RuntimeError as e: pytest.skip(str(e)) - root_dir = tmp_path.as_posix() cache_dir = (tmp_path / "depsolve-cache").as_posix() transactions = [ { @@ -1564,19 +1563,8 @@ def test_depsolve_result_api(tmp_path, repo_servers, dnf_config, detect_fn): }, ] - repo_configs = [] - for server in repo_servers: - repo_configs.append({ - "id": server["name"], - "name": server["name"], - "baseurl": server["address"], - "gpgkeys": [TEST_KEY + server["name"]], - }) - dnf_config = {} - opt_metadata = [] - with_sbom = False - - res, exit_code = depsolve(transactions, cache_dir, dnf_config, repo_configs, root_dir, opt_metadata, with_sbom) + repo_configs = [gen_repo_config(server) for server in repo_servers] + res, exit_code = depsolve(transactions, cache_dir, repos=repo_configs) assert exit_code == 0 # If any of this changes, increase: