import pytest

from tools.ingest_cli import main


def test_help_parses():
    with pytest.raises(SystemExit) as e:
        main(["--help"])
    assert e.value.code == 0


def test_unknown_archive_errors_cleanly(capsys):
    rc = main(["bogus", "--query", "x"])
    assert rc == 2
    assert "unknown archive" in capsys.readouterr().err


def test_missing_query_and_resolve_errors():
    assert main(["nasa"]) == 2


def test_deferred_archive_reports_not_implemented(capsys):
    rc = main(["musopen", "--query", "bach"])
    assert rc == 3
    assert "deferred" in capsys.readouterr().err
