Skip to content

Commit 596a36b

Browse files
committed
Fix CI test failures introduced by resources branch
- salt/states/saltutil.py: add sync_resources() state function to match the sync_resources() module function added in saltutil.py; the existing test enforces a 1:1 correspondence between all sync_* module and state functions - tests/pytests/unit/client/test_netapi.py: update test_run_log to use AsyncMock for process_manager.run(), which our netapi.py change wrapped in asyncio.run() and therefore requires a coroutine, not a plain Mock
1 parent ddd8c4c commit 596a36b

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

salt/states/saltutil.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,20 @@ def sync_tops(name, **kwargs):
323323
return _sync_single(name, "tops", **kwargs)
324324

325325

326+
def sync_resources(name, **kwargs):
327+
"""
328+
Performs the same task as saltutil.sync_resources module
329+
See :mod:`saltutil module for full list of options <salt.modules.saltutil>`
330+
331+
.. code-block:: yaml
332+
333+
sync_everything:
334+
saltutil.sync_resources:
335+
- refresh: True
336+
"""
337+
return _sync_single(name, "resources", **kwargs)
338+
339+
326340
def sync_thorium(name, **kwargs):
327341
"""
328342
Performs the same task as saltutil.sync_thorium module

tests/pytests/unit/client/test_netapi.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import logging
22

33
import salt.client.netapi
4-
from tests.support.mock import Mock, patch
4+
from tests.support.mock import AsyncMock, Mock, patch
55

66

77
def test_run_log(caplog, master_opts):
@@ -11,6 +11,7 @@ def test_run_log(caplog, master_opts):
1111
master_opts["rest_cherrypy"] = {"port": 8000}
1212
mock_process = Mock()
1313
mock_process.add_process.return_value = True
14+
mock_process.return_value.run = AsyncMock()
1415
patch_process = patch.object(salt.utils.process, "ProcessManager", mock_process)
1516
with caplog.at_level(logging.INFO):
1617
with patch_process:

0 commit comments

Comments
 (0)