Skip to content
Merged
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
3 changes: 2 additions & 1 deletion src/tenantq/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import json
from typing import List, Optional

import click
import typer

from .benchmark import BenchmarkResult, run_benchmark
Expand Down Expand Up @@ -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"),
Expand Down
20 changes: 20 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -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
Loading