mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-09 08:30:45 +08:00
- 在 oclaw/ 下重新初始化 Git 仓库 - 补齐子仓库 .gitignore,避免提交本地运行态数据(_local、node_modules、logs 等) - 提交当前工程代码与配置 Made-with: Cursor
34 lines
1.4 KiB
Python
34 lines
1.4 KiB
Python
from __future__ import annotations
|
|
|
|
import json
|
|
from pathlib import Path
|
|
|
|
from oclaw.openclaw_runtime.hooks_runtime import resolve_runtime_config
|
|
|
|
|
|
def test_resolve_runtime_config_from_env_json(monkeypatch) -> None:
|
|
monkeypatch.setenv(
|
|
"OPENCLAW_RUNTIME_CONFIG_JSON",
|
|
json.dumps({"hooks": {"internal": {"enabled": False, "entries": {"x": {"enabled": False}}}}}),
|
|
)
|
|
monkeypatch.delenv("OPENCLAW_CONFIG_PATH", raising=False)
|
|
cfg = resolve_runtime_config()
|
|
assert ((cfg.get("hooks") or {}).get("internal") or {}).get("enabled") is False
|
|
assert ((cfg.get("hooks") or {}).get("internal") or {}).get("entries", {}).get("x", {}).get("enabled") is False
|
|
|
|
|
|
def test_resolve_runtime_config_from_config_path(monkeypatch, tmp_path: Path) -> None:
|
|
cfg_path = tmp_path / "openclaw.custom.json"
|
|
cfg_path.write_text(
|
|
json.dumps({"hooks": {"internal": {"enabled": True, "entries": {"session-memory": {"messages": 99}}}}}),
|
|
encoding="utf-8",
|
|
)
|
|
monkeypatch.delenv("OPENCLAW_RUNTIME_CONFIG_JSON", raising=False)
|
|
monkeypatch.setenv("OPENCLAW_CONFIG_PATH", str(cfg_path))
|
|
cfg = resolve_runtime_config()
|
|
assert ((cfg.get("hooks") or {}).get("internal") or {}).get("enabled") is True
|
|
assert (
|
|
((cfg.get("hooks") or {}).get("internal") or {}).get("entries", {}).get("session-memory", {}).get("messages")
|
|
== 99
|
|
)
|
|
|