mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Make sure dict keys are lowercase
This commit is contained in:
parent
0c05af434a
commit
d78245ce35
5 changed files with 50 additions and 4 deletions
2
changelog/66290.fixed.md
Normal file
2
changelog/66290.fixed.md
Normal file
|
@ -0,0 +1,2 @@
|
|||
Chocolatey: Make sure the return dictionary from ``chocolatey.version``
|
||||
contains lowercase keys
|
|
@ -1157,8 +1157,8 @@ def version(name, check_remote=False, source=None, pre_versions=False):
|
|||
if installed:
|
||||
for pkg in installed:
|
||||
if lower_name == pkg.lower():
|
||||
packages.setdefault(pkg, {})
|
||||
packages[pkg]["installed"] = installed[pkg]
|
||||
packages.setdefault(lower_name, {})
|
||||
packages[lower_name]["installed"] = installed[pkg]
|
||||
|
||||
if check_remote:
|
||||
# If there's a remote package available, then also include that
|
||||
|
@ -1169,8 +1169,8 @@ def version(name, check_remote=False, source=None, pre_versions=False):
|
|||
if available:
|
||||
for pkg in available:
|
||||
if lower_name == pkg.lower():
|
||||
packages.setdefault(pkg, {})
|
||||
packages[pkg]["available"] = available[pkg]
|
||||
packages.setdefault(lower_name, {})
|
||||
packages[lower_name]["available"] = available[pkg]
|
||||
|
||||
return packages
|
||||
|
||||
|
|
|
@ -109,6 +109,13 @@ def vim(chocolatey_mod):
|
|||
chocolatey_mod.uninstall(name="vim", force=True)
|
||||
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
def everything(chocolatey_mod):
|
||||
chocolatey_mod.install(name="everything", version="1.4.1935")
|
||||
yield
|
||||
chocolatey_mod.uninstall(name="everything", force=True)
|
||||
|
||||
|
||||
def test_installed_latest(clean, chocolatey, chocolatey_mod):
|
||||
chocolatey.installed(name="vim")
|
||||
result = chocolatey_mod.version(name="vim")
|
||||
|
@ -122,6 +129,14 @@ def test_installed_version(clean, chocolatey, chocolatey_mod):
|
|||
assert result["vim"]["installed"][0] == "9.0.1672"
|
||||
|
||||
|
||||
def test_installed_version_existing_capitalization(
|
||||
everything, chocolatey, chocolatey_mod
|
||||
):
|
||||
result = chocolatey.installed(name="everything", version="1.4.11024")
|
||||
expected_changes = {"Everything": {"new": ["1.4.11024"], "old": ["1.4.1935"]}}
|
||||
assert result["changes"] == expected_changes
|
||||
|
||||
|
||||
def test_uninstalled(vim, chocolatey, chocolatey_mod):
|
||||
chocolatey.uninstalled(name="vim")
|
||||
result = chocolatey_mod.version(name="vim")
|
||||
|
|
|
@ -109,6 +109,13 @@ def vim(chocolatey_mod):
|
|||
chocolatey_mod.uninstall(name="vim", force=True)
|
||||
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
def everything(chocolatey_mod):
|
||||
chocolatey_mod.install(name="everything", version="1.4.1935")
|
||||
yield
|
||||
chocolatey_mod.uninstall(name="everything", force=True)
|
||||
|
||||
|
||||
def test_installed_latest(clean, chocolatey, chocolatey_mod):
|
||||
chocolatey.installed(name="vim")
|
||||
result = chocolatey_mod.version(name="vim")
|
||||
|
@ -122,6 +129,14 @@ def test_installed_version(clean, chocolatey, chocolatey_mod):
|
|||
assert result["vim"]["installed"][0] == "9.0.1672"
|
||||
|
||||
|
||||
def test_installed_version_existing_capitalization(
|
||||
everything, chocolatey, chocolatey_mod
|
||||
):
|
||||
result = chocolatey.installed(name="everything", version="1.4.11024")
|
||||
expected_changes = {"Everything": {"new": ["1.4.11024"], "old": ["1.4.1935"]}}
|
||||
assert result["changes"] == expected_changes
|
||||
|
||||
|
||||
def test_uninstalled(vim, chocolatey, chocolatey_mod):
|
||||
chocolatey.uninstalled(name="vim")
|
||||
result = chocolatey_mod.version(name="vim")
|
||||
|
|
|
@ -208,6 +208,20 @@ def test_version_check_remote_true():
|
|||
assert result == expected
|
||||
|
||||
|
||||
def test_version_check_remote_true_capitalization():
|
||||
"""
|
||||
Test version when remote is True
|
||||
"""
|
||||
list_side_effect = [
|
||||
{"Ack": ["3.1.1"]},
|
||||
{"Ack": ["3.1.1"], "Wolfpack": ["3.0.17"], "blackbird": ["1.0.79.3"]},
|
||||
]
|
||||
with patch.object(chocolatey, "list_", side_effect=list_side_effect):
|
||||
expected = {"ack": {"available": ["3.1.1"], "installed": ["3.1.1"]}}
|
||||
result = chocolatey.version("ack", check_remote=True)
|
||||
assert result == expected
|
||||
|
||||
|
||||
def test_version_check_remote_true_not_available():
|
||||
"""
|
||||
Test version when remote is True but remote version is unavailable
|
||||
|
|
Loading…
Add table
Reference in a new issue