def test_channel_can_have_sockets_added_to_it():
    mk(('echo.sock', 'channel.send(channel.recv())'))
    socket = make_socket()
    channel = Channel('foo', ThreadedBuffer)
    channel.add(socket)

    expected = [socket]
    actual = list(channel)
    assert actual == expected, actual
def test_channel_can_have_sockets_added_to_it(mk):
    mk(('echo.sock.spt', 'channel.send(channel.recv())'))
    socket = make_socket()
    channel = Channel('foo', ThreadedBuffer)
    channel.add(socket)

    expected = [socket]
    actual = list(channel)
    assert actual == expected
def test_channel_can_have_sockets_added_to_it(harness):
    harness.fs.www.mk(('echo.sock.spt', 'channel.send(channel.recv())'))
    socket = harness.make_socket()
    channel = Channel('foo', ThreadedBuffer)
    channel.add(socket)

    expected = [socket]
    actual = list(channel)
    assert actual == expected
def test_channel_passes_send_on_to_one_socket():
    mk(('echo.sock', ''))
    socket = make_socket()
    channel = Channel('foo', ThreadedBuffer)
    channel.add(socket)
    channel.send('foo')

    expected = deque([Message.from_bytes('3::/echo.sock:foo')])
    actual = socket.outgoing.queue
    assert actual == expected, actual
def test_channel_passes_send_on_to_one_socket(mk):
    mk(('echo.sock.spt', ''))
    socket = make_socket()
    channel = Channel('foo', ThreadedBuffer)
    channel.add(socket)
    channel.send('foo')

    expected = deque([Message.from_bytes('3::/echo.sock:foo')])
    actual = socket.outgoing.queue
    assert actual == expected
def test_channel_raises_AssertionError_on_double_add():
    mk(('echo.sock', ''))
    socket = make_socket()
    channel = Channel('foo', ThreadedBuffer)
    channel.add(socket)
    assert_raises(AssertionError, channel.add, socket)
def test_channel_raises_AssertionError_on_double_add(mk):
    mk(('echo.sock.spt', ''))
    socket = make_socket()
    channel = Channel('foo', ThreadedBuffer)
    channel.add(socket)
    raises(AssertionError, channel.add, socket)
def test_channel_raises_AssertionError_on_double_add(harness):
    harness.fs.www.mk(('echo.sock.spt', ''))
    socket = harness.make_socket()
    channel = Channel('foo', ThreadedBuffer)
    channel.add(socket)
    raises(AssertionError, channel.add, socket)