File size: 1,926 Bytes
1da7ac7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | # 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
|