mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
parent
88b08f6d8d
commit
de572d2233
3 changed files with 9 additions and 11 deletions
|
@ -43,9 +43,6 @@ class NamedLoaderContext(collections.abc.MutableMapping):
|
|||
self.loader_context = loader_context
|
||||
self.default = default
|
||||
|
||||
def with_default(self, default):
|
||||
return NamedLoaderContext(self.name, self.loader_context, default=default)
|
||||
|
||||
def loader(self):
|
||||
"""
|
||||
The LazyLoader in the current context. This will return None if there
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
import pathlib
|
||||
|
||||
import salt.loader.context
|
||||
import salt.loader.lazy
|
||||
import salt.utils.files
|
||||
import tests.support.helpers
|
||||
|
||||
|
||||
def test_opts_dunder_opts_without_import(tmp_path):
|
||||
def xtest_opts_dunder_opts_without_import(tempdir):
|
||||
"""
|
||||
Test __opts__ without being imported.
|
||||
|
||||
|
@ -12,7 +14,7 @@ def test_opts_dunder_opts_without_import(tmp_path):
|
|||
salt.loader.dunder the __opts__ object will be a dictionary.
|
||||
"""
|
||||
opts = {"optimization_order": [0, 1, 2]}
|
||||
with salt.utils.files.fopen(tmp_path / "mymod.py", "w") as fp:
|
||||
with salt.utils.files.fopen(pathlib.Path(tempdir.tempdir) / "mymod.py", "w") as fp:
|
||||
fp.write(
|
||||
tests.support.helpers.dedent(
|
||||
"""
|
||||
|
@ -21,11 +23,11 @@ def test_opts_dunder_opts_without_import(tmp_path):
|
|||
"""
|
||||
)
|
||||
)
|
||||
loader = salt.loader.lazy.LazyLoader([tmp_path], opts)
|
||||
loader = salt.loader.lazy.LazyLoader([tempdir.tempdir], opts)
|
||||
assert type(loader["mymod.mymethod"]()) == dict
|
||||
|
||||
|
||||
def test_opts_dunder_opts_with_import(tmp_path):
|
||||
def test_opts_dunder_opts_with_import(tempdir):
|
||||
"""
|
||||
Test __opts__ when imported.
|
||||
|
||||
|
@ -33,7 +35,7 @@ def test_opts_dunder_opts_with_import(tmp_path):
|
|||
salt.loader.dunder the __opts__ object will be a NamedLoaderContext.
|
||||
"""
|
||||
opts = {"optimization_order": [0, 1, 2]}
|
||||
with salt.utils.files.fopen(tmp_path / "mymod.py", "w") as fp:
|
||||
with salt.utils.files.fopen(pathlib.Path(tempdir.tempdir) / "mymod.py", "w") as fp:
|
||||
fp.write(
|
||||
tests.support.helpers.dedent(
|
||||
"""
|
||||
|
@ -45,6 +47,6 @@ def test_opts_dunder_opts_with_import(tmp_path):
|
|||
"""
|
||||
)
|
||||
)
|
||||
loader = salt.loader.lazy.LazyLoader([tmp_path], opts)
|
||||
loader = salt.loader.lazy.LazyLoader([tempdir.tempdir], opts)
|
||||
assert loader["mymod.optstype"]() == salt.loader.context.NamedLoaderContext
|
||||
assert loader["mymod.opts"]() == opts
|
||||
|
|
|
@ -11,7 +11,6 @@ import salt.modules.yumpkg as yumpkg
|
|||
import salt.states.beacon as beaconstate
|
||||
import salt.states.pkg as pkg
|
||||
import salt.utils.state as state_utils
|
||||
from salt.loader.dunder import __opts__
|
||||
from salt.utils.event import SaltEvent
|
||||
from tests.support.mock import MagicMock, patch
|
||||
|
||||
|
@ -22,7 +21,7 @@ log = logging.getLogger(__name__)
|
|||
def configure_loader_modules(minion_opts):
|
||||
return {
|
||||
cp: {
|
||||
"__opts__": __opts__.with_default(minion_opts),
|
||||
"__opts__": minion_opts,
|
||||
},
|
||||
pkg: {
|
||||
"__env__": "base",
|
||||
|
|
Loading…
Add table
Reference in a new issue