mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-10-29 11:27:43 +08:00
* chore(types): clear AniList endpoint mypy debt * chore(types): clear Douban endpoint mypy debt * chore(types): clear recommendation endpoint mypy debt * chore(types): clear subscription notification mypy debt * chore(types): clear SDK string compatibility mypy debt * chore(types): ratchet v3 host mypy across remaining files * chore(types): reduce v3 host mypy debt and retire ledger * chore(types): reconcile host snapshot with upstream HTTP pool * test(types): cover host paths exposed by mypy cleanup
33 lines
983 B
Python
33 lines
983 B
Python
"""
|
||
验证启动组合根注入插件目录时的版本比较契约。
|
||
"""
|
||
|
||
from types import SimpleNamespace
|
||
from unittest.mock import AsyncMock
|
||
|
||
import pytest
|
||
|
||
from app.startup.initializers import plugins as plugins_initializer
|
||
|
||
|
||
def test_catalog_version_comparison_accepts_only_explicit_success(
|
||
monkeypatch: pytest.MonkeyPatch,
|
||
) -> None:
|
||
"""
|
||
不可解析版本返回 False,避免把比较失败当作可安装候选。
|
||
|
||
:param monkeypatch: 用无网络客户端隔离市场读取
|
||
"""
|
||
client = SimpleNamespace(
|
||
get_plugins=lambda *_args, **_kwargs: [],
|
||
async_get_plugins=AsyncMock(return_value=[]),
|
||
)
|
||
monkeypatch.setattr(
|
||
plugins_initializer, "get_composed_plugin_market_client", lambda: client
|
||
)
|
||
|
||
catalog = plugins_initializer._build_plugin_catalog(lambda plugin: plugin)
|
||
|
||
assert catalog._version_compare("2.0.0", "gt", "1.0.0") is True
|
||
assert catalog._version_compare("invalid", "gt", "1.0.0") is False
|