feat: 统一生产初始化流程并保护系统管理员

This commit is contained in:
Cheng Zhou
2026-03-27 17:17:32 +08:00
parent f2f856ea24
commit a67991740e
14 changed files with 492 additions and 10 deletions
+31
View File
@@ -0,0 +1,31 @@
import uuid
import pytest
from app.crud import study as study_crud
class _FakeDb:
def __init__(self):
self.tables = []
self.committed = False
async def execute(self, stmt):
table = getattr(getattr(stmt, "table", None), "name", None)
if table:
self.tables.append(table)
async def commit(self):
self.committed = True
@pytest.mark.asyncio
async def test_delete_study_removes_contract_fee_payments_before_contract_fees():
db = _FakeDb()
await study_crud.delete(db, uuid.uuid4())
assert "contract_fee_payments" in db.tables
assert "contract_fees" in db.tables
assert db.tables.index("contract_fee_payments") < db.tables.index("contract_fees")
assert db.committed is True