MCPcopy Create free account
hub / github.com/saltstack/salt / test_execute_script

Function test_execute_script

tests/pytests/unit/client/ssh/test_single.py:524–552  ·  view source on GitHub ↗

test Single.execute_script()

(opts, target, tmp_path)

Source from the content-addressed store, hash-verified

522
523
524def test_execute_script(opts, target, tmp_path):
525 """
526 test Single.execute_script()
527 """
528 single = ssh.Single(
529 opts,
530 opts["argv"],
531 "localhost",
532 mods={},
533 fsclient=None,
534 thin=salt.utils.thin.thin_path(opts["cachedir"]),
535 mine=False,
536 winrm=False,
537 **target,
538 )
539
540 exp_ret = ("Success", "", 0)
541 mock_cmd = MagicMock(return_value=exp_ret)
542 patch_cmd = patch("salt.client.ssh.shell.Shell.exec_cmd", mock_cmd)
543 script = str(tmp_path / "script.sh")
544
545 with patch_cmd:
546 ret = single.execute_script(script=script)
547 assert ret == exp_ret
548 assert mock_cmd.call_count == 2
549 assert [
550 call(f"/bin/sh '{script}'"),
551 call(f"rm '{script}'"),
552 ] == mock_cmd.call_args_list
553
554
555def test_shim_cmd(opts, target, tmp_path):

Callers

nothing calls this directly

Calls 3

execute_scriptMethod · 0.95
patchFunction · 0.50
callFunction · 0.50

Tested by

no test coverage detected