summaryrefslogtreecommitdiffstats
path: root/lang/python/python-socketio/test.sh
blob: 1b7c723bbe8521efe6f636cf9c0b80059c2eca83 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/sh

[ "$1" = python3-socketio ] || exit 0

python3 - <<'EOF'
import socketio

# Test server creation and event registration
sio = socketio.Server()

received = []

@sio.event
def connect(sid, environ):
    received.append(('connect', sid))

@sio.event
def message(sid, data):
    received.append(('message', data))

@sio.event
def disconnect(sid):
    received.append(('disconnect', sid))

# Verify the handlers are registered
assert 'connect' in sio.handlers['/']
assert 'message' in sio.handlers['/']
assert 'disconnect' in sio.handlers['/']

# Test namespace creation
ns = socketio.Namespace('/test')
sio.register_namespace(ns)
assert '/test' in sio.namespace_handlers

# Test AsyncServer exists
asio = socketio.AsyncServer()
assert asio is not None
EOF