4b6817381b
CI (OpenClaw E2E) / openclaw test (push) Has been cancelled
CI / coverage-report (push) Has been cancelled
CI / test-kubernetes (push) Has been cancelled
CI / should-run-thorough (push) Has been cancelled
CI / test-thorough (cloudwatch-demo) (push) Has been cancelled
CI / test-thorough (flink-ecs) (push) Has been cancelled
CI / test-thorough (upstream-lambda) (push) Has been cancelled
CI / test-thorough (prefect-ecs-fargate) (push) Has been cancelled
Release / build-binaries (zip, opensre.exe, onefile, windows-latest, windows-x64) (push) Has been cancelled
Benchmark image — build + push to ECR (any adapter) / build + push (push) Has been cancelled
CI / quality (ubuntu-latest) (push) Has been cancelled
CI / test (tools-runtime) (push) Has been cancelled
CI / test (e2e-general) (push) Has been cancelled
CI / test (cli-runtime) (push) Has been cancelled
CI / test (e2e-provider-and-openclaw) (push) Has been cancelled
CI / test (integrations-and-misc) (push) Has been cancelled
Release / verify (push) Has been cancelled
Release / build-python-dist (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, macos-15-intel, darwin-x64) (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, macos-latest, darwin-arm64) (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04, linux-x64) (push) Has been cancelled
Release / publish-release (push) Has been cancelled
Release / publish-main-release (push) Has been cancelled
Interactive Shell Live (PR + post-merge) / turn-checks (no-LLM) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Interactive Shell Live (PR + post-merge) / turn-live shard ${{ matrix.shard_index }} (push) Has been cancelled
Release / prepare (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04-arm, linux-arm64) (push) Has been cancelled
Synthetic Deterministic Tests / Synthetic offline (deterministic) (push) Has been cancelled
92 lines
3.0 KiB
Python
92 lines
3.0 KiB
Python
"""Tests for Argo CD investigation tools."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
from integrations.argocd.tools import ArgoCDApplicationDiffTool, ArgoCDApplicationStatusTool
|
|
|
|
|
|
class _FakeArgoCDClient:
|
|
def __enter__(self) -> _FakeArgoCDClient:
|
|
return self
|
|
|
|
def __exit__(self, *_: object) -> None:
|
|
return None
|
|
|
|
def get_application_summary(self, application_name: str, **_: Any) -> dict[str, Any]:
|
|
return {
|
|
"success": True,
|
|
"application": {
|
|
"name": application_name,
|
|
"sync_status": "OutOfSync",
|
|
"health_status": "Degraded",
|
|
"revision": "abc123",
|
|
},
|
|
"recent_history": [{"revision": "abc123", "deployedAt": "2026-04-02T00:00:00Z"}],
|
|
}
|
|
|
|
def list_applications(self, **_: Any) -> dict[str, Any]:
|
|
return {"success": True, "applications": [{"name": "payments-api"}], "total": 1}
|
|
|
|
def get_application_diff(self, application_name: str, **_: Any) -> dict[str, Any]:
|
|
return {
|
|
"success": True,
|
|
"application_name": application_name,
|
|
"drift_detected": True,
|
|
"diffs": [{"kind": "Deployment", "name": application_name, "diff": "replicas changed"}],
|
|
"diff_count": 1,
|
|
}
|
|
|
|
|
|
_ARGOCD_SOURCE = {
|
|
"base_url": "https://argocd.example.com",
|
|
"bearer_token": "tok_test",
|
|
"username": "",
|
|
"password": "",
|
|
"project": "default",
|
|
"app_namespace": "argocd",
|
|
"application_name": "payments-api",
|
|
"verify_ssl": True,
|
|
"connection_verified": True,
|
|
}
|
|
|
|
|
|
def test_argocd_status_tool_extracts_params_and_returns_application(monkeypatch) -> None: # type: ignore[no-untyped-def]
|
|
monkeypatch.setattr(
|
|
"integrations.argocd.tools.make_argocd_client",
|
|
lambda *_args, **_kwargs: _FakeArgoCDClient(),
|
|
)
|
|
tool = ArgoCDApplicationStatusTool()
|
|
|
|
assert tool.is_available({"argocd": _ARGOCD_SOURCE}) is True
|
|
params = tool.extract_params({"argocd": _ARGOCD_SOURCE})
|
|
result = tool.run(**params)
|
|
|
|
assert result["available"] is True
|
|
assert result["application"]["name"] == "payments-api"
|
|
assert result["application"]["sync_status"] == "OutOfSync"
|
|
assert result["recent_history"][0]["revision"] == "abc123"
|
|
|
|
|
|
def test_argocd_diff_tool_reports_drift(monkeypatch) -> None: # type: ignore[no-untyped-def]
|
|
monkeypatch.setattr(
|
|
"integrations.argocd.tools.make_argocd_client",
|
|
lambda *_args, **_kwargs: _FakeArgoCDClient(),
|
|
)
|
|
tool = ArgoCDApplicationDiffTool()
|
|
|
|
result = tool.run(**tool.extract_params({"argocd": _ARGOCD_SOURCE}))
|
|
|
|
assert result["available"] is True
|
|
assert result["drift_detected"] is True
|
|
assert result["diffs"][0]["kind"] == "Deployment"
|
|
|
|
|
|
def test_argocd_tools_require_configured_source() -> None:
|
|
assert ArgoCDApplicationStatusTool().is_available({}) is False
|
|
assert (
|
|
ArgoCDApplicationDiffTool().is_available({"argocd": {"connection_verified": False}})
|
|
is False
|
|
)
|