Skip to content

Turn any AI agent into an AI Scientist. The #1 Agent Skills library for science, used by 250,000+ scientists worldwide. 177 ready-to-use validated skills plus 100+ scientific databases covering biology, chemistry, medicine, and drug discovery. Compatible with Cursor, Claude Code, Codex, Pi, Antigravity, and the open Agent Skills standard.

1.9 KB
Raw Blame
from pathlib import Path

import pytest

import autoskill

import skill_contract


def test_dispatches_to_run_subcommand(monkeypatch):
    calls = {}

    def fake_run_main(argv):
        calls["run"] = argv
        return 0

    monkeypatch.setattr("run.main", fake_run_main)
    rc = autoskill.main(["run", "--start", "a", "--end", "b"])

    assert rc == 0
    assert calls["run"] == ["--start", "a", "--end", "b"]


def test_dispatches_to_doctor_subcommand(monkeypatch):
    calls = {}

    def fake_doctor_main(argv):
        calls["doctor"] = argv
        return 0

    monkeypatch.setattr("doctor.main", fake_doctor_main)
    rc = autoskill.main(["doctor", "--config", "x", "--skills-dir", "y"])

    assert rc == 0
    assert calls["doctor"] == ["--config", "x", "--skills-dir", "y"]


def test_dispatches_to_promote_subcommand(monkeypatch):
    calls = {}

    def fake_promote_main(argv):
        calls["promote"] = argv
        return 0

    monkeypatch.setattr("promote.main", fake_promote_main)
    rc = autoskill.main(["promote", "--proposed", "p", "--skills-dir", "s", "--name", "n"])

    assert rc == 0
    assert calls["promote"] == ["--proposed", "p", "--skills-dir", "s", "--name", "n"]


def test_propagates_nonzero_exit_code(monkeypatch):
    monkeypatch.setattr("run.main", lambda argv: 7)
    rc = autoskill.main(["run", "--start", "a", "--end", "b"])
    assert rc == 7


def test_missing_subcommand_errors_out():
    with pytest.raises(SystemExit):
        autoskill.main([])


def test_unknown_subcommand_errors_out():
    with pytest.raises(SystemExit):
        autoskill.main(["nope"])

# The shared --help contract: every argparse CLI this skill ships answers --help
# without doing any work. It skips when the skill's packages are absent and runs
# for real under `python tests/run_all.py --isolated`.
CliHelpTests = skill_contract.cli.help_test_case(Path(__file__).resolve().parents[2] / "skills" / "autoskill")