"""Tests for _filter_setting_columns() in settings/manager.py.

This function has zero test coverage. It filters a dict to only keys
that match columns on the Setting model, preventing crashes when
default_settings.json contains unknown keys.
"""

from local_deep_research.settings.manager import _filter_setting_columns


class TestFilterSettingColumns:
    """Tests for _filter_setting_columns()."""

    def test_valid_key_passes_through(self):
        """Known Setting column names should be preserved."""
        result = _filter_setting_columns({"key": "test_key"})
        assert "key" in result
        assert result["key"] == "test_key"

    def test_invalid_key_filtered_out(self):
        """Keys not matching any Setting column should be removed."""
        result = _filter_setting_columns(
            {"key": "test_key", "nonexistent_xyz_column": "val"}
        )
        assert "key" in result
        assert "nonexistent_xyz_column" not in result

    def test_empty_dict(self):
        result = _filter_setting_columns({})
        assert result == {}

    def test_all_invalid_keys(self):
        result = _filter_setting_columns({"bogus_a": 1, "bogus_b": 2})
        assert result == {}

    def test_none_value_preserved(self):
        """Filtering is by key name, not value — None values should pass."""
        result = _filter_setting_columns({"key": None})
        assert "key" in result
        assert result["key"] is None
