mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Add test for getting matchers from __context__ in matchers.confirm_top
This commit is contained in:
parent
4923679536
commit
7017c14ba6
1 changed files with 15 additions and 0 deletions
|
@ -2,6 +2,7 @@ import pytest
|
|||
|
||||
import salt.config
|
||||
import salt.loader
|
||||
from tests.support.mock import patch
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
@ -12,3 +13,17 @@ def matchers(minion_opts):
|
|||
def test_sanity(matchers):
|
||||
match = matchers["confirm_top.confirm_top"]
|
||||
assert match("*", []) is True
|
||||
|
||||
|
||||
@pytest.mark.parametrize("in_context", [False, True])
|
||||
def test_matchers_from_context(matchers, in_context):
|
||||
match = matchers["confirm_top.confirm_top"]
|
||||
with patch.dict(
|
||||
matchers.pack["__context__"], {"matchers": matchers} if in_context else {}
|
||||
), patch("salt.loader.matchers", return_value=matchers) as loader_matchers:
|
||||
assert match("*", []) is True
|
||||
assert id(matchers.pack["__context__"]["matchers"]) == id(matchers)
|
||||
if in_context:
|
||||
loader_matchers.assert_not_called()
|
||||
else:
|
||||
loader_matchers.assert_called_once()
|
||||
|
|
Loading…
Add table
Reference in a new issue