15 lines
424 B
Python
15 lines
424 B
Python
import asyncio
|
|
import websockets
|
|
import re
|
|
|
|
async def test():
|
|
async with websockets.connect("ws://localhost:8080") as ws:
|
|
response = await ws.recv()
|
|
assert(response == "HOSTJOIN:")
|
|
await ws.send("HOST:")
|
|
response = await ws.recv()
|
|
assert(re.match(r"CODE: [a-f\d]{6}", response))
|
|
|
|
asyncio.get_event_loop().run_until_complete(test())
|
|
print("All tests passed")
|