diff --git a/src/tenantq/cli.py b/src/tenantq/cli.py index 783b347..6798001 100644 --- a/src/tenantq/cli.py +++ b/src/tenantq/cli.py @@ -5,6 +5,7 @@ import json from typing import List, Optional +import click import typer from .benchmark import BenchmarkResult, run_benchmark @@ -112,7 +113,7 @@ def benchmark( def search( query: str, tenant: str = typer.Option(..., help="Tenant id to scope the search."), - mode: str = typer.Option("hybrid"), + mode: str = typer.Option("hybrid", click_type=click.Choice(["dense", "sparse", "hybrid"])), limit: int = typer.Option(5), category: Optional[str] = typer.Option(None), embedder: str = typer.Option("fastembed"), diff --git a/tests/test_cli.py b/tests/test_cli.py new file mode 100644 index 0000000..01cb8e8 --- /dev/null +++ b/tests/test_cli.py @@ -0,0 +1,20 @@ +"""CLI behaviour: option validation surfaces clean usage errors.""" + +from __future__ import annotations + +import pytest +from typer.testing import CliRunner + +from tenantq.cli import app + +runner = CliRunner() + + +@pytest.mark.parametrize("bad_mode", ["hybird", "HYBRID", "dense "]) +def test_search_rejects_unknown_mode(bad_mode): + result = runner.invoke(app, ["search", "neural network", "--tenant", "acme", "--mode", bad_mode]) + assert result.exit_code != 0 + assert result.exception is not None + message = str(result.exception) + assert "hybrid" in message + assert "is not one of" in message