mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 01:10:23 +08:00
fix(providers): 允许 max_probe_interval_minutes 设为 0 并修复零值被覆盖的问题
- 将 max_probe_interval_minutes 校验范围从 2-32 改为 0-32 - 修复 routes.py 中 max_probe_interval_minutes 和 cache_ttl_minutes 使用 `or` 短路导致零值被默认值覆盖的问题,改用 is not None 判断 - 前端表单同步调整最小值约束和提示文案 - 新增零值校验的单元测试
This commit is contained in:
@@ -9,7 +9,7 @@ from typing import Any, cast
|
||||
import pytest
|
||||
|
||||
from src.core.exceptions import InvalidRequestException
|
||||
from src.models.endpoint_models import EndpointAPIKeyUpdate
|
||||
from src.models.endpoint_models import EndpointAPIKeyCreate, EndpointAPIKeyUpdate
|
||||
|
||||
|
||||
async def _noop_invalidate_models_list_cache() -> None:
|
||||
@@ -72,6 +72,25 @@ def _build_key(**overrides: Any) -> SimpleNamespace:
|
||||
return SimpleNamespace(**base)
|
||||
|
||||
|
||||
def test_key_create_accepts_zero_max_probe_interval_minutes() -> None:
|
||||
payload = EndpointAPIKeyCreate.model_validate(
|
||||
{
|
||||
"name": "key-1",
|
||||
"api_key": "secret",
|
||||
"api_formats": ["openai:chat"],
|
||||
"max_probe_interval_minutes": 0,
|
||||
}
|
||||
)
|
||||
|
||||
assert payload.max_probe_interval_minutes == 0
|
||||
|
||||
|
||||
def test_key_update_accepts_zero_max_probe_interval_minutes() -> None:
|
||||
payload = EndpointAPIKeyUpdate.model_validate({"max_probe_interval_minutes": 0})
|
||||
|
||||
assert payload.max_probe_interval_minutes == 0
|
||||
|
||||
|
||||
def test_prepare_update_payload_auth_type_null_ignored() -> None:
|
||||
key = _build_key(auth_type="api_key")
|
||||
key_data = EndpointAPIKeyUpdate.model_validate({"auth_type": None})
|
||||
|
||||
Reference in New Issue
Block a user