1
1
from typing import List
2
+ from unittest .mock import MagicMock
2
3
3
4
import pytest
4
5
from litellm import ModelResponse
@@ -94,7 +95,8 @@ async def test_single_step_processing(self):
94
95
"""Test processing a stream through a single step"""
95
96
step = MockOutputPipelineStep ("test_step" , modify_content = True )
96
97
context = MockContext ()
97
- instance = OutputPipelineInstance ([step ], context )
98
+ db_recorder = MagicMock ()
99
+ instance = OutputPipelineInstance ([step ], context , db_recorder )
98
100
99
101
async def mock_stream ():
100
102
yield create_model_response ("Hello" )
@@ -118,7 +120,8 @@ async def test_multiple_steps_processing(self):
118
120
MockOutputPipelineStep ("step2" , modify_content = True ),
119
121
]
120
122
context = MockContext ()
121
- instance = OutputPipelineInstance (steps , context )
123
+ db_recorder = MagicMock ()
124
+ instance = OutputPipelineInstance (steps , context , db_recorder )
122
125
123
126
async def mock_stream ():
124
127
yield create_model_response ("Hello" )
@@ -197,7 +200,8 @@ async def process_chunk(
197
200
return []
198
201
199
202
context = MockContext ()
200
- instance = OutputPipelineInstance ([ReplacementStep ()], context )
203
+ db_recorder = MagicMock ()
204
+ instance = OutputPipelineInstance ([ReplacementStep ()], context , db_recorder )
201
205
202
206
async def mock_stream ():
203
207
yield create_model_response ("he" )
@@ -221,7 +225,8 @@ async def test_buffer_processing(self):
221
225
"""Test that content is properly buffered and cleared"""
222
226
step = MockOutputPipelineStep ("test_step" )
223
227
context = MockContext ()
224
- instance = OutputPipelineInstance ([step ], context )
228
+ db_recorder = MagicMock ()
229
+ instance = OutputPipelineInstance ([step ], context , db_recorder )
225
230
226
231
async def mock_stream ():
227
232
yield create_model_response ("Hello" )
@@ -242,7 +247,8 @@ async def test_empty_stream(self):
242
247
"""Test handling of an empty stream"""
243
248
step = MockOutputPipelineStep ("test_step" )
244
249
context = MockContext ()
245
- instance = OutputPipelineInstance ([step ], context )
250
+ db_recorder = MagicMock ()
251
+ instance = OutputPipelineInstance ([step ], context , db_recorder )
246
252
247
253
async def mock_stream ():
248
254
if False :
@@ -275,7 +281,10 @@ async def process_chunk(
275
281
assert input_context .metadata ["test" ] == "value"
276
282
return [chunk ]
277
283
278
- instance = OutputPipelineInstance ([ContextCheckingStep ()], input_context = input_context )
284
+ db_recorder = MagicMock ()
285
+ instance = OutputPipelineInstance (
286
+ [ContextCheckingStep ()], input_context = input_context , db_recorder = db_recorder
287
+ )
279
288
280
289
async def mock_stream ():
281
290
yield create_model_response ("test" )
@@ -288,7 +297,8 @@ async def test_buffer_flush_on_stream_end(self):
288
297
"""Test that buffer is properly flushed when stream ends"""
289
298
step = MockOutputPipelineStep ("test_step" , should_pause = True )
290
299
context = MockContext ()
291
- instance = OutputPipelineInstance ([step ], context )
300
+ db_recorder = MagicMock ()
301
+ instance = OutputPipelineInstance ([step ], context , db_recorder )
292
302
293
303
async def mock_stream ():
294
304
yield create_model_response ("Hello" )
0 commit comments