-
Notifications
You must be signed in to change notification settings - Fork 489
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
write tests for how the transcript looks (#352)
* starts tests scaffolding * Format transcript properly and add test * Add test using ActionInput instead of TwilioPhoneCallActionInput * Format transcript manually * No more underscore --------- Co-authored-by: Hayden Housen <[email protected]>
- Loading branch information
Showing
2 changed files
with
100 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import asyncio | ||
from vocode.streaming.models.actions import ( | ||
ActionInput, | ||
ActionOutput, | ||
TwilioPhoneCallActionInput, | ||
) | ||
from vocode.streaming.models.transcript import ActionStart, ActionFinish | ||
from vocode.streaming.models.events import Sender | ||
from vocode.streaming.models.transcript import Message | ||
from vocode.streaming.models.transcript import Transcript | ||
from vocode.streaming.action.nylas_send_email import ( | ||
NylasSendEmailActionConfig, | ||
NylasSendEmailParameters, | ||
NylasSendEmailResponse, | ||
) | ||
|
||
|
||
def test_transcript_to_string(): | ||
transcript = Transcript( | ||
event_logs=[ | ||
Message(sender=Sender.BOT, text="What up"), | ||
Message( | ||
sender=Sender.HUMAN, | ||
text="Send me an email you bot. My email is [email protected]", | ||
), | ||
ActionStart( | ||
action_type="action_nylas_send_email", | ||
action_input=TwilioPhoneCallActionInput( | ||
action_config=NylasSendEmailActionConfig(), | ||
conversation_id="123", | ||
params=NylasSendEmailParameters( | ||
recipient_email="[email protected]", | ||
body="What up", | ||
subject="This is the bot", | ||
), | ||
_user_message_tracker=asyncio.Event(), | ||
twilio_sid="123", | ||
), | ||
), | ||
ActionFinish( | ||
action_type="action_nylas_send_email", | ||
action_output=ActionOutput( | ||
action_type="action_nylas_send_email", | ||
response=NylasSendEmailResponse(success=True), | ||
), | ||
), | ||
] | ||
) | ||
|
||
assert ( | ||
transcript.to_string() | ||
== """BOT: What up | ||
HUMAN: Send me an email you bot. My email is [email protected] | ||
ACTION_WORKER: params={'recipient_email': '[email protected]', 'body': 'What up', 'subject': 'This is the bot'} | ||
ACTION_WORKER: action_type='action_nylas_send_email' response={'success': True}""" | ||
) | ||
|
||
|
||
def test_transcript_to_string_no_phone_input(): | ||
transcript = Transcript( | ||
event_logs=[ | ||
Message(sender=Sender.BOT, text="What up"), | ||
Message( | ||
sender=Sender.HUMAN, | ||
text="Send me an email you bot. My email is [email protected]", | ||
), | ||
ActionStart( | ||
action_type="action_nylas_send_email", | ||
action_input=ActionInput( | ||
action_config=NylasSendEmailActionConfig(), | ||
conversation_id="123", | ||
params=NylasSendEmailParameters( | ||
recipient_email="[email protected]", | ||
body="What up", | ||
subject="This is the bot", | ||
), | ||
_user_message_tracker=asyncio.Event(), | ||
), | ||
), | ||
ActionFinish( | ||
action_type="action_nylas_send_email", | ||
action_output=ActionOutput( | ||
action_type="action_nylas_send_email", | ||
response=NylasSendEmailResponse(success=True), | ||
), | ||
), | ||
] | ||
) | ||
|
||
assert ( | ||
transcript.to_string() | ||
== """BOT: What up | ||
HUMAN: Send me an email you bot. My email is [email protected] | ||
ACTION_WORKER: params={'recipient_email': '[email protected]', 'body': 'What up', 'subject': 'This is the bot'} | ||
ACTION_WORKER: action_type='action_nylas_send_email' response={'success': True}""" | ||
) |
This file contains 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