forked from saltstack/salt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move tests to pytests dir and reformat them
- Loading branch information
1 parent
93ac7a2
commit 1d4c92c
Showing
2 changed files
with
65 additions
and
63 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,65 @@ | ||
""" | ||
tests.pytests.unit.test_config | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
Unit tests for salt.fileclient | ||
""" | ||
|
||
import salt.config | ||
from salt import 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(): | ||
""" | ||
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()) | ||
fileserver = MagicMock() | ||
|
||
with patch("salt.fileserver.Fileserver", fileserver): | ||
client = fileclient.FSClient(opts) | ||
assert client.channel.fs.update.call_count == 0 | ||
|
||
|
||
def test_masterless_fs_update(): | ||
""" | ||
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()) | ||
fileserver = MagicMock() | ||
|
||
with patch("salt.fileserver.Fileserver", fileserver): | ||
client = fileclient.FSClient(opts) | ||
assert client.channel.fs.update.call_count == 1 |
This file was deleted.
Oops, something went wrong.