mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-10-27 02:45:24 +08:00
chore(merge): sync master and preserve monitoring test coverage
This commit is contained in:
@@ -46,4 +46,29 @@ def test_migrate_duplicate_routes_and_preserve_primary_and_disabled(column_exist
|
||||
assert conn.execute(sa.select(migrated)).mappings().one() == row
|
||||
migration.downgrade()
|
||||
assert 'plugin_processors' not in {c['name'] for c in sa.inspect(conn).get_columns('bots')}
|
||||
restored = sa.Table('bots', sa.MetaData(), autoload_with=conn)
|
||||
bindings = conn.execute(sa.select(restored.c.event_bindings)).scalar_one()
|
||||
assert bindings == [
|
||||
primary,
|
||||
{
|
||||
'id': 'plugin_processor:one',
|
||||
'event_pattern': '*',
|
||||
'target_type': 'event_processor',
|
||||
'target_uuid': 'one',
|
||||
'enabled': True,
|
||||
'filters': [],
|
||||
'priority': 0,
|
||||
'order': 1,
|
||||
},
|
||||
{
|
||||
'id': 'plugin_processor:two',
|
||||
'event_pattern': '*',
|
||||
'target_type': 'event_processor',
|
||||
'target_uuid': 'two',
|
||||
'enabled': False,
|
||||
'filters': [],
|
||||
'priority': 0,
|
||||
'order': 2,
|
||||
},
|
||||
]
|
||||
engine.dispose()
|
||||
|
||||
@@ -13,7 +13,7 @@ from __future__ import annotations
|
||||
import sys
|
||||
from contextlib import contextmanager
|
||||
from typing import Generator
|
||||
from unittest.mock import MagicMock, Mock
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -174,40 +174,3 @@ class TestManagerClassDecorator:
|
||||
# BaseDatabaseManager has name annotation (type hint)
|
||||
# Check __annotations__ for the type hint
|
||||
assert 'name' in database.BaseDatabaseManager.__annotations__
|
||||
|
||||
def test_decorated_class_inherits_from_base(self):
|
||||
"""Test that decorated class properly inherits BaseDatabaseManager."""
|
||||
database = get_database_module()
|
||||
|
||||
database.preregistered_managers.clear()
|
||||
|
||||
@database.manager_class('test_inherit')
|
||||
class TestChild(database.BaseDatabaseManager):
|
||||
async def initialize(self):
|
||||
pass
|
||||
|
||||
assert issubclass(TestChild, database.BaseDatabaseManager)
|
||||
# Has abstract method requirement satisfied
|
||||
assert hasattr(TestChild, 'initialize')
|
||||
|
||||
def test_decorator_preserves_class_methods(self):
|
||||
"""Test that decorator preserves existing class methods."""
|
||||
database = get_database_module()
|
||||
|
||||
database.preregistered_managers.clear()
|
||||
|
||||
@database.manager_class('preserve_test')
|
||||
class ManagerWithMethods(database.BaseDatabaseManager):
|
||||
custom_attr = 'test_value'
|
||||
|
||||
async def initialize(self):
|
||||
pass
|
||||
|
||||
def custom_method(self):
|
||||
return self.custom_attr
|
||||
|
||||
assert ManagerWithMethods.custom_attr == 'test_value'
|
||||
# Create instance to test method (with mock app)
|
||||
mock_app = Mock()
|
||||
instance = ManagerWithMethods(mock_app)
|
||||
assert instance.custom_method() == 'test_value'
|
||||
|
||||
@@ -50,8 +50,8 @@ class TestExecuteAsync:
|
||||
# Execute a simple select
|
||||
await mgr.execute_async(sqlalchemy.select(1))
|
||||
|
||||
mock_conn.execute.assert_called_once()
|
||||
mock_conn.commit.assert_called_once()
|
||||
mock_conn.execute.assert_awaited_once()
|
||||
mock_conn.commit.assert_awaited_once()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_execute_async_returns_result(self):
|
||||
|
||||
@@ -39,4 +39,6 @@ def test_two_populated_tables_fail_without_discarding_either():
|
||||
with pytest.raises(RuntimeError, match='Both .* contain state'):
|
||||
migration.upgrade()
|
||||
assert set(sa.inspect(conn).get_table_names()) == {'agent_runner_state', 'runner_state'}
|
||||
assert conn.execute(sa.text('SELECT id FROM agent_runner_state')).all() == [(1,)]
|
||||
assert conn.execute(sa.text('SELECT id FROM runner_state')).all() == [(1,)]
|
||||
engine.dispose()
|
||||
|
||||
@@ -81,7 +81,7 @@ class TestSerializeModel:
|
||||
|
||||
result = mgr.serialize_model(TestModel, instance)
|
||||
|
||||
assert '2024-01-15' in result['created_at']
|
||||
assert result['created_at'] == '2024-01-15T10:30:45+00:00'
|
||||
assert isinstance(result['created_at'], str)
|
||||
|
||||
def test_serialize_none_datetime(self):
|
||||
|
||||
Reference in New Issue
Block a user