865f937f41
- compute_client.list_models(status): 拉取 compute 引擎 admin 模型 - 新增 compute_catalog.py(替代静态 pineagents_catalog): Model行→桌面端形状(id/name/group/价格/能力/actual_model), 仅 status=1 - rbac_opc /opc/compute/models|prices 改读 admin 模型; /v1/models 与之一致 - 删 pineagents_catalog.py(静态, 不再引用) - tests: compute_catalog._map 2 通过
26 lines
1.1 KiB
Python
26 lines
1.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""compute_catalog 模型映射(admin 模型 → 桌面端形状)纯函数测试。"""
|
|
from __future__ import annotations
|
|
|
|
from app.services.compute_catalog import _map
|
|
|
|
|
|
def test_map_admin_model():
|
|
row = {
|
|
"model_name": "deepseek-chat", "name": "DeepSeek Chat", "actual_model": "deepseek-chat",
|
|
"group": "default", "billing_unit": "/百万tokens", "input_price": 0.5, "output_price": 1.5,
|
|
"cache_hit_price": 0.1, "vision_support": False, "image_support": False,
|
|
"audio_support": True, "video_support": False, "tags": "对话,通用", "vendor_id": 0, "status": 1,
|
|
}
|
|
m = _map(row)
|
|
assert m["id"] == "deepseek-chat"
|
|
assert m["name"] == "DeepSeek Chat"
|
|
assert m["input_price"] == 0.5 and m["output_price"] == 1.5
|
|
assert m["audio_support"] is True
|
|
assert m["tags"] == ["对话", "通用"]
|
|
|
|
|
|
def test_map_falls_back_to_model_name_when_empty_name():
|
|
m = _map({"model_name": "gpt-4o", "name": ""})
|
|
assert m["id"] == "gpt-4o" and m["name"] == "gpt-4o" and m["actual_model"] == "gpt-4o"
|