From 5bfee90f2ccf432d252205fead2587b957f717ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hozza?= Date: Mon, 5 Aug 2024 10:18:30 +0200 Subject: [PATCH] test_depsolve.py: support testing depsolving of multiple transactions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Until now, the unit test tested only very simple case with a single transaction, which happens only for vanilla images. Any user customization would result in multiple transactions in the depsolve request. This case is not yet tested at all. Signed-off-by: Tomáš Hozza --- tools/test/test_depsolve.py | 47 +++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/tools/test/test_depsolve.py b/tools/test/test_depsolve.py index 12ccbac2..20081de4 100644 --- a/tools/test/test_depsolve.py +++ b/tools/test/test_depsolve.py @@ -34,7 +34,7 @@ def assert_dnf(): raise RuntimeError("Cannot import libdnf") -def depsolve(pkgs, repos, root_dir, cache_dir, dnf_config, opt_metadata) -> Tuple[dict, int]: +def depsolve(transactions, repos, root_dir, cache_dir, dnf_config, opt_metadata) -> Tuple[dict, int]: req = { "command": "depsolve", "arch": ARCH, @@ -45,12 +45,7 @@ def depsolve(pkgs, repos, root_dir, cache_dir, dnf_config, opt_metadata) -> Tupl "root_dir": root_dir, "repos": repos, "optional-metadata": opt_metadata, - "transactions": [ - { - "package-specs": pkgs, - "exclude-specs": None - }, - ] + "transactions": transactions, } } @@ -92,7 +87,13 @@ def repo_servers_fixture(): test_cases = [ { - "packages": ["filesystem"], + "transactions": [ + { + "package-specs": [ + "filesystem", + ], + }, + ], "results": { "packages": { "basesystem", @@ -117,14 +118,27 @@ test_cases = [ }, { # "pkg-with-no-deps" is the only package in the custom repo and has no dependencies - "packages": ["pkg-with-no-deps"], + "transactions": [ + { + "package-specs": [ + "pkg-with-no-deps", + ], + }, + ], "results": { "packages": {"pkg-with-no-deps"}, "reponames": {"custom"}, }, }, { - "packages": ["filesystem", "pkg-with-no-deps"], + "transactions": [ + { + "package-specs": [ + "filesystem", + "pkg-with-no-deps" + ], + }, + ], "results": { "packages": { "basesystem", @@ -150,7 +164,14 @@ test_cases = [ }, }, { - "packages": ["tmux", "pkg-with-no-deps"], + "transactions": [ + { + "package-specs": [ + "tmux", + "pkg-with-no-deps", + ], + }, + ], "results": { "packages": { "alternatives", @@ -285,11 +306,11 @@ def test_depsolve(tmp_path, repo_servers, dnf_config, detect_fn, test_case): except RuntimeError as e: pytest.skip(e) - pks = test_case["packages"] + transactions = test_case["transactions"] for repo_configs, root_dir, opt_metadata in config_combos(tmp_path, repo_servers): with TemporaryDirectory() as cache_dir: - res, exit_code = depsolve(pks, repo_configs, root_dir, cache_dir, dnf_config, opt_metadata) + res, exit_code = depsolve(transactions, repo_configs, root_dir, cache_dir, dnf_config, opt_metadata) assert exit_code == 0 assert {pkg["name"] for pkg in res["packages"]} == test_case["results"]["packages"] assert res["repos"].keys() == test_case["results"]["reponames"]