auto-sync: 2026-05-17 00:31:37

This commit is contained in:
cfdaily
2026-05-17 00:31:37 +08:00
parent 88f9e4f679
commit 2305df9e0e
5 changed files with 72 additions and 0 deletions
View File
View File
View File
View File
+72
View File
@@ -0,0 +1,72 @@
"""F1 测试:项目骨架 + 配置体系"""
import pytest
from fastapi.testclient import TestClient
from src.main import app, config, load_config
@pytest.fixture
def client():
return TestClient(app)
class TestHealthEndpoint:
"""健康端点"""
def test_status_returns_200(self, client):
resp = client.get("/api/daemon/status")
assert resp.status_code == 200
def test_status_has_required_fields(self, client):
data = client.get("/api/daemon/status").json()
assert data["status"] == "running"
assert data["version"] == "2.6.0"
assert "ticker_running" in data
assert "config" in data
def test_status_config_values(self, client):
data = client.get("/api/daemon/status").json()
assert data["config"]["tick_interval"] == 30
assert data["config"]["max_global_agents"] == 5
class TestProjectsEndpoint:
"""项目列表端点(占位)"""
def test_list_projects_returns_200(self, client):
resp = client.get("/api/projects")
assert resp.status_code == 200
assert "projects" in resp.json()
class TestConfig:
"""配置加载"""
def test_config_loaded(self):
assert isinstance(config, dict)
def test_config_has_daemon_section(self):
assert "daemon" in config
assert config["daemon"]["tick_interval"] == 30
def test_config_has_inbox_section(self):
assert "inbox" in config
def test_load_config_returns_dict(self):
cfg = load_config()
assert isinstance(cfg, dict)
class TestOpenAPI:
"""Swagger 文档"""
def test_openapi_json_accessible(self, client):
resp = client.get("/openapi.json")
assert resp.status_code == 200
data = resp.json()
assert data["info"]["title"] == "Sanguo MoziPlus v2"
def test_docs_endpoint_accessible(self, client):
resp = client.get("/docs")
assert resp.status_code == 200