コード例 #1
0
ファイル: test_sshdriver.py プロジェクト: strumtrar/labgrid
 def test_create(self, target, mocker):
     NetworkService(target, "service", "1.2.3.4", "root")
     call = mocker.patch('subprocess.call')
     call.return_value = 0
     popen = mocker.patch('subprocess.Popen', autospec=True)
     path = mocker.patch('os.path.exists')
     path.return_value = True
     instance_mock = mocker.MagicMock()
     popen.return_value = instance_mock
     instance_mock.wait = mocker.MagicMock(return_value=0)
     s = SSHDriver(target, "ssh")
     assert (isinstance(s, SSHDriver))
コード例 #2
0
ファイル: test_sshdriver.py プロジェクト: strumtrar/labgrid
def ssh_driver_mocked_and_activated(target, mocker):
    NetworkService(target, "service", "1.2.3.4", "root")
    call = mocker.patch('subprocess.call')
    call.return_value = 0
    popen = mocker.patch('subprocess.Popen', autospec=True)
    path = mocker.patch('os.path.exists')
    path.return_value = True
    instance_mock = mocker.MagicMock()
    popen.return_value = instance_mock
    instance_mock.wait = mocker.MagicMock(return_value=0)
    SSHDriver(target, "ssh")
    s = target.get_driver("SSHDriver")
    return s
コード例 #3
0
def ssh_driver_mocked_and_activated(target, mocker):
    def dummy():
        def Popen(cmd, stdout=None, stderr=None):
            class xx:
                returncode = 0
                def communicate(*x):
                    if "mktemp" in cmd:
                        return b'/tmp/tmp.aaaa\n', b''
                    else:
                        return b'', b''
            return xx
        return Popen
    NetworkService(target, "service", "1.2.3.4", "root")
    call = mocker.patch('subprocess.call')
    call.return_value = 0
    popen = mocker.patch('subprocess.Popen', new_callable=dummy)
    path = mocker.patch('os.path.exists')
    path.return_value = True
    instance_mock = mocker.MagicMock()
    popen.return_value = instance_mock
    instance_mock.wait = mocker.MagicMock(return_value=0)
    SSHDriver(target, "ssh")
    s = target.get_driver("SSHDriver")
    return s
コード例 #4
0
def ssh_localhost(target, pytestconfig):
    name = pytestconfig.getoption("--ssh-username")
    NetworkService(target, "service", "localhost", name)
    SSHDriver(target, "ssh")
    s = target.get_driver("SSHDriver")
    return s