-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more test coverage and fix previous failing tests
- Loading branch information
Megan Wilhite
committed
Apr 7, 2023
1 parent
17dcb42
commit e29485e
Showing
9 changed files
with
111 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
tests/pytests/functional/modules/state/test_mako_renderer.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import pytest | ||
|
||
pytestmark = [ | ||
pytest.mark.windows_whitelisted, | ||
] | ||
|
||
|
||
def test_mako_renderer(state, state_tree): | ||
""" | ||
Test mako renderer when running state.sls | ||
""" | ||
sls_contents = """ | ||
#!mako|yaml | ||
%for a in [1,2,3]: | ||
echo ${a}: | ||
cmd.run | ||
%endfor | ||
""" | ||
with pytest.helpers.temp_file("issue-55124.sls", sls_contents, state_tree): | ||
ret = state.sls("issue-55124") | ||
for state_return in ret: | ||
assert state_return.result is True | ||
assert "echo" in state_return.id |
32 changes: 32 additions & 0 deletions
32
tests/pytests/functional/modules/state/test_pyobjects_renderer.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import pytest | ||
|
||
pytestmark = [ | ||
pytest.mark.windows_whitelisted, | ||
] | ||
|
||
|
||
def test_pyobjects_renderer(state, state_tree, tmp_path): | ||
""" | ||
Test pyobjects renderer when running state.sls | ||
""" | ||
sls1_contents = f""" | ||
#!pyobjects | ||
import pathlib | ||
import salt://test_pyobjects2.sls | ||
test_file = pathlib.Path("{str(tmp_path)}", "test") | ||
File.managed(str(test_file), user='root', group='root', mode='1777') | ||
""" | ||
sls2_contents = f""" | ||
#!pyobjects | ||
import pathlib | ||
test_file = pathlib.Path("{str(tmp_path)}", "test2") | ||
File.managed(str(test_file), user='root', group='root', mode='1777') | ||
""" | ||
|
||
with pytest.helpers.temp_file("test_pyobjects.sls", sls1_contents, state_tree): | ||
with pytest.helpers.temp_file("test_pyobjects2.sls", sls2_contents, state_tree): | ||
ret = state.sls("test_pyobjects") | ||
assert not ret.errors | ||
for state_return in ret: | ||
assert state_return.result is True | ||
assert str(tmp_path) in state_return.name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import pytest | ||
|
||
pytestmark = [pytest.mark.skip_unless_on_linux] | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def defaults(modules): | ||
return modules.defaults | ||
|
||
|
||
def test_defaults_get(defaults, state_tree, caplog): | ||
""" | ||
test defaults.get | ||
""" | ||
|
||
json_contents = """ | ||
{ | ||
"users": { | ||
"root": 1 | ||
} | ||
} | ||
""" | ||
path = state_tree / "core" | ||
with pytest.helpers.temp_file("defaults.json", json_contents, path): | ||
assert defaults.get("core:users:root") == 1 | ||
|
||
|
||
def test_defaults_merge(defaults): | ||
""" | ||
test defaults.merge | ||
""" | ||
assert defaults.merge({"a": "b"}, {"d": "e"}) == {"a": "b", "d": "e"} | ||
|
||
|
||
def test_defaults_deepcopy(defaults): | ||
""" | ||
test defaults.deepcopy | ||
""" | ||
test_dict = {"1": "one"} | ||
assert defaults.deepcopy(test_dict) == test_dict |