2026-06-03 08:12:38 +03:00
|
|
|
import json
|
|
|
|
|
from types import SimpleNamespace
|
|
|
|
|
|
2026-06-05 06:00:05 +01:00
|
|
|
from tests.helpers.cli_loader import load_script
|
2026-06-03 08:12:38 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def _load_cli():
|
2026-06-05 06:00:05 +01:00
|
|
|
return load_script("odysseus-research")
|
2026-06-03 08:12:38 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_list_skips_non_object_research_records(tmp_path, monkeypatch):
|
|
|
|
|
cli = _load_cli()
|
|
|
|
|
cli._DATA_DIR = tmp_path
|
|
|
|
|
(tmp_path / "good.json").write_text(json.dumps({"query": "hello", "status": "complete"}))
|
|
|
|
|
(tmp_path / "list.json").write_text("[]")
|
|
|
|
|
(tmp_path / "broken.json").write_text("{")
|
|
|
|
|
|
|
|
|
|
emitted = []
|
|
|
|
|
monkeypatch.setattr(cli, "emit", lambda value, args: emitted.append(value))
|
|
|
|
|
|
|
|
|
|
cli.cmd_list(SimpleNamespace(status=None, limit=50))
|
|
|
|
|
|
|
|
|
|
assert emitted == [[{
|
|
|
|
|
"id": "good",
|
|
|
|
|
"query": "hello",
|
|
|
|
|
"category": "",
|
|
|
|
|
"status": "complete",
|
|
|
|
|
"started_at": "",
|
|
|
|
|
"completed_at": "",
|
|
|
|
|
"sources": 0,
|
|
|
|
|
"stats": {},
|
|
|
|
|
}]]
|