feat (ui): keuze default roof folder

This commit is contained in:
kodi
2026-03-09 13:41:04 +01:00
parent ab7a84ebe0
commit a22172f736
7 changed files with 146 additions and 12 deletions
+37 -2
View File
@@ -63,17 +63,49 @@ data = json.loads(Path(sys.argv[1]).read_text(encoding="utf-8"))
settings = data.get("settings")
assert isinstance(settings, dict), "settings must be object"
assert "set_file_date_to_first_aired_date" in settings, "missing setting key"
assert "default_media_root_path" in settings, "missing default root setting key"
assert isinstance(settings["set_file_date_to_first_aired_date"], bool), "setting must be boolean"
assert settings["default_media_root_path"] is None or isinstance(settings["default_media_root_path"], str), \
"default_media_root_path must be string or null"
print("settings GET validation passed")
PY
echo
echo "== Feature test 2: settings update persists round-trip =="
DEFAULT_ROOT_PATH=""
ROOTS_JSON="${TMP_DIR}/roots.json"
if curl --silent --show-error "${BASE_URL}/api/files/roots" -o "${ROOTS_JSON}"; then
DEFAULT_ROOT_PATH="$(python3 - "${ROOTS_JSON}" <<'PY'
import json
import sys
from pathlib import Path
data = json.loads(Path(sys.argv[1]).read_text(encoding="utf-8"))
items = data.get("items") or []
if items and isinstance(items[0], dict):
print(items[0].get("path") or "")
else:
print("")
PY
)"
fi
cat > "${TMP_DIR}/settings_put_true.json" <<'JSON'
{
"set_file_date_to_first_aired_date": true
"set_file_date_to_first_aired_date": true,
"default_media_root_path": "__DEFAULT_ROOT_PATH__"
}
JSON
python3 - "${TMP_DIR}/settings_put_true.json" "${DEFAULT_ROOT_PATH}" <<'PY'
import sys
from pathlib import Path
path = Path(sys.argv[1])
default_path = sys.argv[2]
text = path.read_text(encoding="utf-8")
safe = default_path.replace("\\", "\\\\").replace('"', '\\"')
path.write_text(text.replace("__DEFAULT_ROOT_PATH__", safe), encoding="utf-8")
PY
curl --fail --silent --show-error \
-X PUT "${BASE_URL}/api/session/settings" \
@@ -96,6 +128,8 @@ put_data = json.loads(Path(sys.argv[1]).read_text(encoding="utf-8"))
get_data = json.loads(Path(sys.argv[2]).read_text(encoding="utf-8"))
assert put_data["settings"]["set_file_date_to_first_aired_date"] is True, "PUT should return true"
assert get_data["settings"]["set_file_date_to_first_aired_date"] is True, "GET after PUT should be true"
assert "default_media_root_path" in put_data["settings"], "PUT missing default root setting"
assert "default_media_root_path" in get_data["settings"], "GET missing default root setting"
print("settings PUT/GET round-trip passed")
PY
@@ -198,7 +232,8 @@ fi
# Reset setting back to false to keep environment stable for subsequent runs.
cat > "${TMP_DIR}/settings_put_false.json" <<'JSON'
{
"set_file_date_to_first_aired_date": false
"set_file_date_to_first_aired_date": false,
"default_media_root_path": null
}
JSON
curl --fail --silent --show-error \