# tests/test_cli_v2.py from pathlib import Path from fractus_vorax.agent import cli CSV_CONTENT = ( "question,answer\n" "what is the capital of france,paris\n" "what is the capital of spain,madrid\n" "what is the capital of japan,tokyo\n" "what is the capital of italy,rome\n" "who wrote hamlet,william shakespeare\n" ) def _setup(tmp_path): p = tmp_path / "cap.csv" p.write_text(CSV_CONTENT, encoding="utf-8") brain = tmp_path / "brain" cli.ingest(p, brain, D=2048, seed=0, kn_cache=tmp_path / "kn") return p, brain def test_ingest_announces_expert(tmp_path, capsys): _setup(tmp_path) out = capsys.readouterr().out assert "expert 'cap' spawné" in out def test_ask_prints_fact_cards(tmp_path, capsys): _, brain = _setup(tmp_path) cli.main(["ask", "what is the capital of japan", "--brain", str(brain), "--k", "2"]) out = capsys.readouterr().out assert "[CARTE] FAIT:" in out and "tokyo" in out def test_ask_typo_prints_analogy_card(tmp_path, capsys): _, brain = _setup(tmp_path) cli.main(["ask", "what is the capital of franc", "--brain", str(brain), "--k", "2"]) out = capsys.readouterr().out assert "[CARTE] ANALOGIE:" in out and "paris" in out def test_status_lists_organs(tmp_path, capsys): _, brain = _setup(tmp_path) cli.main(["status", "--brain", str(brain)]) out = capsys.readouterr().out assert "organes:" in out and "expert" in out and "relation" in out def test_ingest_empty_csv_no_expert(tmp_path, capsys): """Un CSV réduit à son en-tête n'ingère rien et ne spawn aucun expert.""" p = tmp_path / "empty.csv" p.write_text("question,answer\n", encoding="utf-8") brain = tmp_path / "brain" n = cli.ingest(p, brain, D=2048, seed=0, kn_cache=tmp_path / "kn") out = capsys.readouterr().out assert n == 0 assert "aucun expert" in out assert "spawné" not in out