feat: 服务端集成自动打包流程
This commit is contained in:
+6
-3
@@ -20,15 +20,18 @@ from backend.database import init_db, engine, Base
|
||||
def setup_db():
|
||||
"""每个测试前重建数据库"""
|
||||
Base.metadata.drop_all(bind=engine)
|
||||
Base.metadata.create_all(bind=engine)
|
||||
init_db()
|
||||
yield
|
||||
Base.metadata.drop_all(bind=engine)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
"""FastAPI 测试客户端"""
|
||||
return TestClient(app)
|
||||
"""已登录的 FastAPI 测试客户端"""
|
||||
test_client = TestClient(app)
|
||||
response = test_client.post("/api/auth/login", json={"username": "admin", "password": "admin123"})
|
||||
test_client.headers.update({"Authorization": f"Bearer {response.json()['token']}"})
|
||||
return test_client
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
Reference in New Issue
Block a user