Files
xiaoxia-saas/packages/adapters/in_memory/asset_repository.py
T
xiaoxia cdcc919853
CI/CD Pipeline / Frontend Lint (push) Failing after 142h2m16s
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 142h2m23s
Deploy / Production Browser E2E (push) Failing after 1800h37m37s
Deploy / Build Production Runtime Images (push) Failing after 1800h37m47s
Deploy / Deploy Staging (push) Has been cancelled
Deploy / Deploy Production (push) Failing after 1801h9m5s
ci: 补全集成测试和部署后冒烟测试
- tests.yml: 添加集成测试步骤(单元测试后执行 pytest tests/integration)
- ci-cd.yml: 添加集成测试步骤
- deploy.yml: 添加部署后冒烟测试(健康检查 + 登录API验证 + /docs端点检查)
- requirements-dev.txt: 添加 pytest-timeout 依赖
- test_auth.py: 修复预期状态码(201→200),需要PG的测试添加skipif标记
- test_api.py: 修复预期状态码和错误消息格式,添加skipif标记
- test_projects.py: 修复 ListAssetLibrariesUseCase.execute() 调用签名
- InMemoryAssetRepository: 添加 find_by_library 别名匹配端口接口

集成测试结果: 101 passed, 19 skipped (需PG的认证测试)
无外部依赖的测试全部通过
2026-07-03 14:51:50 +08:00

38 lines
1.2 KiB
Python
Executable File

"""Asset InMemory Repository 实现"""
from packages.domain import Asset
class InMemoryAssetRepository:
"""素材 InMemory 仓储实现(用于同步用例和测试)"""
def __init__(self):
self._assets: dict[str, Asset] = {}
def create(self, asset: Asset) -> Asset:
self._assets[asset.id] = asset
return asset
def get(self, asset_id: str) -> Asset | None:
return self._assets.get(asset_id)
def list_by_project(self, project_id: str) -> list[Asset]:
return [asset for asset in self._assets.values() if asset.project_id == project_id]
def list_by_library(self, library_id: str) -> list[Asset]:
return [asset for asset in self._assets.values() if asset.library_id == library_id]
def find_by_library(self, library_id: str) -> list[Asset]:
"""Alias for list_by_library to match the port interface."""
return self.list_by_library(library_id)
def update(self, asset: Asset) -> Asset:
self._assets[asset.id] = asset
return asset
def delete(self, asset_id: str) -> bool:
if asset_id in self._assets:
del self._assets[asset_id]
return True
return False