Testing the flask_sockets application

I am creating an application using the flask_sockets library. How to check it?

Here is a sample code. I want to write unit tests for:

import flask
from flask import Flask
from flask_sockets import Sockets

app = Flask(__name__)
sockets = Sockets(app)

ws_conns = []


@sockets.route('/echo')
def echo_socket(ws):
    #on connect
    ws_conns.append(ws)

    #while connected
    while True:
        # message = ws.receive()
        # if message is None:
        # #socket has closed/errored
        #     break
        for c in ws_conns:
            c.send('hello and goodbye!')

    #disconnected
    ws_conns.remove(ws)
    ws.close()

I am using this code from this git repo .

+4
source share

All Articles