def test_websocket_url(self): self.assertEqual("ws://example.com:4000/ws", websocket_url_for_server_url("http://example.com:4000")) # with trailing / on original url self.assertEqual("ws://example.com:4000/ws", websocket_url_for_server_url("http://example.com:4000/")) # with https self.assertEqual("wss://example.com:4000/ws", websocket_url_for_server_url("https://example.com:4000")) # with a path self.assertEqual("wss://example.com:4000/bar/ws", websocket_url_for_server_url("https://example.com:4000/bar")) # with path with trailing slash self.assertEqual("wss://example.com:4000/bar/ws", websocket_url_for_server_url("https://example.com:4000/bar/"))
def push(session_id=None, url=None, document=None, state=None, io_loop=None, validate=True): ''' Update the server with the data for the current document. Will fall back to the default output state (or an explicitly provided :class:`State` object) for ``session_id``, ``url``, or ``document`` if they are not provided. Args: session_id (str, optional) : a Bokeh server session ID to push objects to url (str, optional) : a Bokeh server URL to push objects to document (Document, optional) : A :class:`bokeh.document.Document` to use state (State, optional) : A state to use for any output_server() configuration of session or url io_loop (tornado.ioloop.IOLoop, optional) : Tornado IOLoop to use for connecting to server validate (bool, optional) : True to check integrity of the document we are pushing Returns: None ''' if state is None: state = _state if not session_id: session_id = state.session_id if not session_id: session_id = DEFAULT_SESSION_ID if not url: url = state.server_url if not url: url = DEFAULT_SERVER_HTTP_URL if not document: document = state.document if not document: warnings.warn("No document to push") if validate: document.validate() _push_to_server(websocket_url=websocket_url_for_server_url(url), document=document, session_id=session_id, io_loop=io_loop)
def test_websocket_url(self): self.assertEqual( "ws://example.com:4000/ws", websocket_url_for_server_url("http://example.com:4000")) # with trailing / on original url self.assertEqual( "ws://example.com:4000/ws", websocket_url_for_server_url("http://example.com:4000/")) # with https self.assertEqual( "wss://example.com:4000/ws", websocket_url_for_server_url("https://example.com:4000")) # with a path self.assertEqual( "wss://example.com:4000/bar/ws", websocket_url_for_server_url("https://example.com:4000/bar")) # with path with trailing slash self.assertEqual( "wss://example.com:4000/bar/ws", websocket_url_for_server_url("https://example.com:4000/bar/"))