def _test_ssh_path_windows(self, arch, expected_sys_path, mock_isfile, mock_environ, mock_join, mock_arch, mock_system):
        mock_system.return_value = "Windows"
        mock_arch.return_value = (arch, "foo", "bar")
        mock_environ.__getitem__.return_value = "rootpath"
        mock_join.side_effect = ["system32path", "sshfilepath"]
        mock_isfile.return_value = True
        expected_join_calls = [
            mock.call("rootpath", expected_sys_path),
            mock.call("system32path", "openSSH", "ssh.exe")
        ]

        actual_path = ssh_utils._get_ssh_path()

        self.assertEqual("sshfilepath", actual_path)
        mock_system.assert_called_once_with()
        mock_arch.assert_called_once_with()
        mock_environ.__getitem__.assert_called_once_with("SystemRoot")
        mock_join.assert_has_calls(expected_join_calls)
        mock_isfile.assert_called_once_with("sshfilepath")
示例#2
0
    def test_get_ssh_path_non_windows(self, mock_system):
        mock_system.return_value = "Mac"

        actual_path = ssh_utils._get_ssh_path()
        self.assertEqual('ssh', actual_path)
        mock_system.assert_called_once_with()