gui/backend/tests/conftest.py
def create_socket_connection(cookie=None, token=None):
    ''' Create a socket to the backend. It first attempts to
    create a secure socket and on failure, attempts an
    insecure socket'''
    secure = is_secure_server(token)

    if secure is None:
        return None

    try:
        if is_secure_server():
            # Attempt to connect to a secure socket
            # cspell:ignore reqs
            url = f"wss://localhost:{port}/ws1.ws?token={token}" if token else f"wss://localhost:{port}/ws1.ws"
            return websocket.create_connection(url, cookie=cookie,
                                               sslopt={"cert_reqs": ssl.CERT_NONE})

        # Attempt to connect to an insecure socket
        url = f"ws://localhost:{port}/ws1.ws?token={token}" if token else f"ws://localhost:{port}/ws1.ws"
        return websocket.create_connection(url, cookie=cookie)
    except ConnectionRefusedError as e:
        if e.errno != 111:
            logger.exception(e,
                f"\n=========[EXCEPTION]=========\n{debug_info()}\n{str(e)}\n-----------------------------")
            raise

    except Exception as e:
        logger.exception(e,
            f"\n=========[EXCEPTION]=========\n{debug_info()}\n{str(e)}\n-----------------------------")
        raise

    return None
 Create a socket to the backend. It first attempts to
    create a secure socket and on failure, attempts an
    insecure socket
Create a socket to the backend. It first attempts to
create a secure socket and on failure, attempts an
insecure socket
Create a socket to the backend . It first attempts to create a secure socket and on failure attempts an insecure socket
def create_socket_connection(cookie=None, token=None):
    secure = is_secure_server(token)
    if secure is None:
        return None
    try:
        if is_secure_server():
            url = f"wss://localhost:{port}/ws1.ws?token={token}" if token else f"wss://localhost:{port}/ws1.ws"
            return websocket.create_connection(url, cookie=cookie,
                                               sslopt={"cert_reqs": ssl.CERT_NONE})
        url = f"ws://localhost:{port}/ws1.ws?token={token}" if token else f"ws://localhost:{port}/ws1.ws"
        return websocket.create_connection(url, cookie=cookie)
    except ConnectionRefusedError as e:
        if e.errno != 111:
            logger.exception(e,
                f"\n=========[EXCEPTION]=========\n{debug_info()}\n{str(e)}\n-----------------------------")
            raise
    except Exception as e:
        logger.exception(e,
            f"\n=========[EXCEPTION]=========\n{debug_info()}\n{str(e)}\n-----------------------------")
        raise
    return None
def create_socket_connection ( cookie = None , token = None ) : secure = is_secure_server ( token ) if secure is None : return None try : if is_secure_server ( ) : url = f"wss://localhost:{port}/ws1.ws?token={token}" if token else f"wss://localhost:{port}/ws1.ws" return websocket . create_connection ( url , cookie = cookie , sslopt = { "cert_reqs" : ssl . CERT_NONE } ) url = f"ws://localhost:{port}/ws1.ws?token={token}" if token else f"ws://localhost:{port}/ws1.ws" return websocket . create_connection ( url , cookie = cookie ) except ConnectionRefusedError as e : if e . errno != 111 : logger . exception ( e , f"\n=========[EXCEPTION]=========\n{debug_info()}\n{str(e)}\n-----------------------------" ) raise except Exception as e : logger . exception ( e , f"\n=========[EXCEPTION]=========\n{debug_info()}\n{str(e)}\n-----------------------------" ) raise return None
Create a socket to the backend.
Create a socket to the backend .
''' Create a socket to the backend. It first attempts to
    create a secure socket and on failure, attempts an
    insecure socket''' # Attempt to connect to a secure socket # cspell:ignore reqs # Attempt to connect to an insecure socket
cookie
token