Skip to content

Commit

Permalink
Add test for custom wrapper usage
Browse files Browse the repository at this point in the history
  • Loading branch information
lkubb authored and Megan Wilhite committed Jun 26, 2023
1 parent 1e08e7d commit 560bacd
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/pytests/integration/ssh/test_master.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,30 @@ def _state_tree(salt_master, tmp_path):
yield


@pytest.fixture
def custom_wrapper(salt_run_cli, base_env_state_tree_root_dir):
module_contents = r"""\
def __virtual__():
return "grains_custom"
def items():
return __grains__.value()
"""
module_dir = base_env_state_tree_root_dir / "_wrapper"
module_tempfile = pytest.helpers.temp_file(
"grains_custom.py", module_contents, module_dir
)
try:
with module_tempfile:
ret = salt_run_cli.run("saltutil.sync_wrapper")
assert ret.returncode == 0
assert "wrapper.grains_custom" in ret.data
yield
finally:
ret = salt_run_cli.run("saltutil.sync_wrapper")
assert ret.returncode == 0


@pytest.mark.usefixtures("_state_tree")
def test_state_apply(salt_ssh_cli):
ret = salt_ssh_cli.run("state.apply", "core")
Expand All @@ -77,3 +101,14 @@ def test_state_highstate(salt_ssh_cli):
assert ret.returncode == 0
state_result = StateResult(ret.data)
assert state_result.result is True


@pytest.mark.usefixtures("custom_wrapper")
def test_custom_wrapper(salt_ssh_cli):
ret = salt_ssh_cli.run(
"grains_custom.items",
)
assert ret.returncode == 0
assert ret.data
assert "id" in ret.data
assert ret.data["id"] in ("localhost", "127.0.0.1")

0 comments on commit 560bacd

Please sign in to comment.