Add unit test for repack_pkgs function

This commit is contained in:
Pablo Suárez Hernández 2022-05-03 11:55:55 +01:00
parent 113e5de656
commit 8001a568e0
No known key found for this signature in database
GPG key ID: A9683F02B512C911

View file

@ -7,6 +7,7 @@ import salt.modules.pkg_resource as pkg_resource
import salt.utils.data
import salt.utils.yaml
import yaml
from salt.exceptions import CommandExecutionError
from tests.support.mock import MagicMock, patch
@ -223,6 +224,17 @@ def test_format_pkg_list_with_attr():
assert sorted(pkgs) == sorted(expected_pkg_list)
def test_repack_pkgs():
"""
Test to check that repack function is raising error in case of
package name collisions
"""
assert pkg_resource._repack_pkgs([{"A": "a"}])
assert pkg_resource._repack_pkgs([{"A": "a"}, {"B": "b"}])
with pytest.raises(CommandExecutionError):
assert pkg_resource._repack_pkgs([{"A": "a"}, {"A": "c"}])
def test_stringify():
"""
Test to takes a dict of package name/version information