@@ -0,0 +1,35 @@
|
||||
#!/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()<deadline:
|
||||
status=client.get(base+'/status',headers=headers).json()
|
||||
if status['status'] in ('completed','failed'): break
|
||||
time.sleep(.5)
|
||||
assert status['status']=='completed',status
|
||||
data=client.get(base+'/data',headers=headers)
|
||||
assert data.status_code==200 and data.json()['metadata']['format']=='ole'
|
||||
svg=client.get(base+'/svg',headers=headers)
|
||||
assert svg.status_code==200 and '<svg' in svg.text
|
||||
assert client.get('/view/'+id).status_code==200
|
||||
assert client.get('/docs').status_code==200
|
||||
print(json.dumps({'id':id,'status':status['status'],'compatibility':status['compatibility'],
|
||||
'records':status['record_count'],'primitives':status['primitive_count'],
|
||||
'private_access_enforced':True,'svg_bytes':len(svg.content)},indent=2))
|
||||
مرجع در شماره جدید
مسدود کردن کاربر