hexland-server/test/test.py
2022-10-04 09:46:17 -05:00

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")