Пример #1
0
 async def check_connect_session_fails(self, server, origin):
     with pytest.raises(HTTPError):
         subprotocols = ["bokeh", generate_jwt_token("foo")]
         await websocket_open(server.io_loop,
                              ws_url(server),
                              origin=origin,
                              subprotocols=subprotocols)
Пример #2
0
    def test_ping(self, ManagedServerLoop):
        application = Application()
        with ManagedServerLoop(application,
                               keep_alive_milliseconds=0) as server:
            session = ClientSession(session_id='test_ping',
                                    websocket_url=ws_url(server),
                                    io_loop=server.io_loop)
            session.connect()
            assert session.connected
            assert session.document is None

            connection = next(iter(server._tornado._clients))
            expected_pong = connection._ping_count
            server._tornado._keep_alive()  # send ping
            session.force_roundtrip()

            assert expected_pong == connection._socket.latest_pong

            # check that each ping increments by 1
            server._tornado._keep_alive()
            session.force_roundtrip()

            assert (expected_pong + 1) == connection._socket.latest_pong

            session.close()
            session._loop_until_closed()
            assert not session.connected
Пример #3
0
    def test_connect_with_prefix(self, ManagedServerLoop):
        application = Application()
        with ManagedServerLoop(application, prefix="foo") as server:
            # we don't have to start the server because it
            # uses the same main loop as the client, so
            # if we start either one it starts both
            session = ClientSession(io_loop=server.io_loop,
                                    websocket_url=ws_url(server, "/foo"))
            session.connect()
            assert session.connected
            session.close()
            session._loop_until_closed()

            session = ClientSession(io_loop=server.io_loop,
                                    websocket_url=ws_url(server))
            session.connect()
            assert not session.connected
            session.close()
            session._loop_until_closed()
Пример #4
0
 def test_minimal_connect_and_disconnect(self, ManagedServerLoop) -> None:
     application = Application()
     with ManagedServerLoop(application) as server:
         # we don't have to start the server because it
         # uses the same main loop as the client, so
         # if we start either one it starts both
         session = ClientSession(session_id='test_minimal_connect_and_disconnect',
                                 io_loop = server.io_loop,
                                 websocket_url = ws_url(server))
         session.connect()
         assert session.connected
Пример #5
0
 def test_disconnect_on_error(self, ManagedServerLoop) -> None:
     application = Application()
     with ManagedServerLoop(application) as server:
         session = ClientSession(session_id='test_disconnect_on_error',
                                 websocket_url=ws_url(server),
                                 io_loop = server.io_loop)
         session.connect()
         assert session.connected
         # send a bogus message using private fields
         server.io_loop.spawn_callback(session._connection._socket.write_message, b"xx", binary=True)
         # connection should now close on the server side
         # and the client loop should end
         session._loop_until_closed()
         assert not session.connected
         session.close()
         session._loop_until_closed()
         assert not session.connected
Пример #6
0
    def test_request_server_info(self, ManagedServerLoop):
        application = Application()
        with ManagedServerLoop(application) as server:
            session = ClientSession(session_id='test_request_server_info',
                                    websocket_url=ws_url(server),
                                    io_loop=server.io_loop)
            session.connect()
            assert session.connected
            assert session.document is None

            info = session.request_server_info()

            from bokeh import __version__

            assert info['version_info']['bokeh'] == __version__
            assert info['version_info']['server'] == __version__

            session.close()
            session._loop_until_closed()
            assert not session.connected
Пример #7
0
 async def check_connect_session(self, server, origin):
     await websocket_open(server.io_loop,
                          ws_url(server) + "?bokeh-session-id=foo",
                          origin=origin)
Пример #8
0
 async def check_connect_session_fails(self, server, origin):
     with pytest.raises(HTTPError):
         await websocket_open(server.io_loop,
                              ws_url(server) + "?bokeh-session-id=foo",
                              origin=origin)
Пример #9
0
 async def check_connect_session(self, server, origin):
     subprotocols = ["bokeh", generate_jwt_token("foo")]
     await websocket_open(server.io_loop,
                          ws_url(server),
                          origin=origin,
                          subprotocols=subprotocols)