8000 Add Participant tests · srevenant/twilio-python@dbdb4a8 · GitHub
[go: up one dir, main page]

Skip to content

Commit dbdb4a8

Browse files
committed
Add Participant tests
1 parent 65b60d2 commit dbdb4a8

File tree

3 files changed

+87
-0
lines changed

3 files changed

+87
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import unittest
2+
3+
from mock import patch
4+
5+
from tests.tools import create_mock_json
6+
from twilio.rest.resources.conversations.participants import Participants
7+
8+
9+
AUTH = ("AC123", "token")
10+
BASE_URI = "https://conversations.twilio.com/v1"
11+
CONVERSATION_SID = "CVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
12+
PARTICIPANT_SID = "PAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
13+
14+
15+
class ParticipantTest(unittest.TestCase):
16+
@patch('twilio.rest.resources.base.make_twilio_request')
17+
def test_get(self, request):
18+
resp = create_mock_json('tests/resources/conversations/participant_instance.json')
19+
resp.status_code = 200
20+
request.return_value = resp
21+
22+
uri = "{0}/Conversations/{1}".format(BASE_URI, CONVERSATION_SID)
23+
expected = "{0}/Participants/{1}".format(uri, PARTICIPANT_SID)
24+
list_resource = Participants(uri, AUTH)
25+
list_resource.get(PARTICIPANT_SID)
26+
request.assert_called_with("GET", expected, use_json_extension=False, auth=AUTH)
27+
28+
@patch('twilio.rest.resources.base.make_twilio_request')
29+
def test_list_in_progress(self, request):
30+
resp = create_mock_json('tests/resources/conversations/participant_list.json')
31+
resp.status_code = 200
32+
request.return_value = resp
33+
34+
uri = "{0}/Conversations/{1}".format(BASE_URI, CONVERSATION_SID)
35+
expected = "{0}/Participants".format(uri)
36+
list_resource = Participants(uri, AUTH)
37+
list_resource.list()
38+
request.assert_called_with("GET", expected, params={}, auth=AUTH, use_json_extension=False)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"url": "https://conversations.stage.twilio.com/v1/Conversations/CVe42fecfaefadbb03cbe27d94e4cef8c2/Participants/PA97239ce0bff1491fa82986a543bcd9c9",
3+
"account_sid": "AC998c10b68cbfda9f67277f7d8f4439c9",
4+
"sid": "PA97239ce0bff1491fa82986a543bcd9c9",
5+
"address": "torkel2@AC998c10b68cbfda9f67277f7d8f4439c9.endpoint.twilio.com",
6+
"status": "disconnected",
7+
"conversation_sid": "CVe42fecfaefadbb03cbe27d94e4cef8c2",
8+
"date_created": "2015-05-13T23:03:12Z",
9+
"start_time": "2015-05-13T23:03:15Z",
10+
"end_time": "2015-05-13T23:14:40Z",
11+
"duration": 685
12+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"meta": {
3+
"key": "participants",
4+
"next_page_url": null,
5+
"url": "https://conversations.stage.twilio.com/v1/Conversations/CVe42fecfaefadbb03cbe27d94e4cef8c2/Participants?PageSize=50&Page=0",
6+
"previous_page_url": null,
7+
"first_page_url": "https://conversations.stage.twilio.com/v1/Conversations/CVe42fecfaefadbb03cbe27d94e4cef8c2/Participants?PageSize=50&Page=0",
8+
"page_size": 50,
9+
"page": 0
10+
},
11+
"participants": [
12+
{
13+
"url": "https://conversations.stage.twilio.com/v1/Conversations/CVe42fecfaefadbb03cbe27d94e4cef8c2/Participants/PA97239ce0bff1491fa82986a543bcd9c9",
14+
"account_sid": "AC998c10b68cbfda9f67277f7d8f4439c9",
15+
"sid": "PA97239ce0bff1491fa82986a543bcd9c9",
16+
"address": "torkel2@AC998c10b68cbfda9f67277f7d8f4439c9.endpoint.twilio.com",
17+
"status": "disconnected",
18+
"conversation_sid": "CVe42fecfaefadbb03cbe27d94e4cef8c2",
19+
"date_created": "2015-05-13T23:03:12Z",
20+
"start_time": "2015-05-13T23:03:15Z",
21+
"end_time": "2015-05-13T23:14:40Z",
22+
"duration": 685
23+
},
24+
{
25+
"url": "https://conversations.stage.twilio.com/v1/Conversations/CVe42fecfaefadbb03cbe27d94e4cef8c2/Participants/PA78810fba996f4087c8894b801669b9b2",
26+
"account_sid": "AC998c10b68cbfda9f67277f7d8f4439c9",
27+
"sid": "PA78810fba996f4087c8894b801669b9b2",
28+
"address": "torkel1@AC998c10b68cbfda9f67277f7d8f4439c9.endpoint.twilio.com",
29+
"status": "disconnected",
30+
"conversation_sid": "CVe42fecfaefadbb03cbe27d94e4cef8c2",
31+
"date_created": "2015-05-13T23:03:12Z",
32+
"start_time": "2015-05-13T23:03:15Z",
33+
"end_time": "2015-05-13T23:14:40Z",
34+
"duration": 685
35+
}
36+
]
37+
}

0 commit comments

Comments
 (0)
0