Skip to content

Commit

Permalink
Add test for non-sls functions
Browse files Browse the repository at this point in the history
  • Loading branch information
m-czernek committed Apr 18, 2024
1 parent 7a7f7a1 commit a63e2a3
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/pytests/unit/modules/test_transactional_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,34 @@ def test_call_fail_explicit_reboot():
assert not reboot_mock.called


def test_call_fail_explicit_reboot_non_sls():
"""
Test transactional_update.call does NOT execute reboot when the word 'reboot'
appears in sls executed with function other than state.sls
"""
return_json = {
"local": {
"cmd_|-reboot_test_|-reboot_|-run": {
"name": "reboot",
"changes": {},
"result": True,
}
}
}
utils_mock = {
"json.find_json": MagicMock(return_value=return_json),
}
salt_mock = {
"cmd.run_all": MagicMock(return_value={"retcode": 0, "stdout": ""}),
}
reboot_mock = MagicMock()
with patch.dict(tu.__utils__, utils_mock), patch.dict(
tu.__salt__, salt_mock
), patch("salt.modules.transactional_update.reboot", reboot_mock):
tu.call("state.test")
assert not reboot_mock.called


def test_sls():
"""Test transactional_update.sls"""
salt_mock = {
Expand Down

0 comments on commit a63e2a3

Please sign in to comment.