tests(utils): allow passing PipelineParams to run_test()

This commit is contained in:
Aleix Conchillo Flaqué
2025-09-11 12:59:27 -07:00
parent dac58deffc
commit 74b38b59d6
2 changed files with 5 additions and 5 deletions

View File

@@ -128,7 +128,7 @@ async def run_test(
expected_up_frames: Optional[Sequence[type]] = None, expected_up_frames: Optional[Sequence[type]] = None,
ignore_start: bool = True, ignore_start: bool = True,
observers: Optional[List[BaseObserver]] = None, observers: Optional[List[BaseObserver]] = None,
start_metadata: Optional[Dict[str, Any]] = None, pipeline_params: Optional[PipelineParams] = None,
send_end_frame: bool = True, send_end_frame: bool = True,
) -> Tuple[Sequence[Frame], Sequence[Frame]]: ) -> Tuple[Sequence[Frame], Sequence[Frame]]:
"""Run a test pipeline with the specified processor and validate frame flow. """Run a test pipeline with the specified processor and validate frame flow.
@@ -144,7 +144,7 @@ async def run_test(
expected_up_frames: Expected frame types flowing upstream (optional). expected_up_frames: Expected frame types flowing upstream (optional).
ignore_start: Whether to ignore StartFrames in frame validation. ignore_start: Whether to ignore StartFrames in frame validation.
observers: Optional list of observers to attach to the pipeline. observers: Optional list of observers to attach to the pipeline.
start_metadata: Optional metadata to include with the StartFrame. pipeline_params: Optional pipeline parameters.
send_end_frame: Whether to send an EndFrame at the end of the test. send_end_frame: Whether to send an EndFrame at the end of the test.
Returns: Returns:
@@ -154,7 +154,7 @@ async def run_test(
AssertionError: If the received frames don't match the expected frame types. AssertionError: If the received frames don't match the expected frame types.
""" """
observers = observers or [] observers = observers or []
start_metadata = start_metadata or {} pipeline_params = pipeline_params or PipelineParams()
received_up = asyncio.Queue() received_up = asyncio.Queue()
received_down = asyncio.Queue() received_down = asyncio.Queue()
@@ -173,7 +173,7 @@ async def run_test(
task = PipelineTask( task = PipelineTask(
pipeline, pipeline,
params=PipelineParams(start_metadata=start_metadata), params=pipeline_params,
observers=observers, observers=observers,
cancel_on_idle_timeout=False, cancel_on_idle_timeout=False,
) )

View File

@@ -65,7 +65,7 @@ class TestPipeline(unittest.IsolatedAsyncioTestCase):
frames_to_send=frames_to_send, frames_to_send=frames_to_send,
expected_down_frames=expected_down_frames, expected_down_frames=expected_down_frames,
ignore_start=False, ignore_start=False,
start_metadata={"foo": "bar"}, pipeline_params=PipelineParams(start_metadata={"foo": "bar"}),
) )
assert "foo" in received_down[-1].metadata assert "foo" in received_down[-1].metadata