File size: 1,467 Bytes
57d4dbb
 
 
 
0d11aa0
57d4dbb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from pathlib import Path
ROOT=Path(__file__).resolve().parents[1]

def test_version():
    assert (ROOT/"VERSION").read_text(encoding="utf-8").strip()=="4.6.1"

def test_network_loss_pauses_not_fails_all():
    js=(ROOT/"static"/"js"/"app.js").read_text(encoding="utf-8")
    assert "function pauseBatchForNetwork" in js
    assert "网络中断,下载已暂停" in js
    assert "已完成文件不会重复下载" in js
    assert "if(isDownloadNetworkError(err))" in js

def test_opfs_resume_path_exists():
    js=(ROOT/"static"/"js"/"app.js").read_text(encoding="utf-8")
    assert "function opfsAvailable" in js
    assert "navigator.storage.getDirectory" in js
    assert "streamManagedDownloadToOpfs" in js
    assert 'headers["Range"]="bytes="+resumeStart+"-"' in js
    assert "await writable.seek(start)" in js

def test_auto_resume_hooks_exist():
    js=(ROOT/"static"/"js"/"app.js").read_text(encoding="utf-8")
    assert 'addEventListener("offline"' in js
    assert 'addEventListener("online"' in js
    assert "网络已恢复,正在继续下载" in js

def test_backend_incomplete_stream_becomes_paused():
    py=(ROOT/"routes"/"downloads.py").read_text(encoding="utf-8")
    assert 'final_status="paused"' in py
    assert 'status=final_status' in py

def test_download_ticket_can_renew():
    py=(ROOT/"routes"/"downloads.py").read_text(encoding="utf-8")
    assert "stream_token_issued_ts" in py
    assert "_stream_url(job, renew=True)" in py