def test_two_sockets_are_instantiable(mk):
    mk(('echo.sock.spt', ''))

    socket1 = make_socket()
    socket2 = make_socket()

    expected = (Socket, Socket)
    actual = (socket1.__class__, socket2.__class__)
    assert actual == expected
def test_two_sockets_are_instantiable():
    mk(('echo.sock', ''))

    socket1 = make_socket()
    socket2 = make_socket()

    expected = (Socket, Socket)
    actual = (socket1.__class__, socket2.__class__)
    assert actual == expected, actual
def test_socket_can_shake_hands(mk):
    mk(('echo.sock.spt', ''))
    socket = make_socket()
    response = socket.shake_hands()
    expected = '15:10:xhr-polling'
    actual = response.body.split(':', 1)[1]
    assert actual == expected
def test_socket_can_shake_hands():
    mk(('echo.sock', ''))
    socket = make_socket()
    response = socket.shake_hands()
    expected = '15:10:xhr-polling'
    actual = response.body.split(':', 1)[1]
    assert actual == expected, actual
Exemple #5
0
def test_can_put_onto_buffer(mk):
    mk(('echo.sock.spt', 'socket.send(socket.recv())'))
    buffer = Buffer(make_socket(), 'foo')
    expected = [FFFD + '4' + FFFD + '1:::']
    buffer.put(Message.from_bytes('1:::'))
    actual = list(buffer.flush())
    assert actual == expected
def test_can_put_onto_buffer():
    mk(('echo.sock.spt', 'socket.send(socket.recv())'))
    buffer = Buffer(make_socket(), 'foo')
    expected = [FFFD+'4'+FFFD+'1:::']
    buffer.put(Message.from_bytes('1:::'))
    actual = list(buffer.flush())
    assert actual == expected, actual
def test_can_put_onto_buffer():
    mk(("echo.sock", "socket.send(socket.recv())"))
    buffer = Buffer(make_socket(), "foo")
    expected = [FFFD + "4" + FFFD + "1:::"]
    buffer.put(Message.from_bytes("1:::"))
    actual = list(buffer.flush())
    assert actual == expected, actual
def make_transport(content='', state=0):
    mk(('echo.sock', content))
    socket = make_socket()
    transport = XHRPollingTransport(socket)
    transport.timeout = 0.05 # for testing, could screw up the test
    if state == 1:
        transport.respond(Request(uri='/echo.sock'))
    return transport
 def make_transport(content='', state=0):
     mk(('echo.sock.spt', content))
     socket = make_socket()
     transport = XHRPollingTransport(socket)
     transport.timeout = 0.05  # for testing, could screw up the test
     if state == 1:
         transport.respond(Request(uri='/echo.sock'))
     return transport
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
Exemple #11
0
def test_socket_can_barely_function():
    mk(('echo.sock', 'socket.send("Greetings, program!")'))

    socket = make_socket()
    socket.tick()

    expected = FFFD+'33'+FFFD+'3::/echo.sock:Greetings, program!'
    actual = socket._recv().next()
    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_passes_send_on_to_four_sockets():
    mk(('echo.sock', 'channel.send(channel.recv())'))
    channel = Channel('foo', ThreadedBuffer)
    sockets = [make_socket(channel=channel) for i in range(4)]
    channel.send('foo')

    for socket in sockets:
        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(('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_four_sockets(mk):
    mk(('echo.sock.spt', 'channel.send(channel.recv())'))
    channel = Channel('foo', ThreadedBuffer)
    sockets = [make_socket(channel=channel) for i in range(4)]
    channel.send('foo')

    for socket in sockets:
        expected = deque([Message.from_bytes('3::/echo.sock:foo')])
        actual = socket.outgoing.queue
        assert actual == expected
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_socket_can_barely_function(mk):
    mk(('echo.sock.spt', 'socket.send("Greetings, program!")'))

    socket = make_socket()
    socket.tick()

    expected = FFFD+b'33'+FFFD+b'3::/echo.sock:Greetings, program!'
    actual = socket._recv()
    if actual is not None:
        actual = actual.next()
    assert actual == expected
def test_socket_can_barely_function(mk):
    mk(('echo.sock.spt', 'socket.send("Greetings, program!")'))

    socket = make_socket()
    socket.tick()

    expected = FFFD + b'33' + FFFD + b'3::/echo.sock:Greetings, program!'
    actual = socket._recv()
    if actual is not None:
        actual = actual.next()
    assert actual == expected
def test_buffer_is_instantiable():
    mk(('echo.sock.spt', 'socket.send(socket.recv())'))
    expected = Buffer
    actual = Buffer(make_socket(), 'foo').__class__
    assert actual is expected, actual
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_socket_is_instantiable(mk):
    mk(('echo.sock.spt', ''))

    expected = Socket
    actual = make_socket().__class__
    assert actual is expected
Exemple #22
0
def test_buffer_is_instantiable():
    mk(("echo.sock", "socket.send(socket.recv())"))
    expected = Buffer
    actual = Buffer(make_socket(), "foo").__class__
    assert actual is expected, actual
def test_socket_is_instantiable():
    mk(('echo.sock', ''))

    expected = Socket
    actual = make_socket().__class__
    assert actual is expected, actual
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)
Exemple #25
0
def test_buffer_is_instantiable(mk):
    mk(('echo.sock.spt', 'socket.send(socket.recv())'))
    expected = Buffer
    actual = Buffer(make_socket(), 'foo').__class__
    assert actual is expected