""" 认证模块测试 """ import pytest from fastapi.testclient import TestClient from app.main import app client = TestClient(app) class TestAuth: """认证测试类""" def test_login_success(self): """测试登录成功""" response = client.post( "/api/v1/auth/login", data={"username": "admin", "password": "admin123"} ) # 注意:实际测试需要正确的密码 assert response.status_code in [200, 401] def test_health_check(self): """测试健康检查""" response = client.get("/health") assert response.status_code == 200 assert response.json()["status"] == "healthy" def test_root(self): """测试根路径""" response = client.get("/") assert response.status_code == 200 data = response.json() assert "name" in data assert "version" in data class TestKline: """K 线数据测试类""" def test_get_symbols(self): """测试获取品种列表""" response = client.get("/api/v1/kline/symbols") assert response.status_code == 200 def test_get_periods(self): """测试获取周期列表""" response = client.get("/api/v1/kline/periods") assert response.status_code == 200 if __name__ == "__main__": pytest.main([__file__, "-v"])