Exemple #1
0
def test_ProxyFromVim_closeSocket_inactive():
    from vimpdb.proxy import ProxyFromVim
    from_vim = ProxyFromVim(6666)

    from_vim.socket = Mock()

    from_vim.closeSocket()

    assert from_vim.socket_inactive
    assert not from_vim.socket.called
Exemple #2
0
def test_ProxyFromVim_bindSocket_active():
    from vimpdb.proxy import ProxyFromVim
    from_vim = ProxyFromVim(6666)

    from_vim.socket_factory = Mock()
    from_vim.socket_inactive = False

    from_vim.bindSocket()

    assert not from_vim.socket_factory.called
Exemple #3
0
def test_ProxyFromVim_bindSocket():
    from vimpdb.proxy import ProxyFromVim
    from_vim = ProxyFromVim(6666)

    from_vim.socket_factory = Mock()

    from_vim.bindSocket()

    assert not from_vim.socket_inactive
    assert from_vim.socket.bind.call_count == 1
    from_vim.socket.bind.assert_called_with(('', 6666))
Exemple #4
0
def test_ProxyFromVim_closeSocket():
    from vimpdb.proxy import ProxyFromVim
    from_vim = ProxyFromVim(6666)

    from_vim.socket = Mock()
    from_vim.socket_inactive = False

    from_vim.closeSocket()

    assert from_vim.socket_inactive
    assert from_vim.socket.close.call_count == 1
    from_vim.socket.close.assert_called_with()
Exemple #5
0
def test_ProxyFromVim_waitFor():
    from vimpdb.proxy import ProxyFromVim
    from socket import socket

    from_vim = ProxyFromVim(6666)

    mocked_socket = Mock(socket)
    mocked_socket.recvfrom.return_value = ('message', None)
    mocked_factory = Mock(return_value=mocked_socket)
    from_vim.socket_factory = mocked_factory

    message = from_vim.waitFor(None)

    assert message == 'message'
    assert from_vim.socket.recvfrom.called
Exemple #6
0
def test_ProxyFromVim_instantiation():
    from vimpdb.proxy import ProxyFromVim
    from_vim = ProxyFromVim(6666)
    assert isinstance(from_vim, ProxyFromVim)
    assert from_vim.port == 6666
    assert from_vim.socket_inactive