Skip to content

Commit 535c728

Browse files
committed
Cleanup SSH connector tests.
1 parent cf9dcbe commit 535c728

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

tests/test_connectors/test_ssh.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -433,9 +433,8 @@ def test_run_shell_command_masked(self, fake_ssh_client, fake_click):
433433
@patch('pyinfra.api.connectors.ssh.SSHClient')
434434
def test_run_shell_command_success_exit_code(self, fake_ssh_client):
435435
fake_ssh = MagicMock()
436-
fake_stdin = MagicMock()
437436
fake_stdout = MagicMock()
438-
fake_ssh.exec_command.return_value = fake_stdin, fake_stdout, MagicMock()
437+
fake_ssh.exec_command.return_value = MagicMock(), fake_stdout, MagicMock()
439438

440439
fake_ssh_client.return_value = fake_ssh
441440

@@ -454,9 +453,8 @@ def test_run_shell_command_success_exit_code(self, fake_ssh_client):
454453
@patch('pyinfra.api.connectors.ssh.SSHClient')
455454
def test_run_shell_command_error(self, fake_ssh_client):
456455
fake_ssh = MagicMock()
457-
fake_stdin = MagicMock()
458456
fake_stdout = MagicMock()
459-
fake_ssh.exec_command.return_value = fake_stdin, fake_stdout, MagicMock()
457+
fake_ssh.exec_command.return_value = MagicMock(), fake_stdout, MagicMock()
460458

461459
fake_ssh_client.return_value = fake_ssh
462460

@@ -484,9 +482,8 @@ def test_run_shell_command_sudo_password_prompt(
484482
fake_getpass,
485483
):
486484
fake_ssh = MagicMock()
487-
fake_stdin = MagicMock()
488485
fake_stdout = MagicMock()
489-
fake_ssh.exec_command.return_value = fake_stdin, fake_stdout, MagicMock()
486+
fake_ssh.exec_command.return_value = MagicMock(), fake_stdout, MagicMock()
490487

491488
fake_ssh_client.return_value = fake_ssh
492489
fake_getpass.return_value = 'password'
@@ -499,7 +496,7 @@ def test_run_shell_command_sudo_password_prompt(
499496
command = 'echo Šablony'
500497
fake_stdout.channel.recv_exit_status.return_value = 0
501498

502-
out = host.run_shell_command(command, use_sudo_password=True, print_output=True)
499+
out = host.run_shell_command(command, sudo=True, use_sudo_password=True, print_output=True)
503500
assert len(out) == 3
504501

505502
status, stdout, stderr = out
@@ -511,7 +508,7 @@ def test_run_shell_command_sudo_password_prompt(
511508

512509
fake_ssh.exec_command.assert_called_with((
513510
'env SUDO_ASKPASS=pyinfra-sudo-askpass PYINFRA_SUDO_PASSWORD=password '
514-
"sh -c 'echo Šablony'"
511+
"sudo -H -A -k sh -c 'echo Šablony'"
515512
), get_pty=False)
516513

517514
# SSH file put/get tests

0 commit comments

Comments
 (0)