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
1 change: 1 addition & 0 deletions sdk/src/openagents/client/cli_identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import requests
import typer
from rich.panel import Panel
from rich.progress import Progress, SpinnerColumn, TextColumn
from rich.table import Table
from rich import box

Expand Down
47 changes: 47 additions & 0 deletions tests/agentid/test_cli_identity_imports.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"""Regression tests for the ``agentid`` CLI commands in cli_identity.py.

The ``agentid`` subcommands (verify / info / resolve / verify-token /
challenge / token / auth / claim) use ``Progress``, ``SpinnerColumn`` and
``TextColumn`` from ``rich.progress`` inside a ``with Progress(...)`` block.
Those names were never imported in ``cli_identity.py``, so every one of those
commands crashed with ``NameError: name 'Progress' is not defined`` the moment
it reached the progress block — before any network call.
Comment on lines +3 to +8

These tests stub out the network layer so no real request is made and assert
that the command does not raise a ``NameError``.
"""

import openagents.agentid as agentid
import openagents.client.cli_identity # noqa: F401 -- registers agentid_app onto app
from openagents.agentid.exceptions import AgentIDConnectionError
from openagents.client.cli_shared import app
from typer.testing import CliRunner

runner = CliRunner()


def test_agentid_verify_does_not_raise_nameerror(monkeypatch):
"""``agentid verify`` must reach the network layer without a NameError.

The verifier is stubbed to raise a connection error, so the command takes
its handled error path (exit code 1) instead of crashing with
``NameError: name 'Progress' is not defined``.
"""

class _OfflineVerifier:
def __init__(self, *args, **kwargs):
pass

def validate(self, agent_id):
raise AgentIDConnectionError("offline (test stub)")

monkeypatch.setattr(agentid, "AgentIDVerifier", _OfflineVerifier)

result = runner.invoke(app, ["agentid", "verify", "openagents:test-agent"])

assert not isinstance(result.exception, NameError), (
f"agentid verify raised NameError: {result.exception}"
)
Comment on lines +42 to +44
assert "NameError" not in result.output
# Handled connection error -> typer.Exit(1)
assert result.exit_code == 1
Loading