mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Switch to existing test fixtures
This commit is contained in:
parent
f25bbaf744
commit
063adf0493
1 changed files with 7 additions and 41 deletions
|
@ -1,65 +1,31 @@
|
|||
"""
|
||||
tests.pytests.unit.test_config
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Unit tests for salt.fileclient
|
||||
"""
|
||||
|
||||
import salt.config
|
||||
from salt import fileclient
|
||||
import salt.fileclient as fileclient
|
||||
from tests.support.mock import MagicMock, patch
|
||||
|
||||
|
||||
def _defaults(**kwargs):
|
||||
"""
|
||||
master/minion config defaults
|
||||
"""
|
||||
ret = {
|
||||
"saltenv": kwargs.pop("saltenv", None),
|
||||
"id": "test",
|
||||
"cachedir": "/A",
|
||||
"sock_dir": "/B",
|
||||
"root_dir": "/C",
|
||||
"fileserver_backend": "roots",
|
||||
"open_mode": False,
|
||||
"auto_accept": False,
|
||||
"file_roots": {},
|
||||
"pillar_roots": {},
|
||||
"file_ignore_glob": [],
|
||||
"file_ignore_regex": [],
|
||||
"worker_threads": 5,
|
||||
"hash_type": "sha256",
|
||||
"log_file": "foo.log",
|
||||
"ssl": True,
|
||||
"file_client": "local",
|
||||
}
|
||||
ret.update(kwargs)
|
||||
return ret
|
||||
|
||||
|
||||
def test_master_no_fs_update():
|
||||
def test_master_no_fs_update(master_opts):
|
||||
"""
|
||||
Test that an FSClient spawned from the master does not cause fileserver
|
||||
backends to be refreshed on instantiation. The master already has the
|
||||
maintenance thread for that.
|
||||
"""
|
||||
opts = salt.config.apply_master_config(defaults=_defaults())
|
||||
master_opts["file_client"] = "local"
|
||||
fileserver = MagicMock()
|
||||
|
||||
with patch("salt.fileserver.Fileserver", fileserver):
|
||||
client = fileclient.FSClient(opts)
|
||||
client = fileclient.FSClient(master_opts)
|
||||
assert client.channel.fs.update.call_count == 0
|
||||
|
||||
|
||||
def test_masterless_fs_update():
|
||||
def test_masterless_fs_update(minion_opts):
|
||||
"""
|
||||
Test that an FSClient spawned from a masterless run refreshes the
|
||||
fileserver backends. This is necessary to ensure that a masterless run
|
||||
can access any configured gitfs remotes.
|
||||
"""
|
||||
opts = salt.config.apply_minion_config(defaults=_defaults())
|
||||
minion_opts["file_client"] = "local"
|
||||
fileserver = MagicMock()
|
||||
|
||||
with patch("salt.fileserver.Fileserver", fileserver):
|
||||
client = fileclient.FSClient(opts)
|
||||
client = fileclient.FSClient(minion_opts)
|
||||
assert client.channel.fs.update.call_count == 1
|
||||
|
|
Loading…
Add table
Reference in a new issue