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.

1.4 KB
Raw Blame
"""Unit tests for ``utilities.js_rendering.read_js_rendering_setting``.

The helper is the single read point for ``web.enable_javascript_rendering``
shared by the agent fetch tool, the ``FullSearchResults`` web-search
"include full content" path, and the MCP strategy's download tool.
"""

from local_deep_research.utilities.js_rendering import (
    read_js_rendering_setting,
)


def _snapshot(value):
    return {
        "web.enable_javascript_rendering": {
            "value": value,
            "ui_element": "checkbox",
        }
    }


def test_default_off_when_no_snapshot_no_context():
    assert read_js_rendering_setting(None) is False


def test_returns_true_when_snapshot_enables():
    assert read_js_rendering_setting(_snapshot(True)) is True


def test_returns_false_when_snapshot_disables():
    assert read_js_rendering_setting(_snapshot(False)) is False


def test_coerces_string_true_to_bool():
    """Snapshots loaded from the DB sometimes carry string-typed values."""
    assert read_js_rendering_setting(_snapshot("true")) is True


def test_coerces_string_false_to_bool():
    assert read_js_rendering_setting(_snapshot("false")) is False


def test_returns_concrete_bool_not_truthy_value():
    """``bool(...)`` coercion pins the return type — never returns Any."""
    result = read_js_rendering_setting(_snapshot(True))
    assert result is True or result is False  # not just truthy
    assert isinstance(result, bool)