Self-hosted, Docker-based agentic troubleshooting platform: FastAPI backend + LangGraph agent, Next.js UI, tiered LLM routing (local Ollama -> Gemini -> DeepSeek -> OpenRouter), MCP server manager, encrypted device credentials, RBAC, audit log, project-memory + Obsidian integrations, and editable troubleshooting decision rules tuned for the GeneseasX vessel stack. Co-authored-by: Cursor <cursoragent@cursor.com>
61 lines
2.0 KiB
Python
61 lines
2.0 KiB
Python
"""Tests for Asterisk deployment profiles."""
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
|
|
os.environ.setdefault("SECRET_KEY", "test-secret-key-for-unit-tests-only")
|
|
|
|
from app.agent.asterisk_profiles import ( # noqa: E402
|
|
_docker_asterisk,
|
|
_ssh_connect,
|
|
)
|
|
from app.agent.playbooks import playbook_for # noqa: E402
|
|
from app.models.enums import DeviceType # noqa: E402
|
|
from app.services.vessel_devices import validate_selections # noqa: E402
|
|
from app.schemas import VesselDeviceSelection # noqa: E402
|
|
|
|
|
|
def test_geneseasx_ssh_connect_uses_voip_port_default():
|
|
os.environ["DEVICE_ASTERISK_GENESEASX_PORT"] = "6022"
|
|
args = _ssh_connect(
|
|
{"address": "10.0.0.1", "username": "root", "secret": "pw", "catalog_key": "asterisk_geneseasx"}
|
|
)
|
|
assert args["port"] == 6022
|
|
assert args["password"] == "pw"
|
|
|
|
|
|
def test_docker_asterisk_command_uses_voip_container():
|
|
cmd = _docker_asterisk("pjsip show registrations")(
|
|
{"asterisk_container": "voip", "catalog_key": "asterisk_geneseasx"}
|
|
)
|
|
assert "docker exec voip asterisk -rx" in cmd["command"]
|
|
assert "pjsip show registrations" in cmd["command"]
|
|
|
|
|
|
def test_playbook_geneseasx_uses_ssh_mcp():
|
|
pb = playbook_for(DeviceType.asterisk, None, "asterisk_geneseasx")
|
|
assert pb is not None
|
|
assert pb["mcp_server"] == "ssh-generic-mcp"
|
|
assert pb["connect"][0] == "ssh_connect"
|
|
|
|
|
|
def test_playbook_satbox_uses_ssh_mcp():
|
|
pb = playbook_for(DeviceType.asterisk, None, "asterisk_satbox")
|
|
assert pb is not None
|
|
assert pb["mcp_server"] == "ssh-generic-mcp"
|
|
assert pb["connect"][0] == "ssh_connect"
|
|
|
|
|
|
def test_only_one_asterisk_slot_per_vessel():
|
|
sels = [
|
|
VesselDeviceSelection(catalog_key="asterisk_geneseasx", enabled=True),
|
|
VesselDeviceSelection(catalog_key="asterisk_satbox", enabled=True),
|
|
]
|
|
try:
|
|
validate_selections(sels)
|
|
raised = False
|
|
except ValueError as exc:
|
|
raised = True
|
|
assert "one Asterisk" in str(exc)
|
|
assert raised
|