Ejemplo n.º 1
0
def test_context_manager(monkeypatch):
    """Asserts context manager properly opens/closes"""
    channel_ssh_auth_called = False

    def _channel_ssh_auth(cls, auth_password, auth_private_key_passphrase):
        nonlocal channel_ssh_auth_called
        channel_ssh_auth_called = True

    monkeypatch.setattr(
        "scrapli.transport.plugins.system.transport.SystemTransport.open", lambda x: None
    )
    monkeypatch.setattr(
        "scrapli.channel.sync_channel.Channel.channel_authenticate_ssh", _channel_ssh_auth
    )

    with Driver(host="localhost") as conn:
        pass

    assert channel_ssh_auth_called is True
Ejemplo n.º 2
0
def test_async_transport_exception():
    """Assert we raise ScrapliValueError if an async transport is provided to the sync driver"""
    with pytest.raises(ScrapliValueError):
        Driver(host="localhost", transport="asynctelnet")
Ejemplo n.º 3
0
def sync_driver_telnet():
    """Fixture to provide sync driver instance"""
    sync_driver_telnet = Driver(host="localhost",
                                auth_username="******",
                                transport="telnet")
    return sync_driver_telnet
Ejemplo n.º 4
0
def sync_driver():
    """Fixture to provide sync driver instance"""
    sync_driver = Driver(host="localhost", auth_username="******")
    return sync_driver