mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-10-22 08:25:21 +08:00
test(core): update bot fixtures for platform policy checks
This commit is contained in:
@@ -114,7 +114,12 @@ async def test_runtime_error_redacts_persisted_secrets_on_partial_update():
|
||||
)
|
||||
service = BotService(ap)
|
||||
service.get_bot = AsyncMock(
|
||||
return_value={'uuid': 'bot-1', 'enable': True, 'adapter_config': {'app_secret': 'persisted-secret-value'}}
|
||||
return_value={
|
||||
'uuid': 'bot-1',
|
||||
'adapter': 'aiocqhttp',
|
||||
'enable': True,
|
||||
'adapter_config': {'app_secret': 'persisted-secret-value'},
|
||||
}
|
||||
)
|
||||
with pytest.raises(BotApplyError) as captured:
|
||||
await service.update_bot('workspace-test', 'bot-1', {'enable': True})
|
||||
|
||||
@@ -14,8 +14,13 @@ from langbot.pkg.persistence.tenant_uow import PersistenceScope, PersistenceScop
|
||||
|
||||
def make_bot(subscriptions):
|
||||
bot = object.__new__(RuntimeBot)
|
||||
bot.bot_entity = SimpleNamespace(uuid='bot', event_bindings=[], plugin_processors=subscriptions)
|
||||
bot.bot_entity = SimpleNamespace(
|
||||
uuid='bot', adapter='aiocqhttp', event_bindings=[], plugin_processors=subscriptions
|
||||
)
|
||||
bot.execution_context = 'workspace'
|
||||
bot.workspace_uuid = 'workspace'
|
||||
bot.placement_generation = 1
|
||||
bot.ap = SimpleNamespace(workspace_service=SimpleNamespace(get_execution_binding=AsyncMock()))
|
||||
bot._record_adapter_event = AsyncMock()
|
||||
bot._record_event_route_trace = AsyncMock()
|
||||
bot.logger = SimpleNamespace(error=AsyncMock())
|
||||
@@ -124,7 +129,8 @@ async def test_cloud_deliveries_own_their_scope_and_preserve_parent(primary_fail
|
||||
)
|
||||
|
||||
bot.ap = SimpleNamespace(
|
||||
persistence_mgr=SimpleNamespace(mode=SimpleNamespace(value='cloud_runtime'), tenant_scope=tenant_scope)
|
||||
workspace_service=SimpleNamespace(get_execution_binding=AsyncMock()),
|
||||
persistence_mgr=SimpleNamespace(mode=SimpleNamespace(value='cloud_runtime'), tenant_scope=tenant_scope),
|
||||
)
|
||||
seen = []
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ class TestEventRouteTrace:
|
||||
bot = object.__new__(RuntimeBot)
|
||||
bot.bot_entity = SimpleNamespace(
|
||||
uuid='bot-1',
|
||||
adapter='aiocqhttp',
|
||||
workspace_uuid=TEST_CONTEXT.workspace_uuid,
|
||||
event_bindings=event_bindings,
|
||||
)
|
||||
@@ -703,7 +704,10 @@ async def test_installed_event_processor_never_receives_unbound_events():
|
||||
from langbot_plugin.api.entities.builtin.platform.events import MemberJoinedEvent
|
||||
|
||||
bot = TestEventRouteTrace._make_bot([])
|
||||
bot.ap = SimpleNamespace(plugin_connector=SimpleNamespace(emit_event=AsyncMock()))
|
||||
bot.ap = SimpleNamespace(
|
||||
workspace_service=active_workspace_service(),
|
||||
plugin_connector=SimpleNamespace(emit_event=AsyncMock()),
|
||||
)
|
||||
bot._record_adapter_event = AsyncMock()
|
||||
await bot._handle_platform_event(MemberJoinedEvent(), Mock())
|
||||
bot.ap.plugin_connector.emit_event.assert_not_called()
|
||||
|
||||
@@ -563,7 +563,7 @@ def test_requester_error_message_format():
|
||||
"""Test RequesterError message format."""
|
||||
error = RequesterError('API returned 500')
|
||||
|
||||
assert '模型请求失败' in str(error)
|
||||
assert 'Model request failed' in str(error)
|
||||
assert 'API returned 500' in str(error)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user