File: openssh_tests.py

package info (click to toggle)
proxmoxer 1.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 188 kB
  • sloc: python: 761; makefile: 4
file content (29 lines) | stat: -rw-r--r-- 859 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
__author__ = 'Oleg Butovich'
__copyright__ = '(c) Oleg Butovich 2013-2017'
__licence__ = 'MIT'

from mock import patch
from proxmoxer import ProxmoxAPI
from tests.base.base_ssh_suite import BaseSSHSuite


class TestOpenSSHSuite(BaseSSHSuite):
    proxmox = None
    client = None

    # noinspection PyMethodOverriding
    @patch('openssh_wrapper.SSHConnection')
    def setUp(self, _):
        self.proxmox = ProxmoxAPI('proxmox', user='root', backend='openssh', port=123)
        self.client = self.proxmox._store['session'].ssh_client
        self._set_stderr('200 OK')
        self._set_stdout('')

    def _get_called_cmd(self):
        return self.client.run.call_args[0][0]

    def _set_stdout(self, stdout):
        self.client.run.return_value.stdout = stdout

    def _set_stderr(self, stderr):
        self.client.run.return_value.stderr = stderr