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.

4.0 KB
Raw Blame
"""Tests for theme registry."""


class TestThemeRegistry:
    def test_singleton_instance(self):
        from local_deep_research.web.themes import ThemeRegistry

        r1 = ThemeRegistry()
        r2 = ThemeRegistry()
        assert r1 is r2

    def test_themes_property(self):
        from local_deep_research.web.themes import theme_registry

        themes = theme_registry.themes
        assert isinstance(themes, dict)
        assert len(themes) > 0

    def test_get_theme_ids(self):
        from local_deep_research.web.themes import theme_registry

        ids = theme_registry.get_theme_ids()
        assert isinstance(ids, list)
        assert len(ids) > 0
        # Should be sorted
        assert ids == sorted(ids)

    def test_get_theme(self):
        from local_deep_research.web.themes import theme_registry

        ids = theme_registry.get_theme_ids()
        if ids:
            theme = theme_registry.get_theme(ids[0])
            assert theme is not None
            assert theme.id == ids[0]

    def test_get_theme_nonexistent(self):
        from local_deep_research.web.themes import theme_registry

        theme = theme_registry.get_theme("nonexistent_theme_xyz")
        assert theme is None

    def test_get_themes_by_group(self):
        from local_deep_research.web.themes import theme_registry

        grouped = theme_registry.get_themes_by_group()
        assert isinstance(grouped, dict)

    def test_get_combined_css(self):
        from local_deep_research.web.themes import theme_registry

        css = theme_registry.get_combined_css()
        assert isinstance(css, str)
        assert len(css) > 0
        assert "Auto-generated" in css

    def test_get_themes_json(self):
        from local_deep_research.web.themes import theme_registry

        json_str = theme_registry.get_themes_json()
        assert isinstance(str(json_str), str)
        # Should be valid JSON array
        import json

        parsed = json.loads(str(json_str))
        assert isinstance(parsed, list)

    def test_get_metadata_json(self):
        from local_deep_research.web.themes import theme_registry

        json_str = theme_registry.get_metadata_json()
        assert isinstance(str(json_str), str)
        import json

        parsed = json.loads(str(json_str))
        assert isinstance(parsed, dict)

    def test_get_settings_options(self):
        from local_deep_research.web.themes import theme_registry

        options = theme_registry.get_settings_options()
        assert isinstance(options, list)
        for option in options:
            assert "label" in option
            assert "value" in option

    def test_get_grouped_settings_options(self):
        from local_deep_research.web.themes import theme_registry

        options = theme_registry.get_grouped_settings_options()
        assert isinstance(options, list)
        for option in options:
            assert "label" in option
            assert "value" in option
            assert "group" in option

    def test_is_valid_theme(self):
        from local_deep_research.web.themes import theme_registry

        ids = theme_registry.get_theme_ids()
        if ids:
            assert theme_registry.is_valid_theme(ids[0]) is True
        assert theme_registry.is_valid_theme("nonexistent_xyz") is False

    def test_clear_cache(self):
        from local_deep_research.web.themes import theme_registry

        # Should not raise
        theme_registry.clear_cache()


class TestModuleFunctions:
    def test_get_themes_function(self):
        from local_deep_research.web.themes import get_themes

        themes = get_themes()
        assert isinstance(themes, list)

    def test_get_themes_json_function(self):
        from local_deep_research.web.themes import get_themes_json

        json_str = get_themes_json()
        assert isinstance(str(json_str), str)

    def test_get_theme_metadata_function(self):
        from local_deep_research.web.themes import get_theme_metadata

        metadata = get_theme_metadata()
        assert isinstance(str(metadata), str)