43 lines
1.1 KiB
Python
43 lines
1.1 KiB
Python
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
from corpus_mcp.cli import main
|
|
from corpus_mcp.database import read_corpus_info
|
|
|
|
|
|
def test_index_command_accepts_description_file(tmp_path: Path, capsys) -> None:
|
|
source = tmp_path / "source"
|
|
source.mkdir()
|
|
(source / "document.txt").write_text("searchable", encoding="utf-8")
|
|
description = tmp_path / "description.txt"
|
|
description.write_text("CLI corpus", encoding="utf-8")
|
|
database = tmp_path / "corpus.sqlite"
|
|
|
|
result = main(
|
|
[
|
|
"index",
|
|
str(source),
|
|
"--database",
|
|
str(database),
|
|
"--description-file",
|
|
str(description),
|
|
]
|
|
)
|
|
|
|
assert result == 0
|
|
assert "Indexed 1 documents" in capsys.readouterr().out
|
|
assert read_corpus_info(database)["description"] == "CLI corpus"
|
|
|
|
|
|
def test_module_help_smoke_test() -> None:
|
|
result = subprocess.run(
|
|
[sys.executable, "-m", "corpus_mcp", "--help"],
|
|
check=False,
|
|
capture_output=True,
|
|
text=True,
|
|
)
|
|
|
|
assert result.returncode == 0
|
|
assert "corpus-mcp" in result.stdout
|