Skip to content

Commit

Permalink
Add tests for processing hangup verb in worker
Browse files Browse the repository at this point in the history
  • Loading branch information
Rudi Giesler committed Apr 10, 2015
1 parent d16d6ab commit 40fcf1c
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions vumi_twilio_api/tests/test_twilio_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,22 @@ def test_make_call_parsing_play_verb(self):
self.assertEqual(reply['from_addr'], '+12345')
self.assertEqual(reply['to_addr'], '+54321')

@inlineCallbacks
def test_make_call_parsing_hangup_verb(self):
response = twiml.Response()
response.hangup()
self.twiml_server.add_response('default.xml', response)

yield self._twilio_client_create_call(
'default.xml', from_='+12345', to='+54321')
[msg] = yield self.app_helper.wait_for_dispatched_outbound(1)
yield self.app_helper.dispatch_event(self.app_helper.make_ack(msg))
[_, reply] = yield self.app_helper.wait_for_dispatched_outbound(1)
self.assertEqual(
reply['session_event'], TransportUserMessage.SESSION_CLOSE)
self.assertEqual(reply['from_addr'], '+12345')
self.assertEqual(reply['to_addr'], '+54321')

@inlineCallbacks
def test_receive_call(self):
response = twiml.Response()
Expand Down Expand Up @@ -459,6 +475,22 @@ def test_receive_call_parsing_play_verb(self):
self.assertEqual(reply['helper_metadata']['voice']['url'], 'test_url')
self.assertEqual(reply['in_reply_to'], msg['message_id'])

@inlineCallbacks
def test_receive_call_parsing_hangup_verb(self):
response = twiml.Response()
response.hangup()
self.twiml_server.add_response('', response)

msg = self.app_helper.make_inbound(
'', from_addr='+54321', to_addr='+12345',
session_event=TransportUserMessage.SESSION_NEW)
yield self.app_helper.dispatch_inbound(msg)
[reply] = yield self.app_helper.wait_for_dispatched_outbound(1)

self.assertEqual(
reply['session_event'], TransportUserMessage.SESSION_CLOSE)
self.assertEqual(reply['in_reply_to'], msg['message_id'])

@inlineCallbacks
def test_outgoing_call_ended_status_callback(self):
self.twiml_server.add_response('callback.xml', twiml.Response())
Expand Down

0 comments on commit 40fcf1c

Please sign in to comment.