File size: 1,208 Bytes
bbe872c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
"""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",
    ))