"""Three real game clients; no GPIO, no live deployment database.""" import json import os from pathlib import Path import subprocess import sys import tempfile import threading import time import urllib.request from http.server import HTTPServer from test_room import ROOT, server with tempfile.TemporaryDirectory() as temp: fleet=server.Fleet(Path(temp)/'chain.db',json.loads((ROOT/'tools/room_controller/catalog.json').read_text())) service=HTTPServer(('127.0.0.1',0),server.handler_for(fleet,'test-operator-token',{'cabinet_01':'test-token-one-123','cabinet_02':'test-token-two-123','cabinet_03':'test-token-three-123'})) thread=threading.Thread(target=service.serve_forever,daemon=True) thread.start() url='http://127.0.0.1:'+str(service.server_port) processes=[] def post(path,data={}): request=urllib.request.Request(url+path,data=json.dumps(data).encode(),headers={'Authorization':'Bearer test-operator-token'}) with urllib.request.urlopen(request,timeout=3) as response: return json.load(response) def wait(predicate): deadline=time.monotonic()+30 while time.monotonic() 499/500 score boundary -> one Frogger home -> all three wins') finally: for process in processes: if process.poll() is None: process.terminate(); process.wait(timeout=5) service.shutdown(); service.server_close(); thread.join() for room in fleet.rooms.values(): room.db.close()