Files
MoviePilot/tests/test_plugin_catalog_composition.py
DDSRem e0642eafa7 chore(types): reduce v3 host mypy debt (#7057)
* 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
2026-10-18 09:37:49 +08:00

33 lines
983 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""
验证启动组合根注入插件目录时的版本比较契约。
"""
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