Files
harry0703androngdu88668-ux b32b2cfe3b test(ci): expand regression coverage
Run the complete pytest suite with branch coverage and enforce a stable CI threshold. Add regression tests for task pipelines, controllers, queues, media handling, and application startup. Harden edge cases revealed by the expanded suite.

Refs: #1048

Co-authored-by: rongdu88668-ux <rongdu88668@gmail.com>
2026-07-13 18:08:07 +08:00

31 lines
900 B
Python

import runpy
from pathlib import Path
from unittest.mock import patch
from app.config import config
ROOT_DIR = Path(__file__).resolve().parent.parent
def test_main_starts_uvicorn_with_runtime_config():
"""
服务启动入口只负责把运行配置交给 Uvicorn。这里 mock 真正的服务器启动,
既避免测试占用端口,也确认监听地址、端口和热重载配置不会在入口层丢失。
"""
with (
patch.object(config, "listen_host", "127.0.0.1"),
patch.object(config, "listen_port", 8765),
patch.object(config, "reload_debug", True),
patch("uvicorn.run") as run_server,
):
runpy.run_path(str(ROOT_DIR / "main.py"), run_name="__main__")
run_server.assert_called_once_with(
app="app.asgi:app",
host="127.0.0.1",
port=8765,
reload=True,
log_level="warning",
)