Skip to content

Commit

Permalink
Move tests to pytests dir and reformat them
Browse files Browse the repository at this point in the history
  • Loading branch information
terminalmage committed Feb 6, 2024
1 parent 93ac7a2 commit 1d4c92c
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 63 deletions.
65 changes: 65 additions & 0 deletions tests/pytests/unit/test_fileclient.py
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
63 changes: 0 additions & 63 deletions tests/unit/test_fileclient.py

This file was deleted.

0 comments on commit 1d4c92c

Please sign in to comment.