Add test for issue #56093

This commit is contained in:
jeanluc 2022-11-08 15:38:33 +01:00 committed by Megan Wilhite
parent 267e1db235
commit af1b2ff2ef

View file

@ -2,10 +2,11 @@ import pytest
pytestmark = [
pytest.mark.skip_on_windows(reason="salt-ssh not available on Windows"),
pytest.mark.slow_test,
]
@pytest.fixture(scope="module")
@pytest.fixture(scope="module", autouse=True)
def pillar_tree(base_env_pillar_tree_root_dir):
top_file = """
base:
@ -33,8 +34,22 @@ def pillar_tree(base_env_pillar_tree_root_dir):
yield
@pytest.mark.slow_test
def test_pillar_items(salt_ssh_cli, pillar_tree):
@pytest.fixture()
def pillar_filter_by_lookup():
return {
"common": {
"has_common": True,
},
"custom_default": {
"defaulted": True,
},
"merge": {
"merged": True,
},
}
def test_pillar_items(salt_ssh_cli):
"""
test pillar.items with salt-ssh
"""
@ -48,8 +63,7 @@ def test_pillar_items(salt_ssh_cli, pillar_tree):
assert pillar_items["knights"] == ["Lancelot", "Galahad", "Bedevere", "Robin"]
@pytest.mark.slow_test
def test_pillar_get(salt_ssh_cli, pillar_tree):
def test_pillar_get(salt_ssh_cli):
"""
test pillar.get with salt-ssh
"""
@ -59,11 +73,50 @@ def test_pillar_get(salt_ssh_cli, pillar_tree):
assert ret.data == "python"
@pytest.mark.slow_test
def test_pillar_get_doesnotexist(salt_ssh_cli, pillar_tree):
def test_pillar_get_doesnotexist(salt_ssh_cli):
"""
test pillar.get when pillar does not exist with salt-ssh
"""
ret = salt_ssh_cli.run("pillar.get", "doesnotexist")
assert ret.returncode == 0
assert ret.data == ""
def test_pillar_filter_by(salt_ssh_cli, pillar_filter_by_lookup):
"""
test pillar.filter_by with salt-ssh
"""
pillar_filter_by_lookup["python"] = {"filtered": True}
ret = salt_ssh_cli.run(
"pillar.filter_by",
pillar_filter_by_lookup,
pillar="monty",
merge=pillar_filter_by_lookup["merge"],
base="common",
default="custom_default",
)
assert ret.returncode == 0
assert ret.data
assert "has_common" in ret.data
assert "filtered" in ret.data
assert "merged" in ret.data
assert "defaulted" not in ret.data
def test_pillar_filter_by_default(salt_ssh_cli, pillar_filter_by_lookup):
"""
test pillar.filter_by default param with salt-ssh
"""
ret = salt_ssh_cli.run(
"pillar.filter_by",
pillar_filter_by_lookup,
pillar="monty",
merge=pillar_filter_by_lookup["merge"],
base="common",
default="custom_default",
)
assert ret.returncode == 0
assert ret.data
assert "has_common" in ret.data
assert "merged" in ret.data
assert "defaulted" in ret.data