Skip to content

The agent that grows with you

1.9 KB
Raw Blame
"""Single-owner /model argument parsing (hermes_cli.model_switch.parse_model_switch_args)."""


from hermes_cli.model_switch import (
    MODEL_SWITCH_ERR_ONCE_WITH_GLOBAL,
    MODEL_SWITCH_ERR_RESET_WITH_FLAGS,
    MODEL_SWITCH_ERROR_TEXT,
    parse_model_switch_args,
)


# ---------------------------------------------------------------------------
# parse_model_switch_args — the ONE parser
# ---------------------------------------------------------------------------


def test_provider_flag_and_scopes():
    req = parse_model_switch_args("sonnet --provider anthropic --global")
    assert req.target == "sonnet"
    assert req.explicit_provider == "anthropic"
    assert req.is_global is True
    assert req.scope == "global"
    assert req.errors == ()

    assert parse_model_switch_args("sonnet").scope == "default"
    assert parse_model_switch_args("sonnet --session").scope == "session"
    assert parse_model_switch_args("sonnet \u2013session").scope == "session"  # iOS/Telegram en-dash
    assert parse_model_switch_args("sonnet --once").scope == "once"
    assert parse_model_switch_args("--refresh").force_refresh is True


def test_once_with_global_conflict():
    req = parse_model_switch_args("sonnet --once --global")
    assert MODEL_SWITCH_ERR_ONCE_WITH_GLOBAL in req.errors
    assert MODEL_SWITCH_ERROR_TEXT[MODEL_SWITCH_ERR_ONCE_WITH_GLOBAL] in req.error_messages()


def test_reset_is_its_own_request_and_takes_no_flags():
    assert parse_model_switch_args("  Reset ").is_reset
    for raw in ("reset --global", "reset --once", "reset --provider nous", "reset --reasoning high"):
        req = parse_model_switch_args(raw)
        assert req.errors == (MODEL_SWITCH_ERR_RESET_WITH_FLAGS,) and not req.is_reset, raw
    # "default" is MoA's preset name; a qualified slug reaches a model whose bare id is "reset".
    for raw in ("default", "my-reset", "vendor/reset", "vendor:reset"):
        assert not parse_model_switch_args(raw).is_reset, raw