完善审计日志展示与导出权限
This commit is contained in:
@@ -8,12 +8,14 @@ from app.crud import study as study_crud
|
||||
class _FakeDb:
|
||||
def __init__(self):
|
||||
self.tables = []
|
||||
self.operations = []
|
||||
self.committed = False
|
||||
|
||||
async def execute(self, stmt):
|
||||
table = getattr(getattr(stmt, "table", None), "name", None)
|
||||
if table:
|
||||
self.tables.append(table)
|
||||
self.operations.append((getattr(stmt, "__visit_name__", ""), table))
|
||||
|
||||
async def commit(self):
|
||||
self.committed = True
|
||||
@@ -29,3 +31,13 @@ async def test_delete_study_removes_contract_fee_payments_before_contract_fees()
|
||||
assert "contract_fees" in db.tables
|
||||
assert db.tables.index("contract_fee_payments") < db.tables.index("contract_fees")
|
||||
assert db.committed is True
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_delete_study_preserves_audit_logs():
|
||||
db = _FakeDb()
|
||||
|
||||
await study_crud.delete(db, uuid.uuid4())
|
||||
|
||||
assert ("delete", "audit_logs") not in db.operations
|
||||
assert ("update", "audit_logs") in db.operations
|
||||
|
||||
Reference in New Issue
Block a user