mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-09 01:16:50 +08:00
fix(config): 更新配置成功时返回空字符串消息,修复保存设置 500 错误
This commit is contained in:
@@ -907,7 +907,8 @@ class Settings(BaseSettings, ConfigModel, LogConfigModel):
|
|||||||
"""
|
"""
|
||||||
更新 env 配置
|
更新 env 配置
|
||||||
"""
|
"""
|
||||||
message = None
|
# 成功且无提示时使用空字符串,保证与 Tuple[bool, str] 返回类型一致
|
||||||
|
message = ""
|
||||||
is_converted = original_value is not None and str(original_value) != str(
|
is_converted = original_value is not None and str(original_value) != str(
|
||||||
converted_value
|
converted_value
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -11,14 +11,14 @@ def test_update_float_setting_accepts_json_integer(monkeypatch) -> None:
|
|||||||
field_name: str,
|
field_name: str,
|
||||||
original_value: Any,
|
original_value: Any,
|
||||||
converted_value: Any,
|
converted_value: Any,
|
||||||
) -> tuple[bool, None]:
|
) -> tuple[bool, str]:
|
||||||
"""记录待持久化配置,避免测试写入真实配置文件。"""
|
"""记录待持久化配置,避免测试写入真实配置文件。"""
|
||||||
persisted.update(
|
persisted.update(
|
||||||
field_name=field_name,
|
field_name=field_name,
|
||||||
original_value=original_value,
|
original_value=original_value,
|
||||||
converted_value=converted_value,
|
converted_value=converted_value,
|
||||||
)
|
)
|
||||||
return True, None
|
return True, ""
|
||||||
|
|
||||||
monkeypatch.setattr(settings, "LLM_TEMPERATURE", 0.3)
|
monkeypatch.setattr(settings, "LLM_TEMPERATURE", 0.3)
|
||||||
monkeypatch.setattr(
|
monkeypatch.setattr(
|
||||||
@@ -30,7 +30,7 @@ def test_update_float_setting_accepts_json_integer(monkeypatch) -> None:
|
|||||||
success, message = settings.update_setting("LLM_TEMPERATURE", 1)
|
success, message = settings.update_setting("LLM_TEMPERATURE", 1)
|
||||||
|
|
||||||
assert success is True
|
assert success is True
|
||||||
assert message is None
|
assert message == ""
|
||||||
assert settings.LLM_TEMPERATURE == 1.0
|
assert settings.LLM_TEMPERATURE == 1.0
|
||||||
assert isinstance(settings.LLM_TEMPERATURE, float)
|
assert isinstance(settings.LLM_TEMPERATURE, float)
|
||||||
assert persisted == {
|
assert persisted == {
|
||||||
|
|||||||
Reference in New Issue
Block a user