"""Tests for hybrid search."""

from unittest.mock import patch

from ars25.search.hybrid import search, SECTION_PATTERN


def test_section_pattern_valid():
    assert SECTION_PATTERN.match("25-403")
    assert SECTION_PATTERN.match("25-403.01")
    assert SECTION_PATTERN.match("25-101")


def test_section_pattern_invalid():
    assert not SECTION_PATTERN.match("26-100")
    assert not SECTION_PATTERN.match("25-")
    assert not SECTION_PATTERN.match("abc")
    assert not SECTION_PATTERN.match("25-403; DROP TABLE")


def test_search_returns_empty_when_no_db():
    with patch("ars25.search.hybrid.table_exists", return_value=False):
        results = search("child custody")
        assert results == []
