Пример #1
0
def test_login_alreadylogged():
    server = Server(host=None)
    setup_server(server)

    conn = Connection('newconn', None)
    server._process_login(conn, server.users[2].username)
    wp = WireProtocol()
    wp.parse_incoming_bytes(conn.send_buffer)
    assert wp.command == CMD.RESPONSE
    assert wp.data_len == len('user is already logged in')
    assert wp.data_buffer == b'user is already logged in'
Пример #2
0
def test_login_noaccount():
    server = Server(host=None)
    setup_server(server)
    server.users[2].logout()

    conn = Connection('newconn', None)
    server._process_login(conn, server.users[2].username + 'asdfasdf')
    wp = WireProtocol()
    wp.parse_incoming_bytes(conn.send_buffer)
    assert wp.command == CMD.RESPONSE
    assert wp.data_len == len('username does not exist')
    assert wp.data_buffer == b'username does not exist'