Spaces:
Running on Zero
Running on Zero
Download tests/test_boot.py from fffiloni/ZONOS3-Mini: direct link, hf CLI and curl.
- Browser
- Download file 1.81 kB
-
https://huggingface.co/spaces/fffiloni/ZONOS3-Mini/resolve/main/tests/test_boot.py
- Command line
-
hf download hf://spaces/fffiloni/ZONOS3-Mini/tests/test_boot.py
-
curl -L -o test_boot.py https://huggingface.co/spaces/fffiloni/ZONOS3-Mini/resolve/main/tests/test_boot.py
1.81 kB
| import asyncio | |
| from boot import EntryShell | |
| from config import ROOT | |
| def test_entry_shell_is_sent_before_javascript_and_is_not_cached(): | |
| async def app(scope, receive, send): | |
| await send({'type':'http.response.start','status':200,'headers':[(b'content-type',b'text/html'),(b'content-length',b'31'),(b'etag',b'old')]}) | |
| await send({'type':'http.response.body','body':b'<html><body\n style="margin:0">','more_body':True}) | |
| await send({'type':'http.response.body','body':b'<gradio-app></gradio-app></body></html>'}) | |
| result=[] | |
| async def send(message):result.append(message) | |
| asyncio.run(EntryShell(app,ROOT/'assets/boot.html')({'type':'http','method':'GET','path':'/'},None,send)) | |
| headers=dict(result[0]['headers']);body=result[1]['body'] | |
| assert headers[b'cache-control']==b'no-store' and b'etag' not in headers | |
| assert int(headers[b'content-length'])==len(body) | |
| assert body.index(b'id="zonos-boot"')<body.index(b'<gradio-app>') | |
| assert b'Loading the interface' in body and b'Open in a new tab' in body | |
| def test_api_and_audio_streams_pass_through_without_buffering(): | |
| for path in ['/gradio_api/queue/data','/gradio_api/file=voice.wav','/assets/script.js','/config']: | |
| sent=[] | |
| async def app(scope,receive,send): | |
| for message in [{'type':'http.response.start','status':200,'headers':[]}, | |
| {'type':'http.response.body','body':b'first','more_body':True}, | |
| {'type':'http.response.body','body':b'last'}]: | |
| await send(message) | |
| assert sent[-1] is message | |
| async def send(message):sent.append(message) | |
| asyncio.run(EntryShell(app,ROOT/'assets/boot.html')({'type':'http','method':'GET','path':path},None,send)) | |
| assert len(sent)==3 | |