forked from saltstack/salt
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed file client private attribute reference on `SaltMakoTemplateLoo…
…kup` Fixes saltstack#64280 Signed-off-by: Pedro Algarvio <[email protected]>
- Loading branch information
Showing
3 changed files
with
33 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fixed file client private attribute reference on `SaltMakoTemplateLookup` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import pytest | ||
|
||
from tests.support.mock import Mock, call, patch | ||
|
||
pytest.importorskip("mako") | ||
|
||
# This import needs to be after the above importorskip so that no ImportError | ||
# is raised if Mako is not installed | ||
from salt.utils.mako import SaltMakoTemplateLookup | ||
|
||
|
||
def test_mako_template_lookup(minion_opts): | ||
""" | ||
The shudown method can be called without raising an exception when the | ||
file_client does not have a destroy method | ||
""" | ||
# Test SaltCacheLoader creating and destroying the file client created | ||
file_client = Mock() | ||
with patch("salt.fileclient.get_file_client", return_value=file_client): | ||
loader = SaltMakoTemplateLookup(minion_opts) | ||
assert loader._file_client is None | ||
assert loader.file_client() is file_client | ||
assert loader._file_client is file_client | ||
try: | ||
loader.destroy() | ||
except AttributeError: | ||
pytest.fail("Regression when calling SaltMakoTemplateLookup.destroy()") | ||
assert file_client.mock_calls == [call.destroy()] |