~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.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
ok so it's a compromise between unit testing and integration testing with the fake case, but the core functionality is still being tested. revisit later.
ScottVR762a56045f30
diff --git a/tests/conftest.py b/tests/conftest.pyindex 377b07bbdb..864e8f8f70 100644--- a/tests/conftest.py+++ b/tests/conftest.py@@ -9,6 +9,9 @@ import src.local_deep_research.utilities.db_utils as db_utils_modulefrom src.local_deep_research.web.database.models import Basefrom src.local_deep_research.web.services.settings_manager import SettingsManager+# Remove the custom session_mocker_fixture definition.+# Pytest-mock should provide 'session_mocker' directly.+@pytest.fixture(scope="session", autouse=True)def setup_database_for_all_tests(@@ -88,11 +91,11 @@ def setup_database_for_all_tests(if engine:engine.dispose() # Dispose the engine to close all connections- # tmp_path_factory handles deleting the temporary directory and its contents+ # tmp_path_factory handles deleting the temporary directory and its@pytest.fixture-def mock_db_session(mocker):+def mock_db_session(mocker): # This will still use the default function-scoped mockerreturn mocker.MagicMock()diff --git a/tests/test_settings_manager.py b/tests/test_settings_manager.pyindex d0ca6b13ff..2305fc20db 100644--- a/tests/test_settings_manager.py+++ b/tests/test_settings_manager.py@@ -10,6 +10,9 @@ from src.local_deep_research.web.services.settings_manager import (SettingType,check_env_setting,)+from src.local_deep_research.web.services.settings_service import (+ get_setting as get_app_setting,+)def test_check_env_setting_exists(monkeypatch):@@ -209,6 +212,114 @@ def test_set_setting_db_error(mocker):# mock_logger.error.assert_called_once_with("Error setting value for app.version: Simulated DB Error")+def test_app_get_setting_from_real_db(setup_database_for_all_tests, monkeypatch):+ """+ Tests get_setting via settings_service, using the real file-based database.+ `setup_database_for_all_tests` yields `SessionLocal`, which is a sessionmaker.+ """+ SessionLocal = (+ setup_database_for_all_tests # Get the SessionLocal class from the fixture+ )+ session = SessionLocal() # Create a new session instance for this test++ # Add a setting to the database using this session+ # Changed key to be specific to this test+ setting = Setting(+ key="test.app.version.get", # Use a unique key for this test+ value="1.0.0",+ type=SettingType.APP,+ name="Version",+ description="App version",+ ui_element="text",+ visible=True,+ editable=True,+ )+ session.add(setting)+ session.commit()++ monkeypatch.delenv("LDR_APP_VERSION", raising=False) # Ensure no env override++ # Call the get_setting function from settings_service+ value = get_app_setting("test.app.version.get", db_session=session)+ assert value == "1.0.0"++ session.close() # Close the session for this test+++def test_get_all_settings_from_real_file_db(setup_database_for_all_tests, monkeypatch):+ """+ Tests retrieving all settings from a real *file-based* database.+ """+ # Create a new session for this test+ session = (+ setup_database_for_all_tests()+ ) # Call the sessionmaker to get a new session++ # Add some settings to the database+ setting1 = Setting(+ key="all.settings.app.version",+ value="1.0.0",+ type=SettingType.APP,+ name="Version",+ description="App version",+ ui_element="text",+ visible=True,+ editable=True,+ )+ setting2 = Setting(+ key="all.settings.llm.temperature",+ value=0.7,+ type=SettingType.LLM,+ name="Temperature",+ description="LLM temperature",+ ui_element="number",+ visible=True,+ editable=True,+ )+ session.add_all([setting1, setting2])+ session.commit() # Commit to save them to the database++ # Ensure no conflicting environment variables are set for this test+ monkeypatch.delenv("LDR_APP_VERSION", raising=False)+ monkeypatch.delenv("LDR_LLM_TEMPERATURE", raising=False)++ settings_manager = SettingsManager(db_session=session) # Pass the session instance+ all_settings = settings_manager.get_all_settings()++ # Assertions should check for the unique keys+ assert "all.settings.app.version" in all_settings+ assert all_settings["all.settings.app.version"]["value"] == "1.0.0"+ assert all_settings["all.settings.app.version"]["type"] == "APP"+ assert all_settings["all.settings.app.version"]["editable"] is True+ assert all_settings["all.settings.app.version"]["name"] == "Version"++ assert "all.settings.llm.temperature" in all_settings+ assert all_settings["all.settings.llm.temperature"]["value"] == 0.7+ assert all_settings["all.settings.llm.temperature"]["type"] == "LLM"+ assert all_settings["all.settings.llm.temperature"]["editable"] is True+ assert all_settings["all.settings.llm.temperature"]["name"] == "Temperature"++ # IMPORTANT: Close the session created within the test+ session.close()+++def test_get_all_settings_db_error(mock_db_session, mock_logger):+ """Tests handling a SQLAlchemyError when retrieving all settings."""+ # Configure the mock session to raise a SQLAlchemyError+ mock_db_session.query(Setting).all.side_effect = SQLAlchemyError(+ "Simulated DB Error"+ )++ settings_manager = SettingsManager(db_session=mock_db_session)+ all_settings = settings_manager.get_all_settings()++ # Assert that an empty dictionary is returned and the error was logged+ assert all_settings == {}+ mock_db_session.query(Setting).all.assert_called_once()+ mock_logger.error.assert_called_once()+ # You can check the log message content if needed++def test_get_setting_with_substring_keys(setup_database_for_all_tests):"""Tests that we can get the correct value for a setting, even when its key