Files
OpenJarvis/tests/cli/test_cli.py
T
Jon Saad-FalconandClaude Opus 4.6 301e9cd2d4 Implement OpenJarvis v1.0 — all five pillars, SDK, benchmarks, Docker
Complete implementation across six development phases (v0.1 through v1.0):

- Core: Registry system, config, event bus, types (Phase 0)
- Intelligence + Inference: Model routing, Ollama/vLLM/llama.cpp/Cloud engines (Phase 1)
- Memory: SQLite/FAISS/ColBERT/BM25/Hybrid backends, document ingest, context injection (Phase 2)
- Agents: Simple/Orchestrator/Custom/OpenClaw agents, tool system (Phase 3)
- Learning: HeuristicRouter, reward functions, GRPO stub, telemetry aggregation (Phase 4)
- SDK: Jarvis class, OpenClaw protocol/transport, benchmarks, Docker deployment (Phase 5)

520 tests passing, 8 skipped (optional deps). Ruff lint clean.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 00:52:48 +00:00

82 lines
2.7 KiB
Python

"""Tests for the CLI skeleton."""
from __future__ import annotations
from pathlib import Path
from unittest import mock
from click.testing import CliRunner
from openjarvis.cli import cli
class TestCLI:
def test_help(self) -> None:
result = CliRunner().invoke(cli, ["--help"])
assert result.exit_code == 0
assert "OpenJarvis" in result.output
def test_version(self) -> None:
result = CliRunner().invoke(cli, ["--version"])
assert result.exit_code == 0
assert "1.0.0" in result.output
def test_ask_requires_query(self) -> None:
result = CliRunner().invoke(cli, ["ask"])
assert result.exit_code != 0
def test_serve_needs_engine(self) -> None:
"""Serve requires a running engine; exits with error when none available."""
result = CliRunner().invoke(cli, ["serve"])
# Either exits with error (no engine) or succeeds (deps missing)
# Both are valid states for testing
out = result.output.lower()
assert (
result.exit_code != 0
or "not installed" in out
or "no inference" in out
)
def test_model_subcommands_exist(self) -> None:
result = CliRunner().invoke(cli, ["model", "--help"])
assert result.exit_code == 0
assert "list" in result.output
assert "info" in result.output
assert "pull" in result.output
def test_memory_subcommands_exist(self) -> None:
result = CliRunner().invoke(cli, ["memory", "--help"])
assert result.exit_code == 0
assert "index" in result.output
assert "search" in result.output
assert "stats" in result.output
def test_telemetry_subcommands_exist(self) -> None:
result = CliRunner().invoke(cli, ["telemetry", "--help"])
assert result.exit_code == 0
assert "stats" in result.output
assert "export" in result.output
assert "clear" in result.output
def test_bench_subcommands_exist(self) -> None:
result = CliRunner().invoke(cli, ["bench", "--help"])
assert result.exit_code == 0
assert "run" in result.output
def test_init_creates_config(self, tmp_path: Path) -> None:
config_dir = tmp_path / ".openjarvis"
config_path = config_dir / "config.toml"
with (
mock.patch(
"openjarvis.cli.init_cmd.DEFAULT_CONFIG_DIR", config_dir
),
mock.patch(
"openjarvis.cli.init_cmd.DEFAULT_CONFIG_PATH", config_path
),
):
result = CliRunner().invoke(cli, ["init"])
assert result.exit_code == 0
assert config_path.exists()
content = config_path.read_text()
assert "[engine]" in content