diff --git a/src/api/__init__.py b/src/api/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/blackboard/__init__.py b/src/blackboard/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/cli/__init__.py b/src/cli/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/daemon/__init__.py b/src/daemon/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_main.py b/tests/test_main.py new file mode 100644 index 0000000..d84fc25 --- /dev/null +++ b/tests/test_main.py @@ -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