|
| 1 | +import unittest |
| 2 | + |
| 3 | +from mock import patch |
| 4 | + |
| 5 | +from tests.tools import create_mock_json |
| 6 | +from twilio.rest.resources.conversations.conversations import ConversationsRoot |
| 7 | + |
| 8 | + |
| 9 | +AUTH = ("AC123", "token") |
| 10 | +BASE_URI = "https://conversations.twilio.com/v1" |
| 11 | +CONVERSATION_SID = "CVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" |
| 12 | + |
| 13 | + |
| 14 | +class ConversationTest(unittest.TestCase): |
| 15 | + @patch('twilio.rest.resources.base.make_twilio_request') |
| 16 | + def test_get(self, request): |
| 17 | + resp = create_mock_json('tests/resources/conversations/conversation_instance.json') |
| 18 | + resp.status_code = 200 |
| 19 | + request.return_value = resp |
| 20 | + |
| 21 | + uri = "{0}/Conversations/{1}".format(BASE_URI, CONVERSATION_SID) |
| 22 | + list_resource = ConversationsRoot(BASE_URI, AUTH) |
| 23 | + list_resource.get(CONVERSATION_SID) |
| 24 | + request.assert_called_with("GET", uri, use_json_extension=False, auth=AUTH) |
| 25 | + |
| 26 | + @patch('twilio.rest.resources.base.make_twilio_request') |
| 27 | + def test_list_in_progress(self, request): |
| 28 | + resp = create_mock_json('tests/resources/conversations/conversation_list.json') |
| 29 | + resp.status_code = 200 |
| 30 | + request.return_value = resp |
| 31 | + |
| 32 | + uri = "{0}/Conversations/InProgress".format(BASE_URI) |
| 33 | + list_resource = ConversationsRoot(BASE_URI, AUTH) |
| 34 | + list_resource.in_progress.list() |
| 35 | + request.assert_called_with("GET", uri, params={}, auth=AUTH, use_json_extension=False) |
| 36 | + |
| 37 | + @patch('twilio.rest.resources.base.make_twilio_request') |
| 38 | + def test_list_completed(self, request): |
| 39 | + resp = create_mock_json('tests/resources/conversations/conversation_list.json') |
| 40 | + resp.status_code = 200 |
| 41 | + request.return_value = resp |
| 42 | + |
| 43 | + uri = "{0}/Conversations/Completed".format(BASE_URI) |
| 44 | + list_resource = ConversationsRoot(BASE_URI, AUTH) |
| 45 | + list_resource.completed.list() |
| 46 | + request.assert_called_with("GET", uri, params={}, auth=AUTH, use_json_extension=False) |
0 commit comments