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.

fix: Address review comments from djpetti

LearningCircuitf4a57bf6bdc9
diff --git a/src/local_deep_research/config/paths.py b/src/local_deep_research/config/paths.py
index 592af0ad12..67e42a68e7 100644
--- a/src/local_deep_research/config/paths.py
+++ b/src/local_deep_research/config/paths.py
@@ -94,27 +94,6 @@ def get_logs_directory() -> Path:
return logs_dir
-def get_database_path() -> Path:
- """
- Get the path to the application database.
- DEPRECATED: This returns the shared database path which should not be used.
- Use per-user databases instead via encrypted_db.py
-
- Returns:
- Path to database file (deprecated)
- """
- # Get data directory and ensure it exists
- data_dir = get_data_directory()
- data_dir.mkdir(parents=True, exist_ok=True)
-
- # Raise exception instead of returning path
- db_path = data_dir / "deprecated_shared.db"
- raise RuntimeError(
- f"DEPRECATED: Shared database path requested: {db_path}. "
- "This function should not be used - use per-user encrypted databases instead"
- )
-
-
def get_encrypted_database_path() -> Path:
"""Get the path to the encrypted databases directory.
@@ -145,13 +124,3 @@ def get_user_database_filename(username: str) -> str:
def get_data_dir() -> str:
"""Get data directory as string for backward compatibility."""
return str(get_data_directory())
-
-
-def get_db_path() -> str:
- """Get database path as string for backward compatibility.
-
- DEPRECATED: This function should not be used - use per-user encrypted databases instead.
- """
- raise RuntimeError(
- "DEPRECATED: get_db_path() should not be used - use per-user encrypted databases instead"
- )
diff --git a/tests/config/test_paths.py b/tests/config/test_paths.py
index 55d6be3dab..8a2e927a4b 100644
--- a/tests/config/test_paths.py
+++ b/tests/config/test_paths.py
@@ -4,18 +4,14 @@ import hashlib
from pathlib import Path
from unittest.mock import patch
-import pytest
-
from local_deep_research.config.paths import (
get_data_directory,
get_research_outputs_directory,
get_cache_directory,
get_logs_directory,
- get_database_path,
get_encrypted_database_path,
get_user_database_filename,
get_data_dir,
- get_db_path,
)
@@ -87,15 +83,6 @@ class TestGetLogsDirectory:
assert result.exists()
-class TestGetDatabasePath:
- """Tests for get_database_path function."""
-
- def test_raises_deprecation_warning(self, mock_env_data_dir):
- """Should raise DeprecationWarning."""
- with pytest.raises(DeprecationWarning):
- get_database_path()
-
-
class TestGetEncryptedDatabasePath:
"""Tests for get_encrypted_database_path function."""
@@ -147,12 +134,3 @@ class TestGetDataDir:
result = get_data_dir()
assert isinstance(result, str)
assert result == str(mock_env_data_dir)
-
-
-class TestGetDbPath:
- """Tests for get_db_path backward compat function."""
-
- def test_raises_deprecation_warning(self):
- """Should raise DeprecationWarning."""
- with pytest.raises(DeprecationWarning):
- get_db_path()
diff --git a/tests/utilities/test_log_utils.py b/tests/utilities/test_log_utils.py
index 4b7f066655..d61b8c8a28 100644
--- a/tests/utilities/test_log_utils.py
+++ b/tests/utilities/test_log_utils.py
@@ -562,3 +562,62 @@ class TestConfigLogger:
# Should not raise
config_logger("test_app")
+
+
+class TestWriteLogToDatabase:
+ """Tests for _write_log_to_database function."""
+
+ def test_writes_research_log(self):
+ """Should write ResearchLog to database."""
+ from local_deep_research.utilities.log_utils import (
+ _write_log_to_database,
+ )
+
+ log_entry = {
+ "timestamp": datetime.now(),
+ "message": "Test message",
+ "module": "test_module",
+ "function": "test_func",
+ "line_no": 42,
+ "level": "INFO",
+ "research_id": "test-uuid",
+ "username": "testuser",
+ }
+
+ mock_session = MagicMock()
+ mock_cm = MagicMock()
+ mock_cm.__enter__ = Mock(return_value=mock_session)
+ mock_cm.__exit__ = Mock(return_value=None)
+
+ with patch(
+ "local_deep_research.database.session_context.get_user_db_session",
+ return_value=mock_cm,
+ ):
+ _write_log_to_database(log_entry)
+
+ mock_session.add.assert_called_once()
+ mock_session.commit.assert_called_once()
+
+ def test_handles_database_error_gracefully(self):
+ """Should not raise on database errors."""
+ from local_deep_research.utilities.log_utils import (
+ _write_log_to_database,
+ )
+
+ log_entry = {
+ "timestamp": datetime.now(),
+ "message": "Test",
+ "module": "mod",
+ "function": "f",
+ "line_no": 1,
+ "level": "INFO",
+ "research_id": None,
+ "username": None,
+ }
+
+ with patch(
+ "local_deep_research.database.session_context.get_user_db_session",
+ side_effect=Exception("DB error"),
+ ):
+ # Should not raise
+ _write_log_to_database(log_entry)