-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: d-telnyx <[email protected]>
- Loading branch information
Showing
2 changed files
with
54 additions
and
28 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
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 |
---|---|---|
|
@@ -67,94 +67,118 @@ class CallControlTest < Test::Unit::TestCase | |
@call = Call.new | ||
@call.id = "1234" | ||
@call.reject cause: "CALL_REJECTED" | ||
assert_requested :post, format_url(@call, "reject") | ||
assert_requested :post, format_action_url(@call, "reject") | ||
@call.answer | ||
assert_requested :post, format_url(@call, "answer") | ||
assert_requested :post, format_action_url(@call, "answer") | ||
@call.hangup | ||
assert_requested :post, format_url(@call, "hangup") | ||
assert_requested :post, format_action_url(@call, "hangup") | ||
@call.bridge call_control_id: SecureRandom.base64(20) | ||
assert_requested :post, format_url(@call, "bridge") | ||
assert_requested :post, format_action_url(@call, "bridge") | ||
@call.speak language: "en-US", voice: "female", payload: "Telnyx call control test" | ||
assert_requested :post, format_url(@call, "speak") | ||
assert_requested :post, format_action_url(@call, "speak") | ||
@call.fork_start call_control_id: SecureRandom.base64(20) | ||
assert_requested :post, format_url(@call, "fork_start") | ||
assert_requested :post, format_action_url(@call, "fork_start") | ||
@call.fork_stop | ||
assert_requested :post, format_url(@call, "fork_stop") | ||
assert_requested :post, format_action_url(@call, "fork_stop") | ||
@call.gather_using_audio audio_url: "https://audio.example.com" | ||
assert_requested :post, format_url(@call, "gather_using_audio") | ||
assert_requested :post, format_action_url(@call, "gather_using_audio") | ||
@call.gather_using_speak language: "en-US", voice: "female", payload: "Telnyx call control test" | ||
assert_requested :post, format_url(@call, "gather_using_speak") | ||
assert_requested :post, format_action_url(@call, "gather_using_speak") | ||
@call.playback_start audio_url: "https://audio.example.com" | ||
assert_requested :post, format_url(@call, "playback_start") | ||
assert_requested :post, format_action_url(@call, "playback_start") | ||
@call.playback_stop | ||
assert_requested :post, format_url(@call, "playback_stop") | ||
assert_requested :post, format_action_url(@call, "playback_stop") | ||
@call.send_dtmf digits: "1www2WABCDw9" | ||
assert_requested :post, format_url(@call, "send_dtmf") | ||
assert_requested :post, format_action_url(@call, "send_dtmf") | ||
@call.transfer to: "+15552223333" | ||
assert_requested :post, format_url(@call, "transfer") | ||
assert_requested :post, format_action_url(@call, "transfer") | ||
end | ||
end | ||
|
||
context "commands" do | ||
should "reject" do | ||
@call.reject cause: "CALL_REJECTED" | ||
assert_requested :post, format_url(@call, "reject") | ||
assert_requested :post, format_action_url(@call, "reject") | ||
end | ||
should "answer" do | ||
@call.answer | ||
assert_requested :post, format_url(@call, "answer") | ||
assert_requested :post, format_action_url(@call, "answer") | ||
end | ||
should "hangup" do | ||
@call.hangup | ||
assert_requested :post, format_url(@call, "hangup") | ||
assert_requested :post, format_action_url(@call, "hangup") | ||
end | ||
should "bridge" do | ||
@call.bridge call_control_id: SecureRandom.base64(20) | ||
assert_requested :post, format_url(@call, "bridge") | ||
assert_requested :post, format_action_url(@call, "bridge") | ||
end | ||
should "speak" do | ||
@call.speak language: "en-US", voice: "female", payload: "Telnyx call control test" | ||
assert_requested :post, format_url(@call, "speak") | ||
assert_requested :post, format_action_url(@call, "speak") | ||
end | ||
should "start fork" do | ||
@call.fork_start call_control_id: SecureRandom.base64(20) | ||
assert_requested :post, format_url(@call, "fork_start") | ||
assert_requested :post, format_action_url(@call, "fork_start") | ||
end | ||
should "stop fork" do | ||
@call.fork_stop | ||
assert_requested :post, format_url(@call, "fork_stop") | ||
assert_requested :post, format_action_url(@call, "fork_stop") | ||
end | ||
should "gather using audio" do | ||
@call.gather_using_audio audio_url: "https://audio.example.com" | ||
assert_requested :post, format_url(@call, "gather_using_audio") | ||
assert_requested :post, format_action_url(@call, "gather_using_audio") | ||
end | ||
should "gather using speak" do | ||
@call.gather_using_speak language: "en-US", voice: "female", payload: "Telnyx call control test" | ||
assert_requested :post, format_url(@call, "gather_using_speak") | ||
assert_requested :post, format_action_url(@call, "gather_using_speak") | ||
end | ||
should "playback start" do | ||
@call.playback_start audio_url: "https://audio.example.com" | ||
assert_requested :post, format_url(@call, "playback_start") | ||
assert_requested :post, format_action_url(@call, "playback_start") | ||
end | ||
should "playback stop" do | ||
@call.playback_stop | ||
assert_requested :post, format_url(@call, "playback_stop") | ||
assert_requested :post, format_action_url(@call, "playback_stop") | ||
end | ||
should "send dtmf" do | ||
@call.send_dtmf digits: "1www2WABCDw9" | ||
assert_requested :post, format_url(@call, "send_dtmf") | ||
assert_requested :post, format_action_url(@call, "send_dtmf") | ||
end | ||
should "transfer" do | ||
@call.transfer to: "+15552223333" | ||
assert_requested :post, format_url(@call, "transfer") | ||
assert_requested :post, format_action_url(@call, "transfer") | ||
end | ||
should "start transcription" do | ||
@call.transcription_start | ||
assert_requested :post, format_action_url(@call, "transcription_start") | ||
end | ||
should "end transcription" do | ||
@call.transcription_stop | ||
assert_requested :post, format_action_url(@call, "transcription_stop") | ||
end | ||
should "pause recording" do | ||
@call.record_pause | ||
assert_requested :post, format_action_url(@call, "record_pause") | ||
end | ||
should "resume recording" do | ||
@call.record_resume | ||
assert_requested :post, format_action_url(@call, "record_resume") | ||
end | ||
should "gather stop" do | ||
@call.gather_stop | ||
assert_requested :post, format_action_url(@call, "gather_stop") | ||
end | ||
should "refer" do | ||
@call.refer sip_address: "sip:[email protected]" | ||
assert_requested :post, format_action_url(@call, "refer") | ||
end | ||
end | ||
|
||
def create_call | ||
Telnyx::Call.create connection_id: "12345", to: "+15550001111", from: "+15550002222", cause: "test" | ||
end | ||
|
||
def format_url(call, action) | ||
def format_action_url(call, action) | ||
"#{Telnyx.api_base}/v2/calls/#{call.call_control_id}/actions/#{action}" | ||
end | ||
end | ||
|