Ejemplo n.º 1
0
 def test_make_auth_token(self):
     tokens = {"access_token": "token_test"}
     raw.set_tokens(tokens)
     self.assertEqual(
         raw.make_auth_header(),
         {
             "Authorization": "Bearer token_test",
             "User-Agent": "CGWire Gazu %s" % __version__,
         },
     )
Ejemplo n.º 2
0
def init(client=default_client, ssl_verify=False):
    """
    Init configuration for SocketIO client.

    Returns:
        Event client that will be able to set listeners.
    """

    event_client = socketio.Client(reconnection=False, ssl_verify=ssl_verify)
    event_client.on("connect_error", connect_error)
    event_client.register_namespace(EventsNamespace("/events"))
    event_client.connect(get_event_host(client), make_auth_header())
    return event_client
Ejemplo n.º 3
0
def init(client=default_client):
    """
    Init configuration for SocketIO client.

    Returns:
        Event client that will be able to set listeners.
    """
    from socketIO_client import SocketIO, BaseNamespace
    from . import get_event_host
    from gazu.client import make_auth_header

    path = get_event_host(client)
    event_client = SocketIO(path, None, headers=make_auth_header())
    main_namespace = event_client.define(BaseNamespace, "/events")
    event_client.main_namespace = main_namespace
    event_client.on('error', connect_error)
    return event_client
Ejemplo n.º 4
0
def init(client=default_client,
         ssl_verify=False,
         reconnection=True,
         logger=False,
         **kwargs):
    """
    Init configuration for SocketIO client.

    Returns:
        Event client that will be able to set listeners.
    """
    params = {"ssl_verify": ssl_verify} if sys.version_info[0] > 3 else {}
    params.update(kwargs)
    event_client = socketio.Client(logger=logger,
                                   reconnection=reconnection,
                                   **params)
    event_client.on("connect_error", connect_error)
    event_client.register_namespace(EventsNamespace("/events"))
    event_client.connect(get_event_host(client), make_auth_header())
    return event_client
Ejemplo n.º 5
0
 def test_make_auth_token(self):
     tokens = {"access_token": "token_test"}
     client.set_tokens(tokens)
     self.assertEqual(client.make_auth_header(),
                      {"Authorization": "Bearer token_test"})