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
72 lines
2.1 KiB
Python
72 lines
2.1 KiB
Python
from __future__ import annotations
|
|
|
|
from unittest.mock import MagicMock
|
|
|
|
import pytest
|
|
from rich.console import Console
|
|
|
|
from surfaces.interactive_shell.runtime.background.runner import (
|
|
drain_background_notices,
|
|
start_background_template_investigation,
|
|
)
|
|
from surfaces.interactive_shell.session import Session
|
|
|
|
|
|
def test_enqueue_and_drain_background_notices() -> None:
|
|
import io
|
|
|
|
from rich.console import Console
|
|
|
|
session = Session()
|
|
session.terminal.enqueue_background_notice("[bold]done[/bold]")
|
|
console = Console(file=io.StringIO(), force_terminal=False, highlight=False)
|
|
|
|
drain_background_notices(session, console)
|
|
|
|
assert session.terminal.drain_background_notices() == []
|
|
assert "done" in console.file.getvalue()
|
|
|
|
|
|
def test_start_background_template_investigation_assigns_fresh_investigation_id(
|
|
monkeypatch: pytest.MonkeyPatch,
|
|
) -> None:
|
|
import io
|
|
|
|
session = Session()
|
|
session.last_investigation_id = "inv-stale"
|
|
console = Console(file=io.StringIO(), force_terminal=False, highlight=False)
|
|
|
|
def _fake_run(
|
|
*,
|
|
cancel_requested,
|
|
template_name: str,
|
|
context_overrides,
|
|
) -> dict[str, object]:
|
|
_ = (cancel_requested, template_name, context_overrides)
|
|
return {"root_cause": "done"}
|
|
|
|
monkeypatch.setattr(
|
|
"surfaces.interactive_shell.runtime.investigation_adapter.run_sample_alert_for_session_background",
|
|
_fake_run,
|
|
)
|
|
monkeypatch.setattr(
|
|
"surfaces.interactive_shell.runtime.background.runner.track_investigation",
|
|
lambda **_kwargs: MagicMock(
|
|
__enter__=MagicMock(return_value=MagicMock()),
|
|
__exit__=MagicMock(return_value=False),
|
|
),
|
|
)
|
|
|
|
task_id = start_background_template_investigation(
|
|
template_name="generic",
|
|
session=session,
|
|
console=console,
|
|
display_command="/investigate generic",
|
|
investigation_target="generic",
|
|
)
|
|
|
|
assert session.last_investigation_id
|
|
assert session.last_investigation_id != "inv-stale"
|
|
record = session.terminal.background_investigations[task_id]
|
|
assert record.investigation_id == session.last_investigation_id
|