mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-10-26 18:35:38 +08:00
test: update adapter and monitoring regression fixtures
This commit is contained in:
@@ -294,7 +294,7 @@ async def test_cross_workspace_parent_references_are_rejected(tenant_services):
|
||||
{
|
||||
'event_bindings': [
|
||||
{
|
||||
'event_pattern': 'message.*',
|
||||
'event_pattern': 'message.received',
|
||||
'target_type': 'pipeline',
|
||||
'target_uuid': 'pipeline-b',
|
||||
}
|
||||
|
||||
@@ -390,14 +390,14 @@ class TestBotServiceCreateBot:
|
||||
async def mock_execute(query):
|
||||
nonlocal call_count
|
||||
call_count += 1
|
||||
if call_count <= 2:
|
||||
return pipeline_result # First call: check pipeline
|
||||
elif call_count == 3:
|
||||
return Mock() # Insert
|
||||
if call_count == 1:
|
||||
return Mock() # Insert; there is no legacy pipeline lookup
|
||||
return bot_result # Get bot
|
||||
|
||||
ap.persistence_mgr.execute_async = AsyncMock(side_effect=mock_execute)
|
||||
ap.persistence_mgr.serialize_model = Mock(return_value={'uuid': 'new-uuid', 'name': 'New Bot'})
|
||||
ap.persistence_mgr.serialize_model = Mock(
|
||||
return_value={'uuid': 'new-uuid', 'name': 'New Bot', 'adapter': 'telegram', 'enable': False}
|
||||
)
|
||||
|
||||
service = BotService(ap)
|
||||
|
||||
|
||||
@@ -74,9 +74,9 @@ async def test_event_properties_survive_detail_snapshot_fallback(engine, service
|
||||
await session.commit()
|
||||
detail = await service.get_execution_detail(WORKSPACE, 'agent', 'custom-run')
|
||||
items = detail['pages']['inputs']['items']
|
||||
assert items[0]['content']['member'] == data['member']
|
||||
assert items[0]['content']['count'] == 0
|
||||
assert items[0]['content']['custom'] == data['custom']
|
||||
assert items[0]['content']['event']['member'] == data['member']
|
||||
assert items[0]['content']['event']['count'] == 0
|
||||
assert items[0]['content']['event']['custom'] == data['custom']
|
||||
if has_log:
|
||||
assert items[1]['content'] == {'text': 'later'}
|
||||
|
||||
@@ -85,6 +85,7 @@ def test_event_content_preserves_conflicting_custom_input_fields():
|
||||
from langbot.pkg.api.http.service.monitoring_execution_details import event_content
|
||||
|
||||
assert event_content({'text': 'normalized'}, {'text': {'custom': False}}) == {
|
||||
'text': 'event',
|
||||
'event': {'text': {'custom': False}},
|
||||
'input': {'text': 'normalized'},
|
||||
}
|
||||
@@ -747,9 +748,15 @@ async def test_inflight_snapshot_is_scoped_and_keeps_terminal_transition(engine,
|
||||
service._get_token_coverage = AsyncMock(side_effect=AssertionError('No dashboard aggregates'))
|
||||
async with AsyncSession(engine) as session:
|
||||
for workspace, run_id in [(WORKSPACE, 'flight-visible'), ('other-workspace', 'flight-secret')]:
|
||||
session.add(persistence_agent_run.AgentRun(
|
||||
run_id=run_id, workspace_id=workspace, runner_id='runner', status='running', created_at=_dt(1),
|
||||
))
|
||||
session.add(
|
||||
persistence_agent_run.AgentRun(
|
||||
run_id=run_id,
|
||||
workspace_id=workspace,
|
||||
runner_id='runner',
|
||||
status='running',
|
||||
created_at=_dt(1),
|
||||
)
|
||||
)
|
||||
session.add(persistence_agent_run.AgentRunEvent(run_id='flight-visible', sequence=1, type='tool.started'))
|
||||
await session.commit()
|
||||
snapshot = await service.get_inflight_snapshot(WORKSPACE)
|
||||
@@ -757,9 +764,11 @@ async def test_inflight_snapshot_is_scoped_and_keeps_terminal_transition(engine,
|
||||
assert 'flight-secret' not in rows
|
||||
assert rows['flight-visible']['progress_event'] == 'tool.started'
|
||||
async with AsyncSession(engine) as session:
|
||||
await session.execute(sa.update(persistence_agent_run.AgentRun).where(
|
||||
persistence_agent_run.AgentRun.run_id == 'flight-visible'
|
||||
).values(status='completed'))
|
||||
await session.execute(
|
||||
sa.update(persistence_agent_run.AgentRun)
|
||||
.where(persistence_agent_run.AgentRun.run_id == 'flight-visible')
|
||||
.values(status='completed')
|
||||
)
|
||||
await session.commit()
|
||||
next_snapshot = await service.get_inflight_snapshot(WORKSPACE, [rows['flight-visible']])
|
||||
assert next(r for r in next_snapshot['items'] if r['id'] == 'flight-visible')['status_group'] == 'completed'
|
||||
|
||||
@@ -106,6 +106,7 @@ async def test_runtime_error_redacts_persisted_secrets_on_partial_update():
|
||||
|
||||
ap = SimpleNamespace(
|
||||
persistence_mgr=SimpleNamespace(execute_async=AsyncMock(return_value=SimpleNamespace(rowcount=1))),
|
||||
sess_mgr=SimpleNamespace(session_list=[]),
|
||||
platform_mgr=SimpleNamespace(
|
||||
remove_bot=AsyncMock(),
|
||||
load_bot=AsyncMock(side_effect=ValueError('Invalid app_secret: persisted-secret-value')),
|
||||
@@ -113,7 +114,7 @@ async def test_runtime_error_redacts_persisted_secrets_on_partial_update():
|
||||
)
|
||||
service = BotService(ap)
|
||||
service.get_bot = AsyncMock(
|
||||
return_value={'uuid': 'bot-1', 'adapter_config': {'app_secret': 'persisted-secret-value'}}
|
||||
return_value={'uuid': 'bot-1', '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})
|
||||
|
||||
@@ -8,6 +8,7 @@ import pytest
|
||||
|
||||
from langbot.pkg.agent.runner.descriptor import RunnerDescriptor
|
||||
from langbot.pkg.api.http.service.pipeline import PipelineService
|
||||
from langbot.pkg.api.http.service.model import LLMModelsService
|
||||
|
||||
|
||||
class FakeLogger:
|
||||
@@ -54,6 +55,7 @@ async def test_default_pipeline_config_uses_first_installed_runner_schema():
|
||||
logger=FakeLogger(),
|
||||
runner_registry=FakeRegistry([custom_agent, local_agent]),
|
||||
)
|
||||
ap.llm_model_service = LLMModelsService(ap)
|
||||
|
||||
config = await PipelineService(ap).get_default_pipeline_config('workspace-test')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user