"""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_parses_to_dict_falls_to_comma_split(self): """JSON that parses to a dict (not list) falls through to comma split.""" result = _parse_multiselect('{"a": 1}') # JSON parses OK but isinstance(parsed, list) is False # Falls through to comma-separated split assert isinstance(result, list) assert result == ['{"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 == []