Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions agentic_internet/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def orchestrate(

@app.command()
def tools(
list_tools: bool = typer.Option(True, "--list", "-l", help="List available tools"),
list_tools: bool = typer.Option(True, "--list/--no-list", "-l", help="List available tools"),
multi_model: bool = typer.Option(False, "--multi", "-m", help="Show multi-model tools"),
use_cases: bool = typer.Option(False, "--use-cases", help="Show multi-model use-case recipes"),
):
Expand Down Expand Up @@ -461,7 +461,7 @@ def news(

@app.command()
def models(
list_all: bool = typer.Option(True, "--list", "-l", help="List all available models"),
list_all: bool = typer.Option(True, "--list/--no-list", "-l", help="List all available models"),
category: str | None = typer.Option(
None, "--category", "-c", help="Filter by category: general, news, research, code"
),
Expand Down
97 changes: 97 additions & 0 deletions tests/test_cli_listing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
"""CLI tests for the `models` and `tools` listing flags."""

from types import SimpleNamespace

import pytest
from typer.testing import CliRunner

from agentic_internet import cli

runner = CliRunner()


class FakeInternetAgent:
"""Stand-in for InternetAgent so `tools` needs no model, API keys, or network."""

def __init__(self, **kwargs):
self.kwargs = kwargs
self.tools = [
SimpleNamespace(name="fake_web_search", description="Fake search tool for tests"),
SimpleNamespace(name="fake_scraper", description="Fake scraper tool for tests"),
]


@pytest.fixture
def fake_internet_agent(monkeypatch):
monkeypatch.setattr(cli, "InternetAgent", FakeInternetAgent)


@pytest.mark.parametrize("args", [["models"], ["models", "--list"], ["models", "-l"]])
def test_models_lists_static_catalog_by_default_and_with_list_flag(args):
result = runner.invoke(cli.app, args)

assert result.exit_code == 0, result.output
assert "Available AI Models" in result.output
assert "claude-opus-4.8" in result.output
assert "qwen3-coder" in result.output


def test_models_list_category_filters_static_catalog():
result = runner.invoke(cli.app, ["models", "--list", "--category", "news"])

assert result.exit_code == 0, result.output
assert "sonar-pro" in result.output
assert "qwen3-coder" not in result.output


def test_models_list_details_adds_description_column():
result = runner.invoke(cli.app, ["models", "--list", "--details", "--category", "code"])

assert result.exit_code == 0, result.output
assert "Description" in result.output
assert "qwen3-coder" in result.output


def test_models_no_list_skips_catalog():
result = runner.invoke(cli.app, ["models", "--no-list"])

assert result.exit_code == 0, result.output
assert "Available AI Models" not in result.output


def test_models_live_falls_back_to_static_catalog_without_network(monkeypatch):
monkeypatch.setattr(cli, "fetch_openrouter_models", lambda: [])

result = runner.invoke(cli.app, ["models", "--live", "--list"])

assert result.exit_code == 0, result.output
assert "Could not fetch live OpenRouter models" in result.output
assert "claude-opus-4.8" in result.output


@pytest.mark.parametrize("args", [["tools"], ["tools", "--list"], ["tools", "-l"]])
def test_tools_lists_agent_tools_by_default_and_with_list_flag(fake_internet_agent, args):
result = runner.invoke(cli.app, args)

assert result.exit_code == 0, result.output
assert "Available Tools" in result.output
assert "fake_web_search" in result.output
assert "fake_scraper" in result.output


@pytest.mark.parametrize("args", [["tools", "--multi"], ["tools", "--list", "--multi"], ["tools", "-l", "-m"]])
def test_tools_multi_lists_serpapi_tools(fake_internet_agent, args):
result = runner.invoke(cli.app, args)

assert result.exit_code == 0, result.output
assert "Multi-Model SerpAPI Tools" in result.output
assert "GoogleSearchTool" in result.output
assert "fake_web_search" not in result.output


def test_tools_list_with_use_cases_still_shows_use_cases(fake_internet_agent):
result = runner.invoke(cli.app, ["tools", "--list", "--use-cases"])

assert result.exit_code == 0, result.output
assert "technical_due_diligence" in result.output
assert "fake_web_search" not in result.output
Loading