import json,urllib.request,urllib.error,time,sys from pathlib import Path root=Path(__file__).resolve().parent/'hd-test' fixture=json.loads((root/'fixture.json').read_text()) base='http://127.0.0.1:18879/api/v1' def request(path,body=None): req=urllib.request.Request(base+path,data=json.dumps(body).encode() if body else None,headers={'Content-Type':'application/json'}) try: with urllib.request.urlopen(req,timeout=30) as r: return json.load(r) except urllib.error.HTTPError as e: raise RuntimeError(e.read().decode()) print(request('/health')) data=request('/hd/episodes/'+str(fixture['episode']))['data'] assert data['configured'] row=next(i for i in data['items'] if i['id']==fixture['storyboard']) assert row['original']==fixture['original'] and not row['busy'] resolution=sys.argv[1] if len(sys.argv)>1 else '2K' assert resolution in ('2K','4K') result=request('/hd/storyboards/'+str(fixture['storyboard']),{'resolution':resolution}) fixture['task']=result['data']['id'] fixture.setdefault('real_tasks',{})[resolution]=fixture['task'] (root/'fixture.json').write_text(json.dumps(fixture)) print('Submitted isolated',resolution,'test task:',fixture['task'])