test(serializers): cover the Genesys AudioHook serializer - #5725
Open
CaptainAni187 wants to merge 1 commit into
Open
test(serializers): cover the Genesys AudioHook serializer#5725CaptainAni187 wants to merge 1 commit into
CaptainAni187 wants to merge 1 commit into
Conversation
Adds wire-format and protocol-state coverage for GenesysAudioHookSerializer: the open/ping/close handshake and its sequence numbering, ulaw audio in both directions, the open-and-paused gates on audio, external-channel extraction from interleaved stereo, DTMF and malformed control messages, and the disconnect and barge-in messages carrying output variables.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GenesysAudioHookSerializeris 964 lines and has no tests. It is the largest untested module undersrc/pipecat/, and the only telephony serializer without coverage: Twilio, Exotel and the protobuf serializer all have some.This adds 20 tests covering the parts a Genesys session depends on.
Handshake and sequencing.
openis answered withopenedand marks the session open; the response echoes the client'sseqasclientseq; the server's ownseqincrements per message;pingis answered withpong;closeis answered withclosedand closes the session.Audio. A round trip through PCMU: PCM out, ulaw on the wire, PCM back at the pipeline rate, with the 8-bit to 16-bit size relationship pinned. Audio is refused in both directions before
openarrives and while the session is paused.Stereo. With
["external", "internal"]negotiated, interleaved audio is de-interleaved to the external channel only.Control messages.
dtmfbecomes anInputDTMFFrame; unparseable JSON and unknown message types are ignored rather than raised;positionis tracked from the client and a malformed one falls back to zero.Outbound.
InterruptionFramebecomes a barge-in event,EndFrameandCancelFramebecome a disconnect, and output variables set throughset_output_variables()reach the disconnect message.Two things worth knowing
Writing these turned up behaviour that is easy to get wrong from the outside, so both are pinned by a test rather than left implicit.
_handle_opennegotiates the channel from themediablock in the open message and overwritesInputParams.channel. Constructing the serializer withchannel=BOTHand then receiving an open that advertises["external"]leaves it mono. The stereo test sets the channel through the handshake for that reason.The disconnect message carries
actionalongsideoutputVariables, so the output-variables test asserts the specific key rather than the whole parameters object.Checks
No changelog fragment: this is tests only, with no user-facing change. Happy to add one if you would rather every PR carry one.
Everything here documents current behaviour rather than proposing changes. If any assertion pins something you consider a bug rather than the contract, say so and I will turn it into an issue instead.