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.5 KB
Raw Blame
"""High-value tests for settings/env_definitions/bootstrap.py.

Tests the supported bootstrap encryption policy setting.
"""

from local_deep_research.settings.env_definitions.bootstrap import (
    BOOTSTRAP_SETTINGS,
)
from local_deep_research.settings.env_settings import (
    BooleanSetting,
    SettingsRegistry,
)


def _find(key: str):
    """Return the setting object with the given key."""
    for s in BOOTSTRAP_SETTINGS:
        if s.key == key:
            return s
    raise KeyError(f"Setting {key!r} not found in BOOTSTRAP_SETTINGS")


class TestBootstrapRegistry:
    """Tests for BOOTSTRAP_SETTINGS structure."""

    def test_setting_count(self):
        """BOOTSTRAP_SETTINGS has the expected number of entries."""
        assert len(BOOTSTRAP_SETTINGS) == 1

    def test_all_keys_start_with_bootstrap(self):
        """Every key uses the 'bootstrap.' prefix."""
        for s in BOOTSTRAP_SETTINGS:
            assert s.key.startswith("bootstrap."), f"{s.key} missing prefix"

    def test_register_all_settings(self):
        """All settings can be registered under the bootstrap category."""
        registry = SettingsRegistry()
        registry.register_category("bootstrap", BOOTSTRAP_SETTINGS)
        for s in BOOTSTRAP_SETTINGS:
            assert registry.is_env_only(s.key)


class TestAllowUnencrypted:
    """Tests for bootstrap.allow_unencrypted."""

    def test_is_boolean_setting(self):
        s = _find("bootstrap.allow_unencrypted")
        assert isinstance(s, BooleanSetting)

    def test_default_is_false(self, monkeypatch):
        """Default value is False (require encryption)."""
        s = _find("bootstrap.allow_unencrypted")
        monkeypatch.delenv(s.env_var, raising=False)
        if s.deprecated_env_var:
            monkeypatch.delenv(s.deprecated_env_var, raising=False)
        assert s.get_value() is False

    def test_deprecated_alias(self):
        """Has deprecated env var LDR_ALLOW_UNENCRYPTED."""
        s = _find("bootstrap.allow_unencrypted")
        assert s.deprecated_env_var == "LDR_ALLOW_UNENCRYPTED"

    def test_set_to_true(self, monkeypatch):
        """Can be set to True via env var."""
        s = _find("bootstrap.allow_unencrypted")
        monkeypatch.setenv(s.env_var, "true")
        assert s.get_value() is True

    def test_set_to_false(self, monkeypatch):
        """Can be set to False via env var."""
        s = _find("bootstrap.allow_unencrypted")
        monkeypatch.setenv(s.env_var, "false")
        assert s.get_value() is False