mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-11-02 05:17:23 +08:00
test: isolate transactional download history rows
This commit is contained in:
@@ -14,12 +14,18 @@ from app.db.adapters.history.download import (
|
||||
SessionDownloadHistoryRepository,
|
||||
TransactionalDownloadHistoryRepository,
|
||||
)
|
||||
from app.db.models.downloadhistory import DownloadHistory
|
||||
from app.db.models.downloadhistory import DownloadFiles, DownloadHistory
|
||||
from app.db.session import SessionFactory, async_session_scope
|
||||
from app.db.uow import SqlAlchemyUnitOfWork
|
||||
from app.schemas.types import MediaSource, MediaType
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _track(db) -> None:
|
||||
"""回收仓储通过独立事务写入的历史与文件,避免污染后续用例。"""
|
||||
db.watermark(DownloadHistory, DownloadFiles)
|
||||
|
||||
|
||||
def _repository() -> TransactionalDownloadHistoryRepository:
|
||||
"""构造绑定测试数据库短 Session 的下载历史仓储。"""
|
||||
return TransactionalDownloadHistoryRepository(
|
||||
|
||||
Reference in New Issue
Block a user