Files
CoCoCapitalQuiz/tests/playtest_support.py
T

19 lines
901 B
Python

import sys,json,base64,uuid,os
from pathlib import Path
sys.path.insert(0,str(Path(__file__).resolve().parents[1]/'tools'))
from vcc_mcp import VCC
v=VCC(os.environ['VCC_GRANT'])
def call(n,a={}):
r=v.call(n,a)
if r.get('isError'):raise RuntimeError(r)
return r
def capture(run,name):
r=v.request('tools/call',{'name':'capture_playtest','arguments':{'run_id':run}})
meta={}
for c in r['content']:
if c['type']=='image':(Path(os.environ['CAPITAL_TEST_EVIDENCE'])/(name+'.png')).write_bytes(base64.b64decode(c['data']))
if c['type']=='text':meta=json.loads(c['text'])
(Path(os.environ['CAPITAL_TEST_EVIDENCE'])/(name+'.json')).write_text(json.dumps(meta,indent=2));return meta
def inp(run,steps):return call('playtest_input',{'run_id':run,'request_id':str(uuid.uuid4()),'steps':steps})
def key(run,k,hold=8,settle=250):return inp(run,[{'keys':[k],'fields':hold},{'keys':[],'fields':settle}])