Exemple #1
0
def test_properties(mock_interactivesession):
    runner = RemoteRunner()
    runner.set_default_target_property('name', 'value')
    runner.set_target(shelldicts=[{'shellname': 'ExampleShell'}])
    assert runner.get_target_properties('default')['name'] == 'value'
    runner.set_target_property(target_name='default',
                               property_name='name',
                               property_value='newvalue')
    assert runner.get_target_properties('default')['name'] == 'newvalue'
Exemple #2
0
def bash_remoterunner():
    r = RemoteRunner()
    try:
        r.set_target([{'shellname': 'BashShell'}])
        ret = r.execute_command_in_target('echo hello')
        assert not int(ret.status)
        yield r
    finally:
        r.close()
Exemple #3
0
 def fact():
     return initializer(RemoteRunner())
Exemple #4
0
def bash_remoterunner_context(initializer):
    r = RemoteRunner()
    try:
        yield initializer(r)
    finally:
        r.close()
 def fact():
     r = RemoteRunner()
     r.set_target([{'shellname': 'ExampleShell'}])
     return r
Exemple #6
0
def test_set_terminalpools_maxsize(mock_terminalpools, maxsize):
    runner = RemoteRunner()
    runner.set_terminalpools_maxsize(maxsize)
    set_maxsize = mock_terminalpools.return_value.set_maxsize
    set_maxsize.assert_called_once_with(int(maxsize))
Exemple #7
0
def mock_terminalpools():
    with mock.patch('crl.interactivesessions.remoterunner._TerminalPools',
                    spec_set=True) as p:
        yield p


@pytest.mark.parametrize('maxsize', [50, '50'])
def test_set_terminalpools_maxsize(mock_terminalpools, maxsize):
    runner = RemoteRunner()
    runner.set_terminalpools_maxsize(maxsize)
    set_maxsize = mock_terminalpools.return_value.set_maxsize
    set_maxsize.assert_called_once_with(int(maxsize))


@pytest.mark.parametrize('method', [
    lambda: RemoteRunner().get_target_properties(target='na'),
    lambda: RemoteRunner().set_target_property(target_name='na',
                                               property_name='n',
                                               property_value='v'),
    lambda: RemoteRunner().get_target_properties(target='na'),
    lambda: RemoteRunner().execute_command_in_target('cmd', target='na')])
def test_targetisnotset(method):
    with pytest.raises(TargetIsNotSet) as excinfo:
        method()
    assert str(excinfo.value) == 'na'


def test_close(mock_interactivesession,
               remoterunner):
    remoterunner.set_target(shelldicts=[{'shellname': 'ExampleShell'}],
                            name='target')