mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-26 15:34:26 +00:00
1577567a78
- Replace legacy pipeline binding card + RoutingRulesEditor with unified EventBindingsEditor; remove use_pipeline_uuid/pipeline_routing_rules from bot form schema and API update handler - Add _augment_event_data() to botmgr for filter virtual fields (message_text, message_element_types, chat_type) - Add alembic migration 0009: migrate use_pipeline_uuid and pipeline_routing_rules into event_bindings on first run - Fix command.tsx: data-[disabled] -> data-[disabled=true] so cmdk 1.x items (data-disabled=false) are not pointer-events:none - EventBindingsEditor: onSelect on CommandItems, filter conditions panel, disabled bindings section, dnd reorder - i18n: add filter/condition keys for zh-Hans and en-US - Update tests to match new bot service behavior Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
63 lines
1.8 KiB
Python
63 lines
1.8 KiB
Python
from types import SimpleNamespace
|
|
from unittest.mock import AsyncMock
|
|
|
|
from sqlalchemy.sql.dml import Update
|
|
|
|
from langbot.pkg.api.http.service.bot import BotService
|
|
|
|
|
|
class _FakeResult:
|
|
def __init__(self, value):
|
|
self.value = value
|
|
|
|
def first(self):
|
|
return self.value
|
|
|
|
|
|
class _PersistenceManager:
|
|
def __init__(self):
|
|
self.update_values = None
|
|
|
|
async def execute_async(self, statement):
|
|
if isinstance(statement, Update):
|
|
self.update_values = {
|
|
key: value for key, value in statement.compile().params.items() if not key.startswith('uuid_')
|
|
}
|
|
return None
|
|
|
|
return _FakeResult(SimpleNamespace(name='Updated Pipeline'))
|
|
|
|
|
|
async def test_update_bot_copies_input_before_filtering_legacy_routing_fields():
|
|
persistence_mgr = _PersistenceManager()
|
|
runtime_bot = SimpleNamespace(enable=False)
|
|
platform_mgr = SimpleNamespace(
|
|
remove_bot=AsyncMock(),
|
|
load_bot=AsyncMock(return_value=runtime_bot),
|
|
)
|
|
ap = SimpleNamespace(
|
|
persistence_mgr=persistence_mgr,
|
|
platform_mgr=platform_mgr,
|
|
sess_mgr=SimpleNamespace(session_list=[]),
|
|
)
|
|
service = BotService(ap)
|
|
service.get_bot = AsyncMock(return_value={'uuid': 'bot-1'})
|
|
payload = {
|
|
'uuid': 'caller-owned-uuid',
|
|
'name': 'Test Bot',
|
|
'use_pipeline_uuid': 'pipeline-1',
|
|
'pipeline_routing_rules': [{'type': 'launcher_type'}],
|
|
}
|
|
|
|
await service.update_bot('bot-1', payload)
|
|
|
|
# caller's dict must not be mutated
|
|
assert payload == {
|
|
'uuid': 'caller-owned-uuid',
|
|
'name': 'Test Bot',
|
|
'use_pipeline_uuid': 'pipeline-1',
|
|
'pipeline_routing_rules': [{'type': 'launcher_type'}],
|
|
}
|
|
# legacy routing fields are stripped; only name is persisted
|
|
assert persistence_mgr.update_values == {'name': 'Test Bot'}
|