feat: DramaBox 全量走 App 接口,清单可停止并避免卡死
分类按 App 翻页,精选走推荐接口。清单顶部显示进度,停止后不再拉新剧,已拿到的封面继续加载。列表只绘制可见卡片,避免大量剧目占满主线程。
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import json
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
from server.services.http import HttpClient
|
||||
|
||||
|
||||
def test_proxy_is_reloaded_after_restart() -> None:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
path = Path(tmp) / "proxy.json"
|
||||
with patch("server.services.http.PROXY_PATH", path):
|
||||
first = HttpClient()
|
||||
first.configure_proxy({
|
||||
"mode": "custom",
|
||||
"scheme": "http",
|
||||
"host": "127.0.0.1",
|
||||
"port": "7897",
|
||||
"username": "",
|
||||
"password": "",
|
||||
})
|
||||
saved = json.loads(path.read_text(encoding="utf-8"))
|
||||
assert saved["mode"] == "custom"
|
||||
assert saved["host"] == "127.0.0.1"
|
||||
assert saved["port"] == "7897"
|
||||
|
||||
second = HttpClient()
|
||||
view = second.proxy_view()
|
||||
assert view["mode"] == "custom"
|
||||
assert view["scheme"] == "http"
|
||||
assert view["url"] == "http://127.0.0.1:7897"
|
||||
|
||||
|
||||
def test_invalid_proxy_file_does_not_block_startup() -> None:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
path = Path(tmp) / "proxy.json"
|
||||
path.write_text("{", encoding="utf-8")
|
||||
with patch("server.services.http.PROXY_PATH", path):
|
||||
client = HttpClient()
|
||||
assert client.proxy_view()["mode"] == "off"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_proxy_is_reloaded_after_restart()
|
||||
test_invalid_proxy_file_does_not_block_startup()
|
||||
print("ok")
|
||||
Reference in New Issue
Block a user