fix(test): 集成测试StubAssetRepository增加status参数+素材默认ready
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 21s
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 59s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 1m1s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 16s
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Successful in 2m46s
Auto Approve CI PRs / Auto Approve on CI Green (pull_request) Successful in 3m13s
AI Code Review / AI Code Review (pull_request) Successful in 4m36s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 1m28s
Auto Merge CI PRs / Auto Merge on CI Green + Approved (pull_request) Successful in 4m43s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 6s
CI Build & Deploy Pipeline / Production Browser E2E (pull_request) Failing after 1436h46m35s
CI Build & Deploy Pipeline / Staging API Integration Tests (pull_request) Failing after 1436h46m37s
CI Build & Deploy Pipeline / Staging E2E Tests (pull_request) Failing after 1436h46m37s
CI Build & Deploy Pipeline / Build Production API Image (pull_request) Failing after 1436h46m39s
CI Build & Deploy Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Failing after 1436h46m39s
CI Build & Deploy Pipeline / Build Production Worker Image (pull_request) Failing after 1436h46m39s
CI Build & Deploy Pipeline / Build Staging Worker Image (pull_request) Failing after 1436h46m41s
CI Build & Deploy Pipeline / Build Staging Web Image (pull_request) Failing after 1436h46m42s
CI Build & Deploy Pipeline / Build Staging API Image (pull_request) Failing after 1436h46m42s
CI Build & Deploy Pipeline / Deploy Production (pull_request) Failing after 1437h18m39s
CI Build & Deploy Pipeline / Build Production Web Image (pull_request) Failing after 1437h18m42s
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 21s
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 59s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 1m1s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 16s
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Successful in 2m46s
Auto Approve CI PRs / Auto Approve on CI Green (pull_request) Successful in 3m13s
AI Code Review / AI Code Review (pull_request) Successful in 4m36s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 1m28s
Auto Merge CI PRs / Auto Merge on CI Green + Approved (pull_request) Successful in 4m43s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 6s
CI Build & Deploy Pipeline / Production Browser E2E (pull_request) Failing after 1436h46m35s
CI Build & Deploy Pipeline / Staging API Integration Tests (pull_request) Failing after 1436h46m37s
CI Build & Deploy Pipeline / Staging E2E Tests (pull_request) Failing after 1436h46m37s
CI Build & Deploy Pipeline / Build Production API Image (pull_request) Failing after 1436h46m39s
CI Build & Deploy Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Failing after 1436h46m39s
CI Build & Deploy Pipeline / Build Production Worker Image (pull_request) Failing after 1436h46m39s
CI Build & Deploy Pipeline / Build Staging Worker Image (pull_request) Failing after 1436h46m41s
CI Build & Deploy Pipeline / Build Staging Web Image (pull_request) Failing after 1436h46m42s
CI Build & Deploy Pipeline / Build Staging API Image (pull_request) Failing after 1436h46m42s
CI Build & Deploy Pipeline / Deploy Production (pull_request) Failing after 1437h18m39s
CI Build & Deploy Pipeline / Build Production Web Image (pull_request) Failing after 1437h18m42s
- StubAssetRepository的find/count方法增加status可选参数 - 列表测试创建的素材改为status=ready,匹配默认过滤规则 - 补充按created_at倒序排序,与真实实现行为一致
This commit is contained in:
@@ -103,19 +103,35 @@ class StubAssetRepository:
|
||||
def find_by_id(self, asset_id: str) -> Asset | None:
|
||||
return self._assets.get(asset_id)
|
||||
|
||||
def find_by_library(self, library_id: str, skip: int = 0, limit: int = 100) -> list[Asset]:
|
||||
def find_by_library(
|
||||
self, library_id: str, skip: int = 0, limit: int = 100, status: list[str] | None = None
|
||||
) -> list[Asset]:
|
||||
items = [a for a in self._assets.values() if a.library_id == library_id]
|
||||
if status:
|
||||
items = [a for a in items if a.status.value in status]
|
||||
items.sort(key=lambda a: a.created_at, reverse=True)
|
||||
return items[skip : skip + limit]
|
||||
|
||||
def find_by_library_and_file_type(self, library_id: str, file_type: str) -> list[Asset]:
|
||||
return [
|
||||
def find_by_library_and_file_type(
|
||||
self, library_id: str, file_type: str, skip: int = 0, limit: int = 100, status: list[str] | None = None
|
||||
) -> list[Asset]:
|
||||
items = [
|
||||
a
|
||||
for a in self._assets.values()
|
||||
if a.library_id == library_id and a.mime_type and a.mime_type.startswith(file_type)
|
||||
]
|
||||
if status:
|
||||
items = [a for a in items if a.status.value in status]
|
||||
items.sort(key=lambda a: a.created_at, reverse=True)
|
||||
return items[skip : skip + limit]
|
||||
|
||||
def find_by_project(self, project_id: str, skip: int = 0, limit: int = 100) -> list[Asset]:
|
||||
def find_by_project(
|
||||
self, project_id: str, skip: int = 0, limit: int = 100, status: list[str] | None = None
|
||||
) -> list[Asset]:
|
||||
items = [a for a in self._assets.values() if a.project_id == project_id]
|
||||
if status:
|
||||
items = [a for a in items if a.status.value in status]
|
||||
items.sort(key=lambda a: a.created_at, reverse=True)
|
||||
return items[skip : skip + limit]
|
||||
|
||||
def update(self, asset: Asset) -> Asset:
|
||||
@@ -184,11 +200,17 @@ class StubAssetRepository:
|
||||
count += 1
|
||||
return count
|
||||
|
||||
def count_by_project(self, project_id: str) -> int:
|
||||
return len([a for a in self._assets.values() if a.project_id == project_id])
|
||||
def count_by_project(self, project_id: str, status: list[str] | None = None) -> int:
|
||||
items = [a for a in self._assets.values() if a.project_id == project_id]
|
||||
if status:
|
||||
items = [a for a in items if a.status.value in status]
|
||||
return len(items)
|
||||
|
||||
def count_by_project_ids(self, project_ids: list[str]) -> int:
|
||||
return len([a for a in self._assets.values() if a.project_id in project_ids])
|
||||
def count_by_project_ids(self, project_ids: list[str], status: list[str] | None = None) -> int:
|
||||
items = [a for a in self._assets.values() if a.project_id in project_ids]
|
||||
if status:
|
||||
items = [a for a in items if a.status.value in status]
|
||||
return len(items)
|
||||
|
||||
def find_by_library_and_file_hash(self, library_id: str, file_hash: str) -> Asset | None:
|
||||
if not file_hash:
|
||||
@@ -395,7 +417,7 @@ class TestListAssets:
|
||||
"""获取素材列表端点测试。"""
|
||||
|
||||
def _create_test_assets(self, client, count: int = 3):
|
||||
"""辅助方法:创建测试素材。"""
|
||||
"""辅助方法:创建测试素材(status=ready)。"""
|
||||
for i in range(count):
|
||||
client.post(
|
||||
"/api/v1/assets",
|
||||
@@ -406,6 +428,7 @@ class TestListAssets:
|
||||
"storage_key": f"uploads/video-{i}.mp4",
|
||||
"mime_type": "video/mp4",
|
||||
"file_size": 1024 * (i + 1),
|
||||
"status": "ready",
|
||||
},
|
||||
)
|
||||
|
||||
@@ -457,6 +480,7 @@ class TestListAssets:
|
||||
"name": "hello-world.mp4",
|
||||
"storage_key": "uploads/hello.mp4",
|
||||
"mime_type": "video/mp4",
|
||||
"status": "ready",
|
||||
},
|
||||
)
|
||||
client.post(
|
||||
@@ -467,6 +491,7 @@ class TestListAssets:
|
||||
"name": "goodbye.mp4",
|
||||
"storage_key": "uploads/goodbye.mp4",
|
||||
"mime_type": "video/mp4",
|
||||
"status": "ready",
|
||||
},
|
||||
)
|
||||
|
||||
@@ -768,6 +793,7 @@ class TestAssetsCRUDFlow:
|
||||
"mime_type": "video/mp4",
|
||||
"file_size": 8192,
|
||||
"metadata": {"source": "test"},
|
||||
"status": "ready",
|
||||
},
|
||||
)
|
||||
assert create_resp.status_code == 200
|
||||
|
||||
Reference in New Issue
Block a user