chore: snapshot workflow migration progress
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import uuid
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_batch_delete_assets_awaits_global_admin_guard(client, auth_headers, monkeypatch):
|
||||
guard_calls: list[str] = []
|
||||
deleted_asset_ids: list[str] = []
|
||||
|
||||
async def _guard(user):
|
||||
guard_calls.append(str(user.id))
|
||||
return user
|
||||
|
||||
async def _delete_media_asset(_db, asset_id):
|
||||
deleted_asset_ids.append(str(asset_id))
|
||||
return True
|
||||
|
||||
monkeypatch.setattr("app.utils.auth.require_global_admin", _guard)
|
||||
monkeypatch.setattr("app.domains.media.service.delete_media_asset", _delete_media_asset)
|
||||
|
||||
asset_ids = [str(uuid.uuid4()), str(uuid.uuid4())]
|
||||
response = await client.post("/api/media/batch-delete", json=asset_ids, headers=auth_headers)
|
||||
|
||||
assert response.status_code == 200, response.text
|
||||
assert len(guard_calls) == 1
|
||||
assert deleted_asset_ids == asset_ids
|
||||
assert response.json() == {"deleted": 2, "requested": 2}
|
||||
Reference in New Issue
Block a user