feat: add resource library and real image workflow

This commit is contained in:
afei A
2026-03-29 00:24:29 +08:00
parent eeaff269eb
commit 04da401ab4
38 changed files with 3033 additions and 117 deletions

View File

@@ -0,0 +1,63 @@
import pytest
@pytest.mark.asyncio
async def test_library_resource_can_be_updated_and_archived(api_runtime):
client, _ = api_runtime
create_response = await client.post(
"/api/v1/library/resources",
json={
"resource_type": "model",
"name": "Ava Studio",
"description": "棚拍女模特",
"tags": ["女装", "棚拍"],
"gender": "female",
"age_group": "adult",
"files": [
{
"file_role": "original",
"storage_key": "library/models/ava/original.png",
"public_url": "https://images.marcusd.me/library/models/ava/original.png",
"mime_type": "image/png",
"size_bytes": 1024,
"sort_order": 0,
},
{
"file_role": "thumbnail",
"storage_key": "library/models/ava/thumb.png",
"public_url": "https://images.marcusd.me/library/models/ava/thumb.png",
"mime_type": "image/png",
"size_bytes": 256,
"sort_order": 0,
},
],
},
)
assert create_response.status_code == 201
resource = create_response.json()
update_response = await client.patch(
f"/api/v1/library/resources/{resource['id']}",
json={
"name": "Ava Studio Updated",
"description": "新的描述",
"tags": ["女装", "更新"],
},
)
assert update_response.status_code == 200
updated = update_response.json()
assert updated["name"] == "Ava Studio Updated"
assert updated["description"] == "新的描述"
assert updated["tags"] == ["女装", "更新"]
archive_response = await client.delete(f"/api/v1/library/resources/{resource['id']}")
assert archive_response.status_code == 200
assert archive_response.json()["id"] == resource["id"]
list_response = await client.get("/api/v1/library/resources", params={"resource_type": "model"})
assert list_response.status_code == 200
assert list_response.json()["items"] == []