7a0da7932b
Backwards Compatibility / Verify Encryption Constants (push) Waiting to run
Backwards Compatibility / PyPI Version Compatibility (push) Waiting to run
Backwards Compatibility / Database Migration Tests (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
CodeQL Advanced / Analyze (python) (push) Waiting to run
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-form] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-metrics] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-workflow] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [settings-core] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [settings-pages] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [history-news] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [library] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [link-analytics] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [mobile] (push) Blocked by required conditions
Docker Tests (Consolidated) / detect-changes (push) Waiting to run
Docker Tests (Consolidated) / Build Test Image (push) Waiting to run
Docker Tests (Consolidated) / All Pytest Tests + Coverage (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [accessibility] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [api-crud] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-login] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-pages] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-register] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [chat-core] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [chat-lifecycle] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [error-benchmark] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) (push) Blocked by required conditions
Docker Tests (Consolidated) / Accessibility Tests (push) Blocked by required conditions
Docker Tests (Consolidated) / LLM Unit Tests (push) Blocked by required conditions
Docker Tests (Consolidated) / LLM Example Tests (push) Blocked by required conditions
Docker Tests (Consolidated) / Production Image Smoke Test (push) Blocked by required conditions
Docker Tests (Consolidated) / Infrastructure Tests (push) Blocked by required conditions
OSSF Scorecard / OSSF Security Scorecard Analysis (push) Waiting to run
OSV-Scanner (Scheduled) / scan-scheduled (push) Failing after 0s
Create Release / test-gate (push) Has been cancelled
Create Release / release-gate (push) Has been cancelled
Create Release / ci-gate (push) Has been cancelled
Create Release / version-check (push) Has been cancelled
Create Release / e2e-test-gate (push) Has been cancelled
Create Release / responsive-test-gate (push) Has been cancelled
Create Release / compat-test-gate (push) Has been cancelled
Create Release / compose-integration-gate (push) Has been cancelled
Create Release / vulture-gate (push) Has been cancelled
Create Release / build (push) Has been cancelled
Create Release / provenance (push) Has been cancelled
Create Release / prerelease-docker (push) Has been cancelled
Create Release / publish-docker (push) Has been cancelled
Create Release / create-release (push) Has been cancelled
Create Release / cleanup-changelog (push) Has been cancelled
Create Release / trigger-pypi (push) Has been cancelled
Create Release / monitor-pypi (push) Has been cancelled
Create Release / Clean up orphan prerelease tags and signatures (push) Has been cancelled
67 lines
1.9 KiB
Python
67 lines
1.9 KiB
Python
"""Coverage tests for database/session_context.py — basic import-level checks.
|
|
|
|
Covered here:
|
|
- DatabaseSessionError is a proper Exception subclass
|
|
- with_user_database: decorator injects db_session
|
|
- DatabaseAccessMixin.get_db_session: raises DeprecationWarning
|
|
|
|
Additional branch coverage lives in test_session_context_deep_coverage.py.
|
|
"""
|
|
|
|
from unittest.mock import MagicMock, patch
|
|
|
|
import pytest
|
|
|
|
from local_deep_research.database.session_context import (
|
|
DatabaseAccessMixin,
|
|
DatabaseSessionError,
|
|
with_user_database,
|
|
)
|
|
|
|
MODULE = "local_deep_research.database.session_context"
|
|
|
|
|
|
class TestGetUserDbSessionErrors:
|
|
"""Tests for error paths in get_user_db_session."""
|
|
|
|
def test_database_session_error_is_exception(self):
|
|
"""DatabaseSessionError is a proper Exception subclass."""
|
|
assert issubclass(DatabaseSessionError, Exception)
|
|
err = DatabaseSessionError("test message")
|
|
assert str(err) == "test message"
|
|
|
|
|
|
class TestWithUserDatabase:
|
|
"""Tests for with_user_database decorator."""
|
|
|
|
def test_injects_db_session(self):
|
|
"""Decorator injects db_session as first argument."""
|
|
|
|
@with_user_database
|
|
def my_func(db_session, key):
|
|
return f"session={db_session}, key={key}"
|
|
|
|
mock_session = MagicMock()
|
|
with patch(f"{MODULE}.get_user_db_session") as mock_ctx:
|
|
mock_ctx.return_value.__enter__ = MagicMock(
|
|
return_value=mock_session
|
|
)
|
|
mock_ctx.return_value.__exit__ = MagicMock(return_value=False)
|
|
result = my_func("test_key")
|
|
|
|
assert "test_key" in result
|
|
|
|
|
|
class TestDatabaseAccessMixin:
|
|
"""Tests for DatabaseAccessMixin."""
|
|
|
|
def test_get_db_session_raises_deprecation(self):
|
|
"""get_db_session raises DeprecationWarning."""
|
|
|
|
class MyService(DatabaseAccessMixin):
|
|
pass
|
|
|
|
svc = MyService()
|
|
with pytest.raises(DeprecationWarning):
|
|
svc.get_db_session()
|