mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-08-29 13:47:14 +00:00
chore(merge): sync master into dev/4.11.x
This commit is contained in:
@@ -5,13 +5,19 @@ import pytest
|
||||
from langbot.pkg.api.http.service.pipeline import PipelineService
|
||||
|
||||
|
||||
WORKSPACE_UUID = 'workspace-a'
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_update_pipeline_filters_protected_fields_without_mutating_input(mock_app):
|
||||
service = PipelineService(mock_app)
|
||||
loaded_pipeline = Mock()
|
||||
service.get_pipeline = AsyncMock(return_value=loaded_pipeline)
|
||||
|
||||
mock_app.persistence_mgr.execute_async = AsyncMock(return_value=None)
|
||||
bot = Mock(uuid='bot-uuid')
|
||||
bot_result = Mock(all=Mock(return_value=[bot]))
|
||||
mock_app.persistence_mgr.execute_async = AsyncMock(side_effect=[None, bot_result])
|
||||
mock_app.bot_service = Mock(update_bot=AsyncMock())
|
||||
mock_app.pipeline_mgr = Mock(remove_pipeline=AsyncMock(), load_pipeline=AsyncMock())
|
||||
mock_app.sess_mgr.session_list = []
|
||||
|
||||
@@ -24,7 +30,7 @@ async def test_update_pipeline_filters_protected_fields_without_mutating_input(m
|
||||
}
|
||||
original_pipeline_data = pipeline_data.copy()
|
||||
|
||||
await service.update_pipeline('pipeline-uuid', pipeline_data)
|
||||
await service.update_pipeline(WORKSPACE_UUID, 'pipeline-uuid', pipeline_data)
|
||||
|
||||
assert pipeline_data == original_pipeline_data
|
||||
|
||||
@@ -32,5 +38,6 @@ async def test_update_pipeline_filters_protected_fields_without_mutating_input(m
|
||||
updated_fields = {getattr(field, 'key', str(field)) for field in update_stmt._values}
|
||||
assert updated_fields == {'name'}
|
||||
|
||||
mock_app.pipeline_mgr.remove_pipeline.assert_awaited_once_with('pipeline-uuid')
|
||||
mock_app.pipeline_mgr.load_pipeline.assert_awaited_once_with(loaded_pipeline)
|
||||
mock_app.bot_service.update_bot.assert_not_awaited()
|
||||
mock_app.pipeline_mgr.remove_pipeline.assert_awaited_once_with('workspace-a', 'pipeline-uuid')
|
||||
mock_app.pipeline_mgr.load_pipeline.assert_awaited_once_with('workspace-a', loaded_pipeline)
|
||||
|
||||
Reference in New Issue
Block a user