Files
giant/tests/test_dwarf.py
T
lars d5853d5a75 Unify dataset/tooling scripts into a single dwarf Typer CLI
Replace the five separately-hyphenated uv entry points (steps-to-parquet,
steps-to-parquet-parallel, migrate-geant-steps, bump-dataset-version,
create-root-files) plus the unregistered hparam_scan.py with one `dwarf`
command exposing convert/migrate/bump-gen/bump-schema/status/
update-manifest/create-manifest/make-root/hparam-scan as subcommands.

Each scripts/*.py module now only holds argparse-free business logic;
scripts/dwarf.py wires it up with Typer, matching giant/cli.py's style.
`dwarf convert` merges the old serial/parallel conversion scripts behind
a --jobs flag (default 1: sequential with plain -o; >1: dataset-layout
fan-out via subprocess).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-02 09:52:37 +02:00

69 lines
2.2 KiB
Python

from typer.testing import CliRunner
from scripts.dwarf import app
runner = CliRunner()
def test_convert_rejects_jobs_below_one(tmp_path):
root_file = tmp_path / "shard.root"
root_file.touch()
result = runner.invoke(app, ["convert", str(root_file), "--jobs", "0"])
assert result.exit_code != 0
assert "--jobs must be >= 1" in result.output
def test_convert_rejects_output_with_multiple_files(tmp_path):
a = tmp_path / "a.root"
b = tmp_path / "b.root"
a.touch()
b.touch()
result = runner.invoke(app, ["convert", str(a), str(b), "--output", "out.parquet"])
assert result.exit_code != 0
assert "--output can only be used with a single input file" in result.output
def test_convert_rejects_output_with_parallel_jobs(tmp_path):
root_file = tmp_path / "shard.root"
root_file.touch()
result = runner.invoke(
app, ["convert", str(root_file), "--output", "out.parquet", "--jobs", "2"]
)
assert result.exit_code != 0
assert "--output cannot be combined with --jobs > 1" in result.output
def test_convert_default_jobs_is_one():
result = runner.invoke(app, ["convert", "--help"])
assert result.exit_code == 0
assert "default: 1" in result.output
def test_bump_gen_requires_reason():
result = runner.invoke(app, ["bump-gen"])
assert result.exit_code != 0
assert "reason" in result.output.lower()
def test_create_manifest_requires_exactly_one_of_output_or_pool(tmp_path):
f = tmp_path / "a.parquet"
f.touch()
result = runner.invoke(app, ["create-manifest", str(f)])
assert result.exit_code != 0
assert "exactly one of --output or --pool is required" in result.output
def test_create_manifest_requires_type_with_pool(tmp_path):
f = tmp_path / "a.parquet"
f.touch()
result = runner.invoke(app, ["create-manifest", "--pool", "pbwo4", str(f)])
assert result.exit_code != 0
assert "--type is required when --pool is given" in result.output
def test_status_reports_missing_root(tmp_path):
missing = tmp_path / "does-not-exist"
result = runner.invoke(app, ["status", "--root", str(missing)])
assert result.exit_code != 0
assert "is not a directory" in result.output