test Single.execute_script()
(opts, target, tmp_path)
| 522 | |
| 523 | |
| 524 | def 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 | |
| 555 | def test_shim_cmd(opts, target, tmp_path): |
nothing calls this directly
no test coverage detected