Files
agent-desktop/tests/test_pineagents_catalog.py
T

68 lines
1.9 KiB
Python
Raw Normal View History

# -*- coding: utf-8 -*-
"""PineAgents 模型静态展示目录单测。"""
import pytest
from pineagents.providers.pineagents_catalog import (
PINEAGENTS_MODEL_CATALOG as _catalog_pub,
enrich_catalog,
)
from pineagents.providers.provider import ModelInfo
pytestmark = pytest.mark.unit
def test_enrich_catalog_hit_fills_metadata():
"""命中目录:回填描述/价格/分类/标签/is_free,且不改调用参数。"""
src = [
ModelInfo(
id="qwen3.7-max",
name="Qwen3.7 Max",
supports_image=False,
supports_video=False,
thinking_enabled=True,
)
]
out = enrich_catalog(src)
m = out[0]
assert m.description
assert m.price
assert m.category == "文本"
assert m.tags
# 调用参数保持不变
assert m.thinking_enabled is True
assert m.supports_multimodal is None
def test_enrich_catalog_free_model():
"""免费模型 is_free 命中为 True。"""
out = enrich_catalog([ModelInfo(id="Qwen/Qwen3.5-122B-A10B", name="Q3.5")])
assert out[0].is_free is True
assert out[0].price == "免费"
def test_enrich_catalog_miss_degrades():
"""未命中目录:原样返回,不填充展示字段。"""
out = enrich_catalog([ModelInfo(id="unknown-model-xyz", name="X")])
m = out[0]
assert m.id == "unknown-model-xyz"
assert m.name == "X"
assert m.description is None
assert m.price is None
assert m.tags == []
def test_enrich_catalog_empty():
assert enrich_catalog([]) == []
def test_enrich_catalog_case_insensitive():
"""id 大小写不同仍能命中(查找表已归一化)。"""
out = enrich_catalog([ModelInfo(id="MINIMAX-M2.5", name="MM")])
assert out[0].category == "文本"
def test_catalog_public_entries():
"""公共目录表不应为空(供回填使用)。"""
assert len(_catalog_pub) > 0