"""Tests for HooksConfig with named tokens."""

from nanobot.config.schema import HooksConfig


def test_hooks_config_named_tokens():
    """Named tokens dict should work."""
    config = HooksConfig(enabled=True, tokens={"gitea": "secret1", "ha": "secret2"})
    assert config.tokens == {"gitea": "secret1", "ha": "secret2"}


def test_hooks_config_resolve_token():
    """resolve_token should return token name for a matching token."""
    config = HooksConfig(enabled=True, tokens={"gitea": "secret1", "ha": "secret2"})
    assert config.resolve_token("secret1") == "gitea"
    assert config.resolve_token("secret2") == "ha"
    assert config.resolve_token("unknown") is None


def test_hooks_config_has_tokens():
    """has_tokens should be True if tokens dict is non-empty."""
    assert HooksConfig(enabled=True, tokens={"webhook": "secret"}).has_tokens
    assert not HooksConfig(enabled=True).has_tokens
    assert not HooksConfig(enabled=True, tokens={}).has_tokens
