_openclaw_test_support.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. from __future__ import annotations
  2. import gc
  3. from pathlib import Path
  4. import pytest
  5. from agency_swarm.integrations import openclaw as openclaw_mod
  6. from agency_swarm.integrations.openclaw import OpenClawIntegrationConfig
  7. def _build_openclaw_config(tmp_path: Path) -> OpenClawIntegrationConfig:
  8. home_dir = tmp_path / "openclaw"
  9. return OpenClawIntegrationConfig(
  10. autostart=False,
  11. host="127.0.0.1",
  12. port=18789,
  13. gateway_token="gateway-token",
  14. home_dir=home_dir,
  15. state_dir=home_dir / "state",
  16. config_path=home_dir / "openclaw.json",
  17. log_path=home_dir / "logs" / "openclaw-gateway.log",
  18. startup_timeout_seconds=5.0,
  19. proxy_timeout_seconds=30.0,
  20. default_model="openclaw:main",
  21. provider_model="openai/gpt-5.4-mini",
  22. gateway_command="openclaw gateway",
  23. tool_mode="full",
  24. )
  25. def reset_openclaw_current_app_defaults(monkeypatch: pytest.MonkeyPatch) -> None:
  26. gc.collect()
  27. monkeypatch.setattr(openclaw_mod.openclaw_model, "_CURRENT_APP_OPENCLAW_DEFAULTS", {}, raising=False)
  28. monkeypatch.setattr(openclaw_mod.openclaw_model, "_CURRENT_APP_OPENCLAW_DEFAULT_COUNTS", {}, raising=False)
  29. monkeypatch.setattr(openclaw_mod.openclaw_model, "_CURRENT_APP_OPENCLAW_DEFAULT_PATTERNS", [], raising=False)
  30. monkeypatch.setattr(openclaw_mod.openclaw_model, "_CURRENT_APP_OPENCLAW_DEFAULT_PATTERN_COUNTS", {}, raising=False)
  31. build_openclaw_config = _build_openclaw_config