Download bot/tests/test_event_client.py from afluakd9/Video-downloader-CPU-basic: direct link, hf CLI and curl.
- Browser
- Download file 1.21 kB
-
https://huggingface.co/spaces/afluakd9/Video-downloader-CPU-basic/resolve/main/bot/tests/test_event_client.py
- Command line
-
hf download hf://spaces/afluakd9/Video-downloader-CPU-basic/bot/tests/test_event_client.py
-
curl -L -o test_event_client.py https://huggingface.co/spaces/afluakd9/Video-downloader-CPU-basic/resolve/main/bot/tests/test_event_client.py
1.21 kB
| """Tests that event_client functions are fire-and-forget (never raise).""" | |
| import asyncio | |
| import os | |
| # Point at an unreachable URL before importing event_client | |
| os.environ["DASHBOARD_URL"] = "http://localhost:99999" | |
| import event_client | |
| def test_send_download_start_no_raise(): | |
| asyncio.run(event_client.send_download_start( | |
| job_id="job-1", | |
| user_id=12345, | |
| username="testuser", | |
| chat_id=67890, | |
| url="https://example.com/video", | |
| platform="youtube", | |
| format="video", | |
| quality="best", | |
| title="Test Video", | |
| )) | |
| def test_send_progress_no_raise(): | |
| asyncio.run(event_client.send_progress( | |
| job_id="job-1", | |
| percent=42.5, | |
| speed=1024000.0, | |
| eta=30.0, | |
| downloaded_bytes=10485760, | |
| total_bytes=25165824, | |
| )) | |
| def test_send_download_done_no_raise(): | |
| asyncio.run(event_client.send_download_done( | |
| job_id="job-1", | |
| file_size_bytes=25165824, | |
| duration_seconds=12.5, | |
| filename="video.mp4", | |
| )) | |
| def test_send_download_error_no_raise(): | |
| asyncio.run(event_client.send_download_error( | |
| job_id="job-1", | |
| error_message="Download timed out", | |
| )) | |