mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 03:09:49 +08:00
A failed GET /api/settings left Appearance on "system". Applying any later UI change wrote that placeholder and replaced an explicit local palette. Seed the form from the stored preference, and omit theme from Apply until the server has confirmed one.
34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
"""Fresh setup must write the same theme default the settings module owns."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from deeptutor.services.settings.interface_settings import DEFAULT_UI_SETTINGS
|
|
|
|
|
|
def test_fresh_init_writes_the_interface_theme_default(
|
|
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
|
|
) -> None:
|
|
from deeptutor.services.path_service import PathService
|
|
from deeptutor.services.setup import init as setup_init
|
|
|
|
service = PathService(workspace_root=tmp_path)
|
|
monkeypatch.setattr(setup_init, "get_path_service", lambda: service)
|
|
monkeypatch.setattr(setup_init, "_seed_default_personas", lambda: None)
|
|
monkeypatch.setattr(
|
|
"deeptutor.services.config.ensure_runtime_settings_files",
|
|
lambda: None,
|
|
)
|
|
|
|
setup_init.init_user_directories()
|
|
|
|
interface_file = service.get_settings_file("interface")
|
|
stored = json.loads(interface_file.read_text(encoding="utf-8"))
|
|
assert stored["theme"] == "system"
|
|
assert stored["theme"] == DEFAULT_UI_SETTINGS["theme"]
|
|
assert stored["theme"] == setup_init.DEFAULT_INTERFACE_SETTINGS["theme"]
|