mirror of
https://ghfast.top/https://github.com/aeroxw/tick-stock-panel.git
synced 2026-09-12 23:44:16 +08:00
- 统一开发脚本、Vite 代理与 Docker Compose 的 HOST/PORT 配置
- 首次启动按字面值读取 AUTH_PASSWORD,避免 ${VAR} 被环境变量插值
- 已有 auth.json 时继续以 Web 端密码为准,不受 .env 覆盖
31 lines
779 B
Python
31 lines
779 B
Python
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from app.config import Settings
|
|
|
|
|
|
def test_settings_reads_server_and_auth_values_from_env(
|
|
monkeypatch: pytest.MonkeyPatch,
|
|
tmp_path: Path,
|
|
) -> None:
|
|
for name in ("HOST", "PORT", "LOG_LEVEL", "AUTH_PASSWORD"):
|
|
monkeypatch.delenv(name, raising=False)
|
|
env_path = tmp_path / ".env"
|
|
env_path.write_text(
|
|
"HOST=127.0.0.1\n"
|
|
"PORT=4318\n"
|
|
"LOG_LEVEL=DEBUG\n"
|
|
"AUTH_PASSWORD=config-secret\n",
|
|
encoding="utf-8",
|
|
)
|
|
|
|
configured = Settings(_env_file=env_path)
|
|
|
|
assert configured.host == "127.0.0.1"
|
|
assert configured.port == 4318
|
|
assert configured.log_level == "DEBUG"
|
|
assert configured.auth_password == "config-secret"
|