mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-27 16:04:21 +00:00
test(quality): fix fake tests and add missing coverage
P0 fixes: - telemetry: rewrite fake tests with real behavior verification (25 tests) - config: delete copied-source tests, use proper imports (2 deleted) - persistence: fix try-except pass to verify specific errors P1 fixes: - pipeline: add real FixedWindowAlgo tests instead of mocks (12 tests) - provider: add SessionManager and ToolManager tests (25 tests) - storage: add S3StorageProvider tests with moto mock (16 tests) - plugin: add handler action tests for setting inheritance (15 tests) - rag: add file storage and ZIP processing tests (21 tests) - vector: add VDB filter conversion tests (30 tests) P2 fixes: - pipeline/msgtrun: strengthen assertions for exact message count - api: add response structure validation in integration tests New test files: - provider/test_session_manager.py - provider/test_tool_manager.py - storage/test_s3storage.py - plugin/test_handler_actions.py - rag/test_file_storage.py - vector/test_vdb_filter_conversion.py Source code bugs documented: - provider: TokenManager.next_token() ZeroDivisionError - telemetry: send_tasks class variable shared state - command: empty command IndexError, unused parameters - utils: funcschema KeyError - entity: vector.py independent declarative_base Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -54,13 +54,22 @@ class TestExecuteAsync:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_execute_async_returns_result(self):
|
||||
"""Test that execute_async returns the result."""
|
||||
"""Test that execute_async returns the result from execute.
|
||||
|
||||
NOTE: This test verifies the return value chain - that the result
|
||||
from conn.execute() is properly returned by execute_async().
|
||||
The mock verifies the value propagation, not the SQL execution.
|
||||
For real SQL execution tests, see integration tests.
|
||||
"""
|
||||
persistence = get_persistence_module()
|
||||
|
||||
mock_app = Mock()
|
||||
mgr = persistence.PersistenceManager(mock_app)
|
||||
|
||||
# Create a mock result with actual attributes to simulate real result
|
||||
mock_result = Mock(name='query_result')
|
||||
mock_result.scalar = Mock(return_value=1) # Simulate scalar() method
|
||||
mock_result.scalars = Mock() # Simulate scalars() method
|
||||
|
||||
mock_engine = MagicMock()
|
||||
mock_conn = AsyncMock()
|
||||
@@ -78,7 +87,11 @@ class TestExecuteAsync:
|
||||
|
||||
result = await mgr.execute_async(sqlalchemy.text("SELECT 1"))
|
||||
|
||||
assert result == mock_result
|
||||
# Verify result is the same object returned by execute
|
||||
assert result is mock_result
|
||||
# Verify result has expected methods (simulating real Result object)
|
||||
assert hasattr(result, 'scalar')
|
||||
assert result.scalar() == 1
|
||||
|
||||
|
||||
class TestGetDbEngine:
|
||||
|
||||
Reference in New Issue
Block a user