mirror of
https://github.com/openwrt/packages.git
synced 2026-04-15 19:02:09 +00:00
Requires python-socketio >= 5.12.0 and python-engineio >= 4.11.0, both bumped in preceding commits. Also fix test.sh to use importlib.metadata for version check since flask_socketio no longer exposes __version__ directly. Link: https://github.com/miguelgrinberg/Flask-SocketIO/blob/main/CHANGES.md Signed-off-by: Alexandru Ardelean <alex@shruggie.ro>
38 lines
826 B
Bash
38 lines
826 B
Bash
#!/bin/sh
|
|
|
|
[ "$1" = python3-flask-socketio ] || exit 0
|
|
|
|
python3 - <<EOF
|
|
import sys
|
|
from flask import Flask
|
|
from flask_socketio import SocketIO, emit
|
|
|
|
from importlib.metadata import version
|
|
pkg_version = version("flask-socketio")
|
|
if pkg_version != "$2":
|
|
print("Wrong version: " + pkg_version)
|
|
sys.exit(1)
|
|
|
|
app = Flask(__name__)
|
|
app.config["SECRET_KEY"] = "test-secret"
|
|
socketio = SocketIO(app)
|
|
|
|
@socketio.on("ping")
|
|
def handle_ping(data):
|
|
emit("pong", {"msg": data["msg"]})
|
|
|
|
client = socketio.test_client(app)
|
|
assert client.is_connected()
|
|
|
|
client.emit("ping", {"msg": "hello"})
|
|
received = client.get_received()
|
|
assert len(received) == 1
|
|
assert received[0]["name"] == "pong"
|
|
assert received[0]["args"][0]["msg"] == "hello"
|
|
|
|
client.disconnect()
|
|
assert not client.is_connected()
|
|
|
|
print("python-flask-socketio OK")
|
|
EOF
|