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
95 lines
2.7 KiB
Python
95 lines
2.7 KiB
Python
from __future__ import annotations
|
|
|
|
from unittest.mock import MagicMock
|
|
|
|
from integrations.incident_io.tools import IncidentIoIncidentsTool
|
|
|
|
|
|
def test_incident_io_tool_extracts_credentials_from_sources() -> None:
|
|
tool = IncidentIoIncidentsTool()
|
|
|
|
params = tool.extract_params(
|
|
{
|
|
"incident_io": {
|
|
"api_key": "secret",
|
|
"base_url": "https://api.incident.io",
|
|
"incident_id": "inc-123",
|
|
}
|
|
}
|
|
)
|
|
|
|
assert params["api_key"] == "secret"
|
|
assert params["action"] == "context"
|
|
assert params["incident_id"] == "inc-123"
|
|
assert tool.input_schema["required"] == []
|
|
|
|
|
|
def test_incident_io_tool_runs_context(monkeypatch) -> None:
|
|
tool = IncidentIoIncidentsTool()
|
|
client = MagicMock()
|
|
client.__enter__.return_value = client
|
|
client.__exit__.return_value = None
|
|
client.get_incident_context.return_value = {
|
|
"success": True,
|
|
"incident": {"id": "inc-123"},
|
|
"incident_updates": [],
|
|
}
|
|
|
|
monkeypatch.setattr(
|
|
"integrations.incident_io.tools.make_incident_io_client",
|
|
lambda *_args, **_kwargs: client,
|
|
)
|
|
|
|
result = tool.run(api_key="secret", action="context", incident_id="inc-123")
|
|
|
|
assert result["success"] is True
|
|
assert result["source"] == "incident_io"
|
|
client.get_incident_context.assert_called_once_with("inc-123", update_limit=20)
|
|
|
|
|
|
def test_incident_io_tool_runs_append_summary(monkeypatch) -> None:
|
|
tool = IncidentIoIncidentsTool()
|
|
client = MagicMock()
|
|
client.__enter__.return_value = client
|
|
client.__exit__.return_value = None
|
|
client.append_summary_update.return_value = {"success": True}
|
|
|
|
monkeypatch.setattr(
|
|
"integrations.incident_io.tools.make_incident_io_client",
|
|
lambda *_args, **_kwargs: client,
|
|
)
|
|
|
|
result = tool.run(
|
|
api_key="secret",
|
|
action="append_summary",
|
|
incident_id="inc-123",
|
|
title="RCA",
|
|
body="Finding",
|
|
notify_incident_channel=True,
|
|
)
|
|
|
|
assert result["success"] is True
|
|
client.append_summary_update.assert_called_once_with(
|
|
"inc-123",
|
|
title="RCA",
|
|
body="Finding",
|
|
notify_incident_channel=True,
|
|
)
|
|
|
|
|
|
def test_incident_io_tool_requires_incident_id_for_context(monkeypatch) -> None:
|
|
tool = IncidentIoIncidentsTool()
|
|
client = MagicMock()
|
|
client.__enter__.return_value = client
|
|
client.__exit__.return_value = None
|
|
|
|
monkeypatch.setattr(
|
|
"integrations.incident_io.tools.make_incident_io_client",
|
|
lambda *_args, **_kwargs: client,
|
|
)
|
|
|
|
result = tool.run(api_key="secret", action="context")
|
|
|
|
assert result["success"] is False
|
|
assert "incident_id" in result["error"]
|