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.

refactor: address PR review feedback for stability tests

LearningCircuita771881b1b20
diff --git a/tests/api_tests/test_api_contracts.py b/tests/api_tests/test_api_contracts.py
index 2e1abc99d9..d288ce60b2 100644
--- a/tests/api_tests/test_api_contracts.py
+++ b/tests/api_tests/test_api_contracts.py
@@ -120,65 +120,5 @@ class TestResponseStructures:
)
-class TestAPIEndpointPaths:
- """
- Document critical API endpoint paths.
-
- These tests don't hit the actual endpoints, but document
- the expected paths that clients depend on.
- """
-
- def test_critical_endpoint_paths_documented(self):
- """
- Document the critical API endpoint paths.
-
- Changing these paths will break client integrations.
- """
- # These are the critical endpoint paths that should not change
- critical_paths = [
- # Auth
- "/auth/login",
- "/auth/logout",
- "/auth/csrf-token",
- # Research API
- "/api/start_research",
- "/api/research/<research_id>",
- "/api/research/<research_id>/status",
- "/api/history",
- "/api/report/<research_id>",
- # Settings
- "/settings/api",
- "/settings/api/<path:key>",
- # API v1
- "/api/v1/health",
- "/api/v1/quick_summary",
- "/api/v1/generate_report",
- ]
-
- # This test documents the expected paths.
- # Actual endpoint testing is done in integration tests.
- assert len(critical_paths) > 0, "Critical paths should be documented"
-
-
-class TestErrorResponseFormat:
- """
- Verify error responses have consistent format.
- """
-
- def test_error_response_keys(self):
- """
- Document expected error response format.
-
- Error responses should have "error" or "message" key.
- """
- # Expected error response structures:
- # {"error": "Error message"}
- # {"status": "error", "message": "Error message"}
-
- # This is documentation - actual format testing is in integration tests
- expected_error_keys = ["error", "message", "status"]
- assert len(expected_error_keys) > 0, "Error keys should be documented"
-
-
if __name__ == "__main__":
pytest.main([__file__, "-v"])
diff --git a/tests/database/scripts/__init__.py b/tests/database/scripts/__init__.py
new file mode 100644
index 0000000000..6100eda962
--- /dev/null
+++ b/tests/database/scripts/__init__.py
@@ -0,0 +1 @@
+# Scripts for database backwards compatibility testing
diff --git a/tests/database/scripts/create_compat_db.py b/tests/database/scripts/create_compat_db.py
new file mode 100644
index 0000000000..e9334b9294
--- /dev/null
+++ b/tests/database/scripts/create_compat_db.py
@@ -0,0 +1,51 @@
+#!/usr/bin/env python3
+"""
+Script to create a database using the installed local-deep-research package.
+
+This script is used by test_backwards_compatibility.py to create a database
+with a previous version of the package, which is then tested for compatibility
+with the current version.
+
+Usage:
+ python create_compat_db.py <db_dir> <username> <password>
+"""
+
+import sys
+from pathlib import Path
+
+# Set up paths
+db_dir = Path(sys.argv[1])
+username = sys.argv[2]
+password = sys.argv[3]
+
+# Patch the data directory before importing
+import local_deep_research.config.paths as paths_module # noqa: E402
+
+original_get_data_directory = paths_module.get_data_directory
+paths_module.get_data_directory = lambda: db_dir
+
+from local_deep_research.database.encrypted_db import DatabaseManager # noqa: E402
+
+# Create a fresh manager with patched path
+manager = DatabaseManager()
+manager.data_dir = db_dir / "encrypted_databases"
+manager.data_dir.mkdir(parents=True, exist_ok=True)
+
+# Create the database
+engine = manager.create_user_database(username, password)
+
+# Add some test data
+session = manager.get_session(username)
+from local_deep_research.database.models import UserSettings # noqa: E402
+
+setting = UserSettings(
+ key="test.backwards_compat",
+ value={"version": "previous", "test": True},
+ category="test",
+)
+session.add(setting)
+session.commit()
+session.close()
+
+manager.close_user_database(username)
+print("Database created successfully")
diff --git a/tests/database/test_backwards_compatibility.py b/tests/database/test_backwards_compatibility.py
index 229085cd24..fcc02d57b4 100644
--- a/tests/database/test_backwards_compatibility.py
+++ b/tests/database/test_backwards_compatibility.py
@@ -24,47 +24,11 @@ from pathlib import Path
import pytest
-# Script to create a database using the installed package
-CREATE_DB_SCRIPT = """
-import sys
-import tempfile
-from pathlib import Path
-
-# Set up paths
-db_dir = Path(sys.argv[1])
-username = sys.argv[2]
-password = sys.argv[3]
-
-# Patch the data directory before importing
-import local_deep_research.config.paths as paths_module
-original_get_data_directory = paths_module.get_data_directory
-paths_module.get_data_directory = lambda: db_dir
-
-from local_deep_research.database.encrypted_db import DatabaseManager
-
-# Create a fresh manager with patched path
-manager = DatabaseManager()
-manager.data_dir = db_dir / "encrypted_databases"
-manager.data_dir.mkdir(parents=True, exist_ok=True)
-
-# Create the database
-engine = manager.create_user_database(username, password)
-
-# Add some test data
-session = manager.get_session(username)
-from local_deep_research.database.models import UserSettings
-setting = UserSettings(
- key="test.backwards_compat",
- value={"version": "previous", "test": True},
- category="test",
+# Path to the script that creates a database using the installed package
+# This is in a separate file for better IDE support (syntax highlighting, linting)
+CREATE_DB_SCRIPT_PATH = (
+ Path(__file__).parent / "scripts" / "create_compat_db.py"
)
-session.add(setting)
-session.commit()
-session.close()
-
-manager.close_user_database(username)
-print("Database created successfully")
-"""
class TestBackwardsCompatibility:
@@ -172,8 +136,9 @@ class TestBackwardsCompatibility:
username = "compat_test_user"
password = "CompatTestPass123!"
+ # Copy the script to temp dir (script is in separate file for IDE support)
script_file = temp_dir / "create_db.py"
- script_file.write_text(CREATE_DB_SCRIPT)
+ script_file.write_text(CREATE_DB_SCRIPT_PATH.read_text())
result = subprocess.run(
[