Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

2.1 KB
Raw Blame
"""Edge-case tests for _parse_number() and _parse_multiselect().

These cover branches missed by existing test_parse_multiselect.py and
test_manager_behavior.py: scientific notation, ValueError paths,
JSON-to-non-list parsing, and degenerate input strings.
"""

import pytest

from local_deep_research.settings.manager import (
    _parse_multiselect,
    _parse_number,
)


class TestParseNumberEdgeCases:
    """Edge cases for _parse_number()."""

    def test_scientific_notation_whole_returns_int(self):
        """1e2 = 100.0 which is_integer() → returns int(100)."""
        assert _parse_number("1e2") == 100
        assert isinstance(_parse_number("1e2"), int)

    def test_scientific_notation_whole_float_returns_int(self):
        """1.5e2 = 150.0 which is_integer() is True → returns int(150)."""
        result = _parse_number("1.5e2")
        # 150.0.is_integer() is True so this returns int
        assert result == 150
        assert isinstance(result, int)

    def test_negative_whole_returns_int(self):
        assert _parse_number("-5.0") == -5
        assert isinstance(_parse_number("-5.0"), int)

    def test_non_numeric_raises_valueerror(self):
        with pytest.raises(ValueError):
            _parse_number("abc")


class TestParseMultiselectEdgeCases:
    """Edge cases not covered by test_parse_multiselect.py."""

    def test_json_object_is_not_reinterpreted_as_comma_separated(self):
        """An object cannot replace the list a multiselect requires."""
        with pytest.raises(ValueError):
            _parse_multiselect('{"a": 1}')

    def test_only_commas_returns_empty_list(self):
        """String of only commas → all items strip to empty → filtered out."""
        result = _parse_multiselect(",,,")
        assert result == []

    def test_non_string_non_list_passthrough_none(self):
        """None should pass through unchanged."""
        assert _parse_multiselect(None) is None

    def test_whitespace_only_string(self):
        """Whitespace-only string: stripped → doesn't start with '[' → comma split → empty."""
        result = _parse_multiselect("   ")
        assert result == []