"""Tests for CLI parsing and streaming profile execution.""" from __future__ import annotations import json from pathlib import Path from swe_data_processing.cli import _run_streaming_stage, build_parser def test_streaming_stage_writes_each_record(tmp_path: Path) -> None: input_path = tmp_path / "input.jsonl" output_path = tmp_path / "output.jsonl" input_path.write_text( "".join(json.dumps({"trajectory_id": f"s-{i}"}) + "\n" for i in range(10)), encoding="utf-8", ) status = _run_streaming_stage( input_path=input_path, output_path=output_path, errors_path=None, limit=None, resume=False, workers=3, processor=lambda record: {"sample_id": record["trajectory_id"]}, ) assert status == 0 assert len(output_path.read_text().splitlines()) == 10 def test_cli_has_only_deterministic_pipeline_commands() -> None: parser = build_parser() assert parser.parse_args( ["profile", "--input", "in.jsonl", "--output", "out.jsonl"] ).command == "profile" help_text = parser.format_help() assert "classify" not in help_text assert "repair" not in help_text