tests: rename some variables to make things clearer
This commit is contained in:
@@ -29,12 +29,12 @@ class TestSentenceAggregator(unittest.IsolatedAsyncioTestCase):
|
|||||||
for word in sentence.split(" "):
|
for word in sentence.split(" "):
|
||||||
frames_to_send.append(TextFrame(text=word + " "))
|
frames_to_send.append(TextFrame(text=word + " "))
|
||||||
|
|
||||||
expected_returned_frames = [TextFrame, TextFrame, TextFrame]
|
expected_down_frames = [TextFrame, TextFrame, TextFrame]
|
||||||
|
|
||||||
(received_down, _) = await run_test(
|
(received_down, _) = await run_test(
|
||||||
aggregator,
|
aggregator,
|
||||||
frames_to_send=frames_to_send,
|
frames_to_send=frames_to_send,
|
||||||
expected_down_frames=expected_returned_frames,
|
expected_down_frames=expected_down_frames,
|
||||||
)
|
)
|
||||||
assert received_down[-3].text == "Hello, world. "
|
assert received_down[-3].text == "Hello, world. "
|
||||||
assert received_down[-2].text == "How are you? "
|
assert received_down[-2].text == "How are you? "
|
||||||
@@ -59,7 +59,7 @@ class TestGatedAggregator(unittest.IsolatedAsyncioTestCase):
|
|||||||
LLMFullResponseEndFrame(),
|
LLMFullResponseEndFrame(),
|
||||||
]
|
]
|
||||||
|
|
||||||
expected_returned_frames = [
|
expected_down_frames = [
|
||||||
OutputImageRawFrame,
|
OutputImageRawFrame,
|
||||||
LLMFullResponseStartFrame,
|
LLMFullResponseStartFrame,
|
||||||
TextFrame,
|
TextFrame,
|
||||||
@@ -72,5 +72,5 @@ class TestGatedAggregator(unittest.IsolatedAsyncioTestCase):
|
|||||||
(received_down, _) = await run_test(
|
(received_down, _) = await run_test(
|
||||||
gated_aggregator,
|
gated_aggregator,
|
||||||
frames_to_send=frames_to_send,
|
frames_to_send=frames_to_send,
|
||||||
expected_down_frames=expected_returned_frames,
|
expected_down_frames=expected_down_frames,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -25,11 +25,11 @@ class TestIdentifyFilter(unittest.IsolatedAsyncioTestCase):
|
|||||||
async def test_identity(self):
|
async def test_identity(self):
|
||||||
filter = IdentityFilter()
|
filter = IdentityFilter()
|
||||||
frames_to_send = [UserStartedSpeakingFrame(), UserStoppedSpeakingFrame()]
|
frames_to_send = [UserStartedSpeakingFrame(), UserStoppedSpeakingFrame()]
|
||||||
expected_returned_frames = [UserStartedSpeakingFrame, UserStoppedSpeakingFrame]
|
expected_down_frames = [UserStartedSpeakingFrame, UserStoppedSpeakingFrame]
|
||||||
await run_test(
|
await run_test(
|
||||||
filter,
|
filter,
|
||||||
frames_to_send=frames_to_send,
|
frames_to_send=frames_to_send,
|
||||||
expected_down_frames=expected_returned_frames,
|
expected_down_frames=expected_down_frames,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -37,32 +37,32 @@ class TestFrameFilter(unittest.IsolatedAsyncioTestCase):
|
|||||||
async def test_text_frame(self):
|
async def test_text_frame(self):
|
||||||
filter = FrameFilter(types=(TextFrame,))
|
filter = FrameFilter(types=(TextFrame,))
|
||||||
frames_to_send = [TextFrame(text="Hello Pipecat!")]
|
frames_to_send = [TextFrame(text="Hello Pipecat!")]
|
||||||
expected_returned_frames = [TextFrame]
|
expected_down_frames = [TextFrame]
|
||||||
await run_test(
|
await run_test(
|
||||||
filter,
|
filter,
|
||||||
frames_to_send=frames_to_send,
|
frames_to_send=frames_to_send,
|
||||||
expected_down_frames=expected_returned_frames,
|
expected_down_frames=expected_down_frames,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def test_end_frame(self):
|
async def test_end_frame(self):
|
||||||
filter = FrameFilter(types=(EndFrame,))
|
filter = FrameFilter(types=(EndFrame,))
|
||||||
frames_to_send = [EndFrame()]
|
frames_to_send = [EndFrame()]
|
||||||
expected_returned_frames = [EndFrame]
|
expected_down_frames = [EndFrame]
|
||||||
await run_test(
|
await run_test(
|
||||||
filter,
|
filter,
|
||||||
frames_to_send=frames_to_send,
|
frames_to_send=frames_to_send,
|
||||||
expected_down_frames=expected_returned_frames,
|
expected_down_frames=expected_down_frames,
|
||||||
send_end_frame=False,
|
send_end_frame=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def test_system_frame(self):
|
async def test_system_frame(self):
|
||||||
filter = FrameFilter(types=())
|
filter = FrameFilter(types=())
|
||||||
frames_to_send = [UserStartedSpeakingFrame()]
|
frames_to_send = [UserStartedSpeakingFrame()]
|
||||||
expected_returned_frames = [UserStartedSpeakingFrame]
|
expected_down_frames = [UserStartedSpeakingFrame]
|
||||||
await run_test(
|
await run_test(
|
||||||
filter,
|
filter,
|
||||||
frames_to_send=frames_to_send,
|
frames_to_send=frames_to_send,
|
||||||
expected_down_frames=expected_returned_frames,
|
expected_down_frames=expected_down_frames,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -73,11 +73,11 @@ class TestFunctionFilter(unittest.IsolatedAsyncioTestCase):
|
|||||||
|
|
||||||
filter = FunctionFilter(filter=passthrough)
|
filter = FunctionFilter(filter=passthrough)
|
||||||
frames_to_send = [TextFrame(text="Hello Pipecat!")]
|
frames_to_send = [TextFrame(text="Hello Pipecat!")]
|
||||||
expected_returned_frames = [TextFrame]
|
expected_down_frames = [TextFrame]
|
||||||
await run_test(
|
await run_test(
|
||||||
filter,
|
filter,
|
||||||
frames_to_send=frames_to_send,
|
frames_to_send=frames_to_send,
|
||||||
expected_down_frames=expected_returned_frames,
|
expected_down_frames=expected_down_frames,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def test_no_passthrough(self):
|
async def test_no_passthrough(self):
|
||||||
@@ -86,11 +86,11 @@ class TestFunctionFilter(unittest.IsolatedAsyncioTestCase):
|
|||||||
|
|
||||||
filter = FunctionFilter(filter=no_passthrough)
|
filter = FunctionFilter(filter=no_passthrough)
|
||||||
frames_to_send = [TextFrame(text="Hello Pipecat!")]
|
frames_to_send = [TextFrame(text="Hello Pipecat!")]
|
||||||
expected_returned_frames = []
|
expected_down_frames = []
|
||||||
await run_test(
|
await run_test(
|
||||||
filter,
|
filter,
|
||||||
frames_to_send=frames_to_send,
|
frames_to_send=frames_to_send,
|
||||||
expected_down_frames=expected_returned_frames,
|
expected_down_frames=expected_down_frames,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -98,11 +98,11 @@ class TestWakeCheckFilter(unittest.IsolatedAsyncioTestCase):
|
|||||||
async def test_no_wake_word(self):
|
async def test_no_wake_word(self):
|
||||||
filter = WakeCheckFilter(wake_phrases=["Hey, Pipecat"])
|
filter = WakeCheckFilter(wake_phrases=["Hey, Pipecat"])
|
||||||
frames_to_send = [TranscriptionFrame(user_id="test", text="Phrase 1", timestamp="")]
|
frames_to_send = [TranscriptionFrame(user_id="test", text="Phrase 1", timestamp="")]
|
||||||
expected_returned_frames = []
|
expected_down_frames = []
|
||||||
await run_test(
|
await run_test(
|
||||||
filter,
|
filter,
|
||||||
frames_to_send=frames_to_send,
|
frames_to_send=frames_to_send,
|
||||||
expected_down_frames=expected_returned_frames,
|
expected_down_frames=expected_down_frames,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def test_wake_word(self):
|
async def test_wake_word(self):
|
||||||
@@ -111,10 +111,10 @@ class TestWakeCheckFilter(unittest.IsolatedAsyncioTestCase):
|
|||||||
TranscriptionFrame(user_id="test", text="Hey, Pipecat", timestamp=""),
|
TranscriptionFrame(user_id="test", text="Hey, Pipecat", timestamp=""),
|
||||||
TranscriptionFrame(user_id="test", text="Phrase 1", timestamp=""),
|
TranscriptionFrame(user_id="test", text="Phrase 1", timestamp=""),
|
||||||
]
|
]
|
||||||
expected_returned_frames = [TranscriptionFrame, TranscriptionFrame]
|
expected_down_frames = [TranscriptionFrame, TranscriptionFrame]
|
||||||
(received_down, _) = await run_test(
|
(received_down, _) = await run_test(
|
||||||
filter,
|
filter,
|
||||||
frames_to_send=frames_to_send,
|
frames_to_send=frames_to_send,
|
||||||
expected_down_frames=expected_returned_frames,
|
expected_down_frames=expected_down_frames,
|
||||||
)
|
)
|
||||||
assert received_down[-1].text == "Phrase 1"
|
assert received_down[-1].text == "Phrase 1"
|
||||||
|
|||||||
@@ -21,11 +21,11 @@ class TestPipeline(unittest.IsolatedAsyncioTestCase):
|
|||||||
pipeline = Pipeline([IdentityFilter()])
|
pipeline = Pipeline([IdentityFilter()])
|
||||||
|
|
||||||
frames_to_send = [TextFrame(text="Hello from Pipecat!")]
|
frames_to_send = [TextFrame(text="Hello from Pipecat!")]
|
||||||
expected_returned_frames = [TextFrame]
|
expected_down_frames = [TextFrame]
|
||||||
await run_test(
|
await run_test(
|
||||||
pipeline,
|
pipeline,
|
||||||
frames_to_send=frames_to_send,
|
frames_to_send=frames_to_send,
|
||||||
expected_down_frames=expected_returned_frames,
|
expected_down_frames=expected_down_frames,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def test_pipeline_multiple(self):
|
async def test_pipeline_multiple(self):
|
||||||
@@ -36,22 +36,22 @@ class TestPipeline(unittest.IsolatedAsyncioTestCase):
|
|||||||
pipeline = Pipeline([identity1, identity2, identity3])
|
pipeline = Pipeline([identity1, identity2, identity3])
|
||||||
|
|
||||||
frames_to_send = [TextFrame(text="Hello from Pipecat!")]
|
frames_to_send = [TextFrame(text="Hello from Pipecat!")]
|
||||||
expected_returned_frames = [TextFrame]
|
expected_down_frames = [TextFrame]
|
||||||
await run_test(
|
await run_test(
|
||||||
pipeline,
|
pipeline,
|
||||||
frames_to_send=frames_to_send,
|
frames_to_send=frames_to_send,
|
||||||
expected_down_frames=expected_returned_frames,
|
expected_down_frames=expected_down_frames,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def test_pipeline_start_metadata(self):
|
async def test_pipeline_start_metadata(self):
|
||||||
pipeline = Pipeline([IdentityFilter()])
|
pipeline = Pipeline([IdentityFilter()])
|
||||||
|
|
||||||
frames_to_send = []
|
frames_to_send = []
|
||||||
expected_returned_frames = [StartFrame]
|
expected_down_frames = [StartFrame]
|
||||||
(received_down, _) = await run_test(
|
(received_down, _) = await run_test(
|
||||||
pipeline,
|
pipeline,
|
||||||
frames_to_send=frames_to_send,
|
frames_to_send=frames_to_send,
|
||||||
expected_down_frames=expected_returned_frames,
|
expected_down_frames=expected_down_frames,
|
||||||
ignore_start=False,
|
ignore_start=False,
|
||||||
start_metadata={"foo": "bar"},
|
start_metadata={"foo": "bar"},
|
||||||
)
|
)
|
||||||
@@ -63,11 +63,11 @@ class TestParallelPipeline(unittest.IsolatedAsyncioTestCase):
|
|||||||
pipeline = ParallelPipeline([IdentityFilter()])
|
pipeline = ParallelPipeline([IdentityFilter()])
|
||||||
|
|
||||||
frames_to_send = [TextFrame(text="Hello from Pipecat!")]
|
frames_to_send = [TextFrame(text="Hello from Pipecat!")]
|
||||||
expected_returned_frames = [TextFrame]
|
expected_down_frames = [TextFrame]
|
||||||
await run_test(
|
await run_test(
|
||||||
pipeline,
|
pipeline,
|
||||||
frames_to_send=frames_to_send,
|
frames_to_send=frames_to_send,
|
||||||
expected_down_frames=expected_returned_frames,
|
expected_down_frames=expected_down_frames,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def test_parallel_multiple(self):
|
async def test_parallel_multiple(self):
|
||||||
@@ -75,11 +75,11 @@ class TestParallelPipeline(unittest.IsolatedAsyncioTestCase):
|
|||||||
pipeline = ParallelPipeline([IdentityFilter()], [IdentityFilter()])
|
pipeline = ParallelPipeline([IdentityFilter()], [IdentityFilter()])
|
||||||
|
|
||||||
frames_to_send = [TextFrame(text="Hello from Pipecat!")]
|
frames_to_send = [TextFrame(text="Hello from Pipecat!")]
|
||||||
expected_returned_frames = [TextFrame]
|
expected_down_frames = [TextFrame]
|
||||||
await run_test(
|
await run_test(
|
||||||
pipeline,
|
pipeline,
|
||||||
frames_to_send=frames_to_send,
|
frames_to_send=frames_to_send,
|
||||||
expected_down_frames=expected_returned_frames,
|
expected_down_frames=expected_down_frames,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user