dc2d2acc82
Scaffold an MVP of the natural-language ops terminal: inventory + intent template registry, SSH/WinRM/local connectors, risk-gated executor with SQLite audit log, Claude-driven agent layer using Function Calling, plus a Typer CLI and FastAPI surface. Includes 10 cross-OS intents (disk/system/service) and example inventory. Verified end-to-end on the local Windows host: hosts/intents listing, check_disk_usage execution, and WRITE-class confirmation gating. Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
47 lines
1.6 KiB
Python
47 lines
1.6 KiB
Python
"""Smoke tests: framework loads, registry parses, local connector executes."""
|
|
from __future__ import annotations
|
|
|
|
import asyncio
|
|
import platform
|
|
|
|
import pytest
|
|
|
|
from ops_tools.config import PROJECT_ROOT, get_settings
|
|
from ops_tools.connectors.local import LocalConnector
|
|
from ops_tools.inventory.loader import load_inventory
|
|
from ops_tools.inventory.models import ConnectionType, Host, OSFamily
|
|
from ops_tools.intents.registry import load_intent_registry
|
|
|
|
|
|
def test_inventory_loads_example():
|
|
settings = get_settings()
|
|
inv = load_inventory(settings.resolve(settings.inventory_path))
|
|
# The example file ships with localhost; loader falls back to it if no real
|
|
# inventory.yaml exists.
|
|
assert "localhost" in inv.hosts
|
|
assert inv.hosts["localhost"].connection == ConnectionType.LOCAL
|
|
|
|
|
|
def test_intent_registry_has_disk_check():
|
|
reg = load_intent_registry(PROJECT_ROOT / "templates")
|
|
assert "check_disk_usage" in reg
|
|
intent = reg.get("check_disk_usage")
|
|
assert "linux" in intent.implementations
|
|
assert "windows" in intent.implementations
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_local_connector_runs():
|
|
host = Host(
|
|
name="localhost",
|
|
address="127.0.0.1",
|
|
connection=ConnectionType.LOCAL,
|
|
os_family=(OSFamily.WINDOWS if platform.system().lower() == "windows" else OSFamily.LINUX),
|
|
)
|
|
async with LocalConnector(host) as conn:
|
|
# Pick a command that exists on both Windows and POSIX.
|
|
cmd = "Get-Date" if platform.system().lower() == "windows" else "echo hello"
|
|
result = await conn.run(cmd, timeout=10)
|
|
assert result.exit_code == 0
|
|
assert result.stdout.strip() != ""
|