#!/usr/bin/env python3 """Exercise the actual HTTP API and worker using an actual native file.""" import argparse import json import os from pathlib import Path import time import httpx p=argparse.ArgumentParser() p.add_argument('file',type=Path) p.add_argument('--url',default='http://127.0.0.1:8000') a=p.parse_args() key=os.getenv('API_KEY','') with httpx.Client(base_url=a.url,timeout=30) as client: response=client.post('/api/v1/schematics/render',files={'file':(a.file.name,a.file.read_bytes())},headers={'X-API-Key':key}) assert response.status_code==202,response.text body=response.json(); id=body['id']; headers={'X-Viewer-Token':body['viewer_token']} base=f'/api/v1/schematics/{id}' assert client.get(base+'/data').status_code==404 deadline=time.monotonic()+90 while time.monotonic()