From 7b11d5ffe962b0596214cad1970c35db6fec49fe Mon Sep 17 00:00:00 2001 From: Jingming Niu Date: Mon, 2 Nov 2015 15:42:26 -0800 Subject: [PATCH 1/3] Revert "Merge remote-tracking branch 'origin/signal-beta' into edge" This reverts commit 6bf0e94e2113e3564f7110fbdbe376a89d5d06b5, reversing changes made to 07bf63985cd63075ae44216cd4d39e40c7318e22. --- tests/requirements.txt | 1 - tests/test_access_token.py | 81 ---------- tests/test_make_request.py | 216 +++++++++++--------------- tests/test_signing_keys.py | 13 -- twilio/access_token.py | 70 --------- twilio/jwt/__init__.py | 7 +- twilio/rest/client.py | 2 - twilio/rest/resources/__init__.py | 2 - twilio/rest/resources/accounts.py | 2 - twilio/rest/resources/base.py | 3 +- twilio/rest/resources/signing_keys.py | 75 --------- 11 files changed, 98 insertions(+), 374 deletions(-) delete mode 100644 tests/test_access_token.py delete mode 100644 tests/test_signing_keys.py delete mode 100644 twilio/access_token.py delete mode 100644 twilio/rest/resources/signing_keys.py diff --git a/tests/requirements.txt b/tests/requirements.txt index 5f04d6e39f..9262910394 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,5 +1,4 @@ sphinx -httplib2==0.8 mock==0.8.0 nose coverage diff --git a/tests/test_access_token.py b/tests/test_access_token.py deleted file mode 100644 index 3f1379ea03..0000000000 --- a/tests/test_access_token.py +++ /dev/null @@ -1,81 +0,0 @@ -import unittest - -from nose.tools import assert_equal -from twilio.jwt import decode -from twilio.access_token import AccessToken - -ACCOUNT_SID = 'AC123' -SIGNING_KEY_SID = 'SK123' - - -# python2.6 support -def assert_is_not_none(obj): - assert obj is not None, '%r is None' % obj - - -class AccessTokenTest(unittest.TestCase): - def _validate_claims(self, payload): - assert_equal(SIGNING_KEY_SID, payload['iss']) - assert_equal(ACCOUNT_SID, payload['sub']) - assert_is_not_none(payload['nbf']) - assert_is_not_none(payload['exp']) - assert_equal(payload['nbf'] + 3600, payload['exp']) - assert_is_not_none(payload['jti']) - assert_equal('{0}-{1}'.format(payload['iss'], payload['nbf']), - payload['jti']) - assert_is_not_none(payload['grants']) - - def test_empty_grants(self): - scat = AccessToken(SIGNING_KEY_SID, ACCOUNT_SID, 'secret') - token = str(scat) - assert_is_not_none(token) - payload = decode(token, 'secret') - self._validate_claims(payload) - assert_equal([], payload['grants']) - - def test_single_grant(self): - scat = AccessToken(SIGNING_KEY_SID, ACCOUNT_SID, 'secret') - scat.add_grant('https://api.twilio.com/**') - token = str(scat) - assert_is_not_none(token) - payload = decode(token, 'secret') - self._validate_claims(payload) - assert_equal(1, len(payload['grants'])) - assert_equal('https://api.twilio.com/**', payload['grants'][0]['res']) - assert_equal(['*'], payload['grants'][0]['act']) - - def test_endpoint_grant(self): - scat = AccessToken(SIGNING_KEY_SID, ACCOUNT_SID, 'secret') - scat.add_endpoint_grant('bob') - token = str(scat) - assert_is_not_none(token) - payload = decode(token, 'secret') - self._validate_claims(payload) - assert_equal(1, len(payload['grants'])) - assert_equal('sip:bob@AC123.endpoint.twilio.com', - payload['grants'][0]['res']) - assert_equal(['listen', 'invite'], payload['grants'][0]['act']) - - def test_rest_grant(self): - scat = AccessToken(SIGNING_KEY_SID, ACCOUNT_SID, 'secret') - scat.add_rest_grant('/Apps') - token = str(scat) - assert_is_not_none(token) - payload = decode(token, 'secret') - self._validate_claims(payload) - assert_equal(1, len(payload['grants'])) - assert_equal('https://api.twilio.com/2010-04-01/Accounts/AC123/Apps', - payload['grants'][0]['res']) - assert_equal(['*'], payload['grants'][0]['act']) - - def test_enable_nts(self): - scat = AccessToken(SIGNING_KEY_SID, ACCOUNT_SID, 'secret') - scat.enable_nts() - token = str(scat) - assert_is_not_none(token) - payload = decode(token, 'secret') - self._validate_claims(payload) - assert_equal(1, len(payload['grants'])) - assert_equal('https://api.twilio.com/2010-04-01/Accounts/AC123/Tokens.json', - payload['grants'][0]['res']) - assert_equal(['POST'], payload['grants'][0]['act']) diff --git a/tests/test_make_request.py b/tests/test_make_request.py index 6348fea500..d1e4d5d800 100644 --- a/tests/test_make_request.py +++ b/tests/test_make_request.py @@ -3,21 +3,16 @@ Uses the awesome httpbin.org to validate responses """ -import base64 import platform -import unittest -from httplib2 import Response +import twilio from nose.tools import assert_equal, raises from mock import patch, Mock, ANY - -import twilio from twilio.rest.exceptions import TwilioRestException from twilio.rest.resources.base import make_request, make_twilio_request from twilio.rest.resources.connection import Connection from twilio.rest.resources.connection import PROXY_TYPE_SOCKS5 - get_headers = { "User-Agent": "twilio-python/{version} (Python {python_version})".format( version=twilio.__version__, @@ -31,118 +26,97 @@ post_headers["Content-Type"] = "application/x-www-form-urlencoded" -class MakeRequestTest(unittest.TestCase): - - @patch('twilio.rest.resources.base.Response') - @patch('httplib2.Http') - def test_get_params(self, http_mock, response_mock): - http = Mock() - http.request.return_value = (Mock(), Mock()) - http_mock.return_value = http - make_request("GET", "http://httpbin.org/get", params={"hey": "you"}) - http.request.assert_called_with("http://httpbin.org/get?hey=you", "GET", - body=None, headers=None) - - @patch('twilio.rest.resources.base.Response') - @patch('httplib2.Http') - def test_get_extra_params(self, http_mock, response_mock): - http = Mock() - http.request.return_value = (Mock(), Mock()) - http_mock.return_value = http - make_request("GET", "http://httpbin.org/get?foo=bar", params={"hey": "you"}) - http.request.assert_called_with("http://httpbin.org/get?foo=bar&hey=you", "GET", - body=None, headers=None) - - @patch('twilio.rest.resources.base.Response') - @patch('httplib2.Http') - def test_resp_uri(self, http_mock, response_mock): - http = Mock() - http.request.return_value = (Mock(), Mock()) - http_mock.return_value = http - make_request("GET", "http://httpbin.org/get") - http.request.assert_called_with("http://httpbin.org/get", "GET", - body=None, headers=None) - - @patch('twilio.rest.resources.base.Response') - @patch('httplib2.Http') - def test_sequence_data(self, http_mock, response_mock): - http = Mock() - http.request.return_value = (Mock(), Mock()) - http_mock.return_value = http - make_request( - "POST", - "http://httpbin.org/post", - data={"a_list": ["here", "is", "some", "stuff"]}, - ) - http.request.assert_called_with( - "http://httpbin.org/post", - "POST", - body="a_list=here&a_list=is&a_list=some&a_list=stuff", - headers=None, - ) - - @patch('twilio.rest.resources.base.Response') - @patch('httplib2.Http._conn_request') - def test_make_request_basic_auth(self, mock_request, mock_response): - response = Response({ - 'status': '401', - 'WWW-Authenticate': 'Basic realm="Twilio API"' - }) - mock_request.side_effect = [(response, Mock()), (Mock(), Mock())] - make_request('GET', 'http://httpbin.org/get', auth=('AC123', 'AuthToken')) - - auth = "{0}:{1}".format('AC123', 'AuthToken') - encoded_auth = auth.encode('utf-8') - b64_auth = base64.b64encode(encoded_auth) - - mock_request.assert_called_with( - ANY, - '/get', - 'GET', - None, - { - 'accept-encoding': 'gzip, deflate', - 'authorization': 'Basic {0}'.format(b64_auth.decode('utf-8')), - 'user-agent': ANY, - } - ) - - @patch('twilio.rest.resources.base.make_request') - def test_make_twilio_request_headers(self, mock): - url = "http://random/url" - make_twilio_request("POST", url, use_json_extension=True) - mock.assert_called_with("POST", "http://random/url.json", - headers=post_headers) - - @raises(TwilioRestException) - @patch('twilio.rest.resources.base.make_request') - def test_make_twilio_request_bad_data(self, mock): - resp = Mock() - resp.ok = False - resp.return_value = "error" - mock.return_value = resp - - url = "http://random/url" - make_twilio_request("POST", url) - mock.assert_called_with("POST", "http://random/url.json", - headers=post_headers) - - @patch('twilio.rest.resources.base.Response') - @patch('httplib2.Http') - def test_proxy_info(self, http_mock, resp_mock): - http = Mock() - http.request.return_value = (Mock(), Mock()) - http_mock.return_value = http - Connection.set_proxy_info( - 'example.com', - 8080, - proxy_type=PROXY_TYPE_SOCKS5, - ) - make_request("GET", "http://httpbin.org/get") - http_mock.assert_called_with(timeout=None, ca_certs=ANY, proxy_info=ANY) - http.request.assert_called_with("http://httpbin.org/get", "GET", - body=None, headers=None) - proxy_info = http_mock.call_args[1]['proxy_info'] - assert_equal(proxy_info.proxy_host, 'example.com') - assert_equal(proxy_info.proxy_port, 8080) - assert_equal(proxy_info.proxy_type, PROXY_TYPE_SOCKS5) +@patch('twilio.rest.resources.base.Response') +@patch('httplib2.Http') +def test_get_params(http_mock, response_mock): + http = Mock() + http.request.return_value = (Mock(), Mock()) + http_mock.return_value = http + make_request("GET", "http://httpbin.org/get", params={"hey": "you"}) + http.request.assert_called_with("http://httpbin.org/get?hey=you", "GET", + body=None, headers=None) + + +@patch('twilio.rest.resources.base.Response') +@patch('httplib2.Http') +def test_get_extra_params(http_mock, response_mock): + http = Mock() + http.request.return_value = (Mock(), Mock()) + http_mock.return_value = http + make_request("GET", "http://httpbin.org/get?foo=bar", params={"hey": "you"}) + http.request.assert_called_with("http://httpbin.org/get?foo=bar&hey=you", "GET", + body=None, headers=None) + + +@patch('twilio.rest.resources.base.Response') +@patch('httplib2.Http') +def test_resp_uri(http_mock, response_mock): + http = Mock() + http.request.return_value = (Mock(), Mock()) + http_mock.return_value = http + make_request("GET", "http://httpbin.org/get") + http.request.assert_called_with("http://httpbin.org/get", "GET", + body=None, headers=None) + + +@patch('twilio.rest.resources.base.Response') +@patch('httplib2.Http') +def test_sequence_data(http_mock, response_mock): + http = Mock() + http.request.return_value = (Mock(), Mock()) + http_mock.return_value = http + make_request( + "POST", + "http://httpbin.org/post", + data={"a_list": ["here", "is", "some", "stuff"]}, + ) + http.request.assert_called_with( + "http://httpbin.org/post", + "POST", + body="a_list=here&a_list=is&a_list=some&a_list=stuff", + headers=None, + ) + + +@patch('twilio.rest.resources.base.make_request') +def test_make_twilio_request_headers(mock): + url = "http://random/url" + make_twilio_request("POST", url, use_json_extension=True) + mock.assert_called_with("POST", "http://random/url.json", + headers=post_headers) + + +@raises(TwilioRestException) +@patch('twilio.rest.resources.base.make_request') +def test_make_twilio_request_bad_data(mock): + resp = Mock() + resp.ok = False + resp.return_value = "error" + mock.return_value = resp + + url = "http://random/url" + make_twilio_request("POST", url) + mock.assert_called_with("POST", "http://random/url.json", + headers=post_headers) + + +@patch('twilio.rest.resources.base.Response') +@patch('httplib2.Http') +def test_proxy_info(http_mock, resp_mock): + http = Mock() + http.request.return_value = (Mock(), Mock()) + http_mock.return_value = http + Connection.set_proxy_info( + 'example.com', + 8080, + proxy_type=PROXY_TYPE_SOCKS5, + ) + make_request("GET", "http://httpbin.org/get") + http_mock.assert_called_with(timeout=None, ca_certs=ANY, proxy_info=ANY) + http.request.assert_called_with("http://httpbin.org/get", "GET", + body=None, headers=None) + proxy_info = http_mock.call_args[1]['proxy_info'] + assert_equal(proxy_info.proxy_host, 'example.com') + assert_equal(proxy_info.proxy_port, 8080) + assert_equal(proxy_info.proxy_type, PROXY_TYPE_SOCKS5) +>>>>>>> parent of 6bf0e94... Merge remote-tracking branch 'origin/signal-beta' into edge diff --git a/tests/test_signing_keys.py b/tests/test_signing_keys.py deleted file mode 100644 index fa0585e29d..0000000000 --- a/tests/test_signing_keys.py +++ /dev/null @@ -1,13 +0,0 @@ -import unittest -from nose.tools import assert_raises -from twilio.rest.resources.signing_keys import SigningKeys - - -class SigningKeysTest(unittest.TestCase): - - def test_list(self): - """ - Tests the Error part - """ - keys = SigningKeys(self, [], {}) - assert_raises(AttributeError, keys.list) diff --git a/twilio/access_token.py b/twilio/access_token.py deleted file mode 100644 index 1ff86be43c..0000000000 --- a/twilio/access_token.py +++ /dev/null @@ -1,70 +0,0 @@ -import time -import jwt - -ALL = '*' - -# HTTP Actions -HTTP_DELETE = 'DELETE' -HTTP_GET = 'GET' -HTTP_POST = 'POST' -HTTP_PUT = 'PUT' - -# Client Actions -CLIENT_LISTEN = 'listen' -CLIENT_INVITE = 'invite' - - -class AccessToken(object): - def __init__(self, signing_key_sid, account_sid, secret, ttl=3600): - self.signing_key_sid = signing_key_sid - self.account_sid = account_sid - self.secret = secret - self.ttl = ttl - self.grants = [] - - def add_grant(self, resource, actions=ALL): - if not isinstance(actions, list): - actions = [actions] - - self.grants.append({ - 'res': resource, - 'act': actions, - }) - return self - - def add_rest_grant(self, uri, actions=ALL): - resource = 'https://api.twilio.com/2010-04-01/Accounts/{0}/{1}'.format( - self.account_sid, - uri.lstrip('/'), - ) - return self.add_grant(resource, actions) - - def add_endpoint_grant(self, endpoint, actions=None): - actions = actions or [CLIENT_LISTEN, CLIENT_INVITE] - resource = 'sip:{0}@{1}.endpoint.twilio.com'.format( - endpoint, - self.account_sid - ) - return self.add_grant(resource, actions) - - def enable_nts(self): - return self.add_rest_grant('/Tokens.json', HTTP_POST) - - def to_jwt(self): - now = int(time.time()) - headers = { - "cty": "twilio-sat;v=1" - } - payload = { - "jti": '{0}-{1}'.format(self.signing_key_sid, now), - "iss": self.signing_key_sid, - "sub": self.account_sid, - "nbf": now, - "exp": now + self.ttl, - "grants": self.grants - } - - return jwt.encode(payload, self.secret, headers=headers) - - def __str__(self): - return self.to_jwt().decode('utf-8') diff --git a/twilio/jwt/__init__.py b/twilio/jwt/__init__.py index f87ba5365f..edb4062433 100644 --- a/twilio/jwt/__init__.py +++ b/twilio/jwt/__init__.py @@ -6,8 +6,7 @@ import base64 import hashlib import hmac - -from six import b +from six import text_type, b # default text to binary representation conversion @@ -42,11 +41,9 @@ def base64url_encode(input): return base64.urlsafe_b64encode(input).decode('utf-8').replace('=', '') -def encode(payload, key, algorithm='HS256', headers=None): +def encode(payload, key, algorithm='HS256'): segments = [] header = {"typ": "JWT", "alg": algorithm} - if headers: - header.update(headers) segments.append(base64url_encode(binary(json.dumps(header)))) segments.append(base64url_encode(binary(json.dumps(payload)))) sign_input = '.'.join(segments) diff --git a/twilio/rest/client.py b/twilio/rest/client.py index bc3c45731f..27f09067c5 100644 --- a/twilio/rest/client.py +++ b/twilio/rest/client.py @@ -21,7 +21,6 @@ Queues, Recordings, Sandboxes, - SigningKeys, Sip, Sms, Tokens, @@ -75,7 +74,6 @@ def __init__(self, account=None, token=None, base="https://api.twilio.com", self.messages = Messages(self.account_uri, self.auth, timeout) self.media = MediaList(self.account_uri, self.auth, timeout) self.sip = Sip(self.account_uri, self.auth, timeout) - self.signing_keys = SigningKeys(self.account_uri, self.auth, timeout) self.tokens = Tokens(self.account_uri, self.auth, timeout) self.keys = Keys(self.account_uri, self.auth, timeout) diff --git a/twilio/rest/resources/__init__.py b/twilio/rest/resources/__init__.py index 74d0210556..cf25e73bd2 100644 --- a/twilio/rest/resources/__init__.py +++ b/twilio/rest/resources/__init__.py @@ -44,8 +44,6 @@ from .media import Media, MediaList -from .signing_keys import SigningKey, SigningKeys - from .sip import Sip from .task_router import ( diff --git a/twilio/rest/resources/accounts.py b/twilio/rest/resources/accounts.py index 0fafd507dd..78c2f65370 100644 --- a/twilio/rest/resources/accounts.py +++ b/twilio/rest/resources/accounts.py @@ -14,7 +14,6 @@ from .messages import Messages from .media import MediaList from .sip import Sip -from .signing_keys import SigningKeys class Account(InstanceResource): @@ -43,7 +42,6 @@ class Account(InstanceResource): UsageTriggers, MediaList, Messages, - SigningKeys, Sip, Keys, ] diff --git a/twilio/rest/resources/base.py b/twilio/rest/resources/base.py index 5a16ec5c12..67285c11cc 100644 --- a/twilio/rest/resources/base.py +++ b/twilio/rest/resources/base.py @@ -8,10 +8,10 @@ binary_type, iteritems ) - from ...compat import urlencode from ...compat import urlparse from ...compat import urlunparse + from ... import __version__ from ...exceptions import TwilioException from ..exceptions import TwilioRestException @@ -24,7 +24,6 @@ UNSET_TIMEOUT, ) - logger = logging.getLogger('twilio') diff --git a/twilio/rest/resources/signing_keys.py b/twilio/rest/resources/signing_keys.py deleted file mode 100644 index 8eaec3eae6..0000000000 --- a/twilio/rest/resources/signing_keys.py +++ /dev/null @@ -1,75 +0,0 @@ -from twilio.rest.resources.base import InstanceResource, ListResource - - -class SigningKey(InstanceResource): - """ - A signing key resource. - See https://www.twilio.com/docs/api/rest/signing-keys - - .. attribute:: sid - - The unique ID for this signing key. - - .. attribute:: friendly_name - - A human-readable description of this signing key. - - .. attribute:: secret - - This signing key's secret. - - .. attribute:: date_created - - The date this signing key was created, given as UTC in ISO 8601 format. - - .. attribute:: date_updated - - The date this singing key was last updated, given as UTC in ISO 8601 - format. - """ - - def update(self, **kwargs): - """ - Update this signing key - """ - return self.parent.update(self.name, **kwargs) - - def delete(self): - """ - Delete this signing key - """ - return self.parent.delete(self.name) - - -class SigningKeys(ListResource): - name = "SigningKeys" - key = "signing_keys" - instance = SigningKey - - def create(self, **kwargs): - """ - Create a :class:`SigningKey` with any of these optional parameters. - - :param friendly_name: A human readable description of the signing key. - """ - return self.create_instance(kwargs) - - def update(self, sid, **kwargs): - """ - Update a :class:`SigningKey` with the given parameters. - - All the parameters are describe above in :meth:`create` - """ - return self.update_instance(sid, kwargs) - - def delete(self, sid): - """ - Delete a :class:`SigningKey` - """ - return self.delete_instance(sid) - - def list(self, **kw): - """ - List is not supported, hence raises an Error - """ - raise AttributeError("SigningKeys do not support lists()") From 20f2ed63f2e472001a5a44d062046b95b052bc09 Mon Sep 17 00:00:00 2001 From: Jingming Niu Date: Mon, 2 Nov 2015 15:44:32 -0800 Subject: [PATCH 2/3] Revert "Merge branch 'conversations' into edge" This reverts commit ce08b3dead4d28d1261f703c4f729995a85d1a25, reversing changes made to 9f62d187176bfa6f7161d1166c8a984c7fea5d89. --- tests/conversations/__init__.py | 0 tests/conversations/test_client.py | 14 ----- tests/conversations/test_conversations.py | 46 --------------- tests/conversations/test_participants.py | 38 ------------ tests/ip_messaging/__init__.py | 0 tests/ip_messaging/test_channels.py | 52 ----------------- tests/ip_messaging/test_credentials.py | 52 ----------------- tests/ip_messaging/test_members.py | 52 ----------------- tests/ip_messaging/test_messages.py | 52 ----------------- tests/ip_messaging/test_roles.py | 36 ------------ tests/ip_messaging/test_services.py | 52 ----------------- tests/ip_messaging/test_users.py | 52 ----------------- .../conversations/conversation_instance.json | 13 ----- .../conversations/conversation_list.json | 39 ------------- .../conversations/participant_instance.json | 12 ---- .../conversations/participant_list.json | 37 ------------ .../ip_messaging/channel_instance.json | 15 ----- .../ip_messaging/credential_instance.json | 8 --- .../ip_messaging/member_instance.json | 9 --- .../ip_messaging/message_instance.json | 12 ---- .../resources/ip_messaging/role_instance.json | 11 ---- .../ip_messaging/service_instance.json | 17 ------ .../resources/ip_messaging/user_instance.json | 10 ---- twilio/rest/conversations.py | 28 --------- twilio/rest/ip_messaging.py | 29 ---------- twilio/rest/resources/base.py | 2 +- .../rest/resources/conversations/__init__.py | 0 .../resources/conversations/conversations.py | 58 ------------------- .../resources/conversations/participants.py | 34 ----------- .../rest/resources/ip_messaging/__init__.py | 34 ----------- .../rest/resources/ip_messaging/channels.py | 54 ----------------- .../resources/ip_messaging/credentials.py | 53 ----------------- twilio/rest/resources/ip_messaging/members.py | 49 ---------------- .../rest/resources/ip_messaging/messages.py | 49 ---------------- twilio/rest/resources/ip_messaging/roles.py | 37 ------------ .../rest/resources/ip_messaging/services.py | 57 ------------------ twilio/rest/resources/ip_messaging/users.py | 49 ---------------- 37 files changed, 1 insertion(+), 1161 deletions(-) delete mode 100644 tests/conversations/__init__.py delete mode 100644 tests/conversations/test_client.py delete mode 100644 tests/conversations/test_conversations.py delete mode 100644 tests/conversations/test_participants.py delete mode 100644 tests/ip_messaging/__init__.py delete mode 100644 tests/ip_messaging/test_channels.py delete mode 100644 tests/ip_messaging/test_credentials.py delete mode 100644 tests/ip_messaging/test_members.py delete mode 100644 tests/ip_messaging/test_messages.py delete mode 100644 tests/ip_messaging/test_roles.py delete mode 100644 tests/ip_messaging/test_services.py delete mode 100644 tests/ip_messaging/test_users.py delete mode 100644 tests/resources/conversations/conversation_instance.json delete mode 100644 tests/resources/conversations/conversation_list.json delete mode 100644 tests/resources/conversations/participant_instance.json delete mode 100644 tests/resources/conversations/participant_list.json delete mode 100644 tests/resources/ip_messaging/channel_instance.json delete mode 100644 tests/resources/ip_messaging/credential_instance.json delete mode 100644 tests/resources/ip_messaging/member_instance.json delete mode 100644 tests/resources/ip_messaging/message_instance.json delete mode 100644 tests/resources/ip_messaging/role_instance.json delete mode 100644 tests/resources/ip_messaging/service_instance.json delete mode 100644 tests/resources/ip_messaging/user_instance.json delete mode 100644 twilio/rest/conversations.py delete mode 100644 twilio/rest/ip_messaging.py delete mode 100644 twilio/rest/resources/conversations/__init__.py delete mode 100644 twilio/rest/resources/conversations/conversations.py delete mode 100644 twilio/rest/resources/conversations/participants.py delete mode 100644 twilio/rest/resources/ip_messaging/__init__.py delete mode 100644 twilio/rest/resources/ip_messaging/channels.py delete mode 100644 twilio/rest/resources/ip_messaging/credentials.py delete mode 100644 twilio/rest/resources/ip_messaging/members.py delete mode 100644 twilio/rest/resources/ip_messaging/messages.py delete mode 100644 twilio/rest/resources/ip_messaging/roles.py delete mode 100644 twilio/rest/resources/ip_messaging/services.py delete mode 100644 twilio/rest/resources/ip_messaging/users.py diff --git a/tests/conversations/__init__.py b/tests/conversations/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/conversations/test_client.py b/tests/conversations/test_client.py deleted file mode 100644 index d19545c937..0000000000 --- a/tests/conversations/test_client.py +++ /dev/null @@ -1,14 +0,0 @@ -from mock import patch - -from tests.tools import create_mock_json -from twilio.rest.conversations import TwilioConversationsClient - - -@patch("twilio.rest.resources.base.make_twilio_request") -def test_conversations(mock): - client = TwilioConversationsClient("ACCOUNT_SID", "AUTH_TOKEN") - resp = create_mock_json("tests/resources/conversations/conversation_instance.json") - mock.return_value = resp - client.conversations.get("CV4bbc4afc943cd2a5d29f0ce01c5656db") - uri = "https://conversations.twilio.com/v1/Conversations/CV4bbc4afc943cd2a5d29f0ce01c5656db" - mock.assert_called_with("GET", uri, auth=("ACCOUNT_SID", "AUTH_TOKEN"), use_json_extension=False) diff --git a/tests/conversations/test_conversations.py b/tests/conversations/test_conversations.py deleted file mode 100644 index f9fced201e..0000000000 --- a/tests/conversations/test_conversations.py +++ /dev/null @@ -1,46 +0,0 @@ -import unittest - -from mock import patch - -from tests.tools import create_mock_json -from twilio.rest.resources.conversations.conversations import ConversationsRoot - - -AUTH = ("AC123", "token") -BASE_URI = "https://conversations.twilio.com/v1" -CONVERSATION_SID = "CVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - - -class ConversationTest(unittest.TestCase): - @patch('twilio.rest.resources.base.make_twilio_request') - def test_get(self, request): - resp = create_mock_json('tests/resources/conversations/conversation_instance.json') - resp.status_code = 200 - request.return_value = resp - - uri = "{0}/Conversations/{1}".format(BASE_URI, CONVERSATION_SID) - list_resource = ConversationsRoot(BASE_URI, AUTH) - list_resource.get(CONVERSATION_SID) - request.assert_called_with("GET", uri, use_json_extension=False, auth=AUTH) - - @patch('twilio.rest.resources.base.make_twilio_request') - def test_list_in_progress(self, request): - resp = create_mock_json('tests/resources/conversations/conversation_list.json') - resp.status_code = 200 - request.return_value = resp - - uri = "{0}/Conversations/InProgress".format(BASE_URI) - list_resource = ConversationsRoot(BASE_URI, AUTH) - list_resource.in_progress.list() - request.assert_called_with("GET", uri, params={}, auth=AUTH, use_json_extension=False) - - @patch('twilio.rest.resources.base.make_twilio_request') - def test_list_completed(self, request): - resp = create_mock_json('tests/resources/conversations/conversation_list.json') - resp.status_code = 200 - request.return_value = resp - - uri = "{0}/Conversations/Completed".format(BASE_URI) - list_resource = ConversationsRoot(BASE_URI, AUTH) - list_resource.completed.list() - request.assert_called_with("GET", uri, params={}, auth=AUTH, use_json_extension=False) diff --git a/tests/conversations/test_participants.py b/tests/conversations/test_participants.py deleted file mode 100644 index 6e1d214f7c..0000000000 --- a/tests/conversations/test_participants.py +++ /dev/null @@ -1,38 +0,0 @@ -import unittest - -from mock import patch - -from tests.tools import create_mock_json -from twilio.rest.resources.conversations.participants import Participants - - -AUTH = ("AC123", "token") -BASE_URI = "https://conversations.twilio.com/v1" -CONVERSATION_SID = "CVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" -PARTICIPANT_SID = "PAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - - -class ParticipantTest(unittest.TestCase): - @patch('twilio.rest.resources.base.make_twilio_request') - def test_get(self, request): - resp = create_mock_json('tests/resources/conversations/participant_instance.json') - resp.status_code = 200 - request.return_value = resp - - uri = "{0}/Conversations/{1}".format(BASE_URI, CONVERSATION_SID) - expected = "{0}/Participants/{1}".format(uri, PARTICIPANT_SID) - list_resource = Participants(uri, AUTH) - list_resource.get(PARTICIPANT_SID) - request.assert_called_with("GET", expected, use_json_extension=False, auth=AUTH) - - @patch('twilio.rest.resources.base.make_twilio_request') - def test_list_in_progress(self, request): - resp = create_mock_json('tests/resources/conversations/participant_list.json') - resp.status_code = 200 - request.return_value = resp - - uri = "{0}/Conversations/{1}".format(BASE_URI, CONVERSATION_SID) - expected = "{0}/Participants".format(uri) - list_resource = Participants(uri, AUTH) - list_resource.list() - request.assert_called_with("GET", expected, params={}, auth=AUTH, use_json_extension=False) diff --git a/tests/ip_messaging/__init__.py b/tests/ip_messaging/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/ip_messaging/test_channels.py b/tests/ip_messaging/test_channels.py deleted file mode 100644 index 61faa2dfc6..0000000000 --- a/tests/ip_messaging/test_channels.py +++ /dev/null @@ -1,52 +0,0 @@ -from mock import patch, Mock -from twilio.rest.resources.ip_messaging import Channels, Channel -from tests.tools import create_mock_json - -BASE_URI = "https://ip-messaging.twilio.com/v1/Services/ISxxx" -ACCOUNT_SID = "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" -AUTH = (ACCOUNT_SID, "token") -CHANNEL_SID = "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - -list_resource = Channels(BASE_URI, AUTH) - - -@patch("twilio.rest.resources.base.make_twilio_request") -def test_create_channel(mock): - resp = create_mock_json("tests/resources/ip_messaging/channel_instance.json") - resp.status_code = 201 - mock.return_value = resp - - uri = "%s/Channels" % (BASE_URI) - list_resource.create(friendly_name='TestChannel') - exp_params = { - 'FriendlyName': "TestChannel" - } - - mock.assert_called_with("POST", uri, data=exp_params, auth=AUTH, - use_json_extension=False) - - -@patch("twilio.rest.resources.base.make_twilio_request") -def test_get(mock): - resp = create_mock_json("tests/resources/ip_messaging/channel_instance.json") - mock.return_value = resp - - uri = "%s/Channels/%s" % (BASE_URI, CHANNEL_SID) - list_resource.get(CHANNEL_SID) - - mock.assert_called_with("GET", uri, auth=AUTH, - use_json_extension=False) - - -@patch("twilio.rest.resources.base.Resource.request") -def test_delete(req): - """ Deleting a call should work """ - resp = Mock() - resp.content = "" - resp.status_code = 204 - req.return_value = resp, {} - - app = Channel(list_resource, "CH123") - app.delete() - uri = "%s/Channels/CH123" % (BASE_URI) - req.assert_called_with("DELETE", uri) diff --git a/tests/ip_messaging/test_credentials.py b/tests/ip_messaging/test_credentials.py deleted file mode 100644 index 52b2c01c86..0000000000 --- a/tests/ip_messaging/test_credentials.py +++ /dev/null @@ -1,52 +0,0 @@ -from mock import patch, Mock -from twilio.rest.resources.ip_messaging import Credentials, Credential -from tests.tools import create_mock_json - -BASE_URI = "https://ip-messaging.twilio.com/v1" -ACCOUNT_SID = "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" -AUTH = (ACCOUNT_SID, "token") -CREDENTIAL_SID = "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - -list_resource = Credentials(BASE_URI, AUTH) - - -@patch("twilio.rest.resources.base.make_twilio_request") -def test_create_credential(mock): - resp = create_mock_json("tests/resources/ip_messaging/credential_instance.json") - resp.status_code = 201 - mock.return_value = resp - - uri = "%s/Credentials" % (BASE_URI) - list_resource.create('apn') - exp_params = { - 'Type': "apn" - } - - mock.assert_called_with("POST", uri, data=exp_params, auth=AUTH, - use_json_extension=False) - - -@patch("twilio.rest.resources.base.make_twilio_request") -def test_get(mock): - resp = create_mock_json("tests/resources/ip_messaging/credential_instance.json") - mock.return_value = resp - - uri = "%s/Credentials/%s" % (BASE_URI, CREDENTIAL_SID) - list_resource.get(CREDENTIAL_SID) - - mock.assert_called_with("GET", uri, auth=AUTH, - use_json_extension=False) - - -@patch("twilio.rest.resources.base.Resource.request") -def test_delete(req): - """ Deleting a call should work """ - resp = Mock() - resp.content = "" - resp.status_code = 204 - req.return_value = resp, {} - - app = Credential(list_resource, "IS123") - app.delete() - uri = "https://ip-messaging.twilio.com/v1/Credentials/IS123" - req.assert_called_with("DELETE", uri) diff --git a/tests/ip_messaging/test_members.py b/tests/ip_messaging/test_members.py deleted file mode 100644 index fa05331870..0000000000 --- a/tests/ip_messaging/test_members.py +++ /dev/null @@ -1,52 +0,0 @@ -from mock import patch, Mock -from twilio.rest.resources.ip_messaging import Members, Member -from tests.tools import create_mock_json - -BASE_URI = "https://ip-messaging.twilio.com/v1/Services/ISxxx/Channels/CHxxx" -ACCOUNT_SID = "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" -AUTH = (ACCOUNT_SID, "token") -MEMBER_SID = "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - -list_resource = Members(BASE_URI, AUTH) - - -@patch("twilio.rest.resources.base.make_twilio_request") -def test_create_member(mock): - resp = create_mock_json("tests/resources/ip_messaging/member_instance.json") - resp.status_code = 201 - mock.return_value = resp - - uri = "%s/Members" % (BASE_URI) - list_resource.create('test_identity') - exp_params = { - 'Identity': "test_identity" - } - - mock.assert_called_with("POST", uri, data=exp_params, auth=AUTH, - use_json_extension=False) - - -@patch("twilio.rest.resources.base.make_twilio_request") -def test_get(mock): - resp = create_mock_json("tests/resources/ip_messaging/member_instance.json") - mock.return_value = resp - - uri = "%s/Members/%s" % (BASE_URI, MEMBER_SID) - list_resource.get(MEMBER_SID) - - mock.assert_called_with("GET", uri, auth=AUTH, - use_json_extension=False) - - -@patch("twilio.rest.resources.base.Resource.request") -def test_delete(req): - """ Deleting a call should work """ - resp = Mock() - resp.content = "" - resp.status_code = 204 - req.return_value = resp, {} - - app = Member(list_resource, "MB123") - app.delete() - uri = "%s/Members/MB123" % (BASE_URI) - req.assert_called_with("DELETE", uri) diff --git a/tests/ip_messaging/test_messages.py b/tests/ip_messaging/test_messages.py deleted file mode 100644 index c4fd6f8a2c..0000000000 --- a/tests/ip_messaging/test_messages.py +++ /dev/null @@ -1,52 +0,0 @@ -from mock import patch, Mock -from twilio.rest.resources.ip_messaging import Messages, Message -from tests.tools import create_mock_json - -BASE_URI = "https://ip-messaging.twilio.com/v1/Services/ISxxx/Channels/CHxxx" -ACCOUNT_SID = "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" -AUTH = (ACCOUNT_SID, "token") -MESSAGE_SID = "MSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - -list_resource = Messages(BASE_URI, AUTH) - - -@patch("twilio.rest.resources.base.make_twilio_request") -def test_create_message(mock): - resp = create_mock_json("tests/resources/ip_messaging/message_instance.json") - resp.status_code = 201 - mock.return_value = resp - - uri = "%s/Messages" % (BASE_URI) - list_resource.create('TestBody') - exp_params = { - 'Body': "TestBody" - } - - mock.assert_called_with("POST", uri, data=exp_params, auth=AUTH, - use_json_extension=False) - - -@patch("twilio.rest.resources.base.make_twilio_request") -def test_get(mock): - resp = create_mock_json("tests/resources/ip_messaging/message_instance.json") - mock.return_value = resp - - uri = "%s/Messages/%s" % (BASE_URI, MESSAGE_SID) - list_resource.get(MESSAGE_SID) - - mock.assert_called_with("GET", uri, auth=AUTH, - use_json_extension=False) - - -@patch("twilio.rest.resources.base.Resource.request") -def test_delete(req): - """ Deleting a call should work """ - resp = Mock() - resp.content = "" - resp.status_code = 204 - req.return_value = resp, {} - - app = Message(list_resource, "MS123") - app.delete() - uri = "%s/Messages/MS123" % (BASE_URI) - req.assert_called_with("DELETE", uri) diff --git a/tests/ip_messaging/test_roles.py b/tests/ip_messaging/test_roles.py deleted file mode 100644 index 8160dcb7c9..0000000000 --- a/tests/ip_messaging/test_roles.py +++ /dev/null @@ -1,36 +0,0 @@ -from mock import patch, Mock -from twilio.rest.resources.ip_messaging import Roles, Role -from tests.tools import create_mock_json - -BASE_URI = "https://ip-messaging.twilio.com/v1/Services/ISxxx" -ACCOUNT_SID = "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" -AUTH = (ACCOUNT_SID, "token") -ROLE_SID = "ROaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - -list_resource = Roles(BASE_URI, AUTH) - - -@patch("twilio.rest.resources.base.make_twilio_request") -def test_get(mock): - resp = create_mock_json("tests/resources/ip_messaging/role_instance.json") - mock.return_value = resp - - uri = "%s/Roles/%s" % (BASE_URI, ROLE_SID) - list_resource.get(ROLE_SID) - - mock.assert_called_with("GET", uri, auth=AUTH, - use_json_extension=False) - - -@patch("twilio.rest.resources.base.Resource.request") -def test_delete(req): - """ Deleting a call should work """ - resp = Mock() - resp.content = "" - resp.status_code = 204 - req.return_value = resp, {} - - app = Role(list_resource, "RO123") - app.delete() - uri = "%s/Roles/RO123" % (BASE_URI) - req.assert_called_with("DELETE", uri) diff --git a/tests/ip_messaging/test_services.py b/tests/ip_messaging/test_services.py deleted file mode 100644 index 04b24a7f14..0000000000 --- a/tests/ip_messaging/test_services.py +++ /dev/null @@ -1,52 +0,0 @@ -from mock import patch, Mock -from twilio.rest.resources.ip_messaging import Services, Service -from tests.tools import create_mock_json - -BASE_URI = "https://ip-messaging.twilio.com/v1" -ACCOUNT_SID = "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" -AUTH = (ACCOUNT_SID, "token") -SERVICE_SID = "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - -list_resource = Services(BASE_URI, AUTH) - - -@patch("twilio.rest.resources.base.make_twilio_request") -def test_create_service(mock): - resp = create_mock_json("tests/resources/ip_messaging/service_instance.json") - resp.status_code = 201 - mock.return_value = resp - - uri = "%s/Services" % (BASE_URI) - list_resource.create('TestService') - exp_params = { - 'FriendlyName': "TestService" - } - - mock.assert_called_with("POST", uri, data=exp_params, auth=AUTH, - use_json_extension=False) - - -@patch("twilio.rest.resources.base.make_twilio_request") -def test_get(mock): - resp = create_mock_json("tests/resources/ip_messaging/service_instance.json") - mock.return_value = resp - - uri = "%s/Services/%s" % (BASE_URI, SERVICE_SID) - list_resource.get(SERVICE_SID) - - mock.assert_called_with("GET", uri, auth=AUTH, - use_json_extension=False) - - -@patch("twilio.rest.resources.base.Resource.request") -def test_delete(req): - """ Deleting a call should work """ - resp = Mock() - resp.content = "" - resp.status_code = 204 - req.return_value = resp, {} - - app = Service(list_resource, "IS123") - app.delete() - uri = "https://ip-messaging.twilio.com/v1/Services/IS123" - req.assert_called_with("DELETE", uri) diff --git a/tests/ip_messaging/test_users.py b/tests/ip_messaging/test_users.py deleted file mode 100644 index 0c90bb7e2a..0000000000 --- a/tests/ip_messaging/test_users.py +++ /dev/null @@ -1,52 +0,0 @@ -from mock import patch, Mock -from twilio.rest.resources.ip_messaging import Users, User -from tests.tools import create_mock_json - -BASE_URI = "https://ip-messaging.twilio.com/v1/Services/ISxxx" -ACCOUNT_SID = "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" -AUTH = (ACCOUNT_SID, "token") -USER_SID = "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - -list_resource = Users(BASE_URI, AUTH) - - -@patch("twilio.rest.resources.base.make_twilio_request") -def test_create_user(mock): - resp = create_mock_json("tests/resources/ip_messaging/user_instance.json") - resp.status_code = 201 - mock.return_value = resp - - uri = "%s/Users" % (BASE_URI) - list_resource.create('test_id') - exp_params = { - 'Id': "test_id" - } - - mock.assert_called_with("POST", uri, data=exp_params, auth=AUTH, - use_json_extension=False) - - -@patch("twilio.rest.resources.base.make_twilio_request") -def test_get(mock): - resp = create_mock_json("tests/resources/ip_messaging/user_instance.json") - mock.return_value = resp - - uri = "%s/Users/%s" % (BASE_URI, USER_SID) - list_resource.get(USER_SID) - - mock.assert_called_with("GET", uri, auth=AUTH, - use_json_extension=False) - - -@patch("twilio.rest.resources.base.Resource.request") -def test_delete(req): - """ Deleting a call should work """ - resp = Mock() - resp.content = "" - resp.status_code = 204 - req.return_value = resp, {} - - app = User(list_resource, "US123") - app.delete() - uri = "%s/Users/US123" % (BASE_URI) - req.assert_called_with("DELETE", uri) diff --git a/tests/resources/conversations/conversation_instance.json b/tests/resources/conversations/conversation_instance.json deleted file mode 100644 index a23e753f3b..0000000000 --- a/tests/resources/conversations/conversation_instance.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "links": { - "participants": "https://conversations.stage.twilio.com/v1/Conversations/CV4bbc4afc943cd2a5d29f0ce01c5656db/Participants" - }, - "sid": "CV4bbc4afc943cd2a5d29f0ce01c5656db", - "status": "created", - "account_sid": "AC998c10b68cbfda9f67277f7d8f4439c9", - "date_created": "2015-05-12T21:13:15Z", - "start_time": "2015-05-12T21:13:15Z", - "end_time": "2015-05-12T21:14:15Z", - "duration": 60, - "url": "https://conversations.stage.twilio.com/v1/Conversations/CV4bbc4afc943cd2a5d29f0ce01c5656db" -} diff --git a/tests/resources/conversations/conversation_list.json b/tests/resources/conversations/conversation_list.json deleted file mode 100644 index bc7c0e3efb..0000000000 --- a/tests/resources/conversations/conversation_list.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "meta": { - "key": "conversations", - "next_page_url": null, - "url": "https://conversations.stage.twilio.com/v1/Conversations/Completed?PageSize=50&Page=0", - "previous_page_url": null, - "first_page_url": "https://conversations.stage.twilio.com/v1/Conversations/Completed?PageSize=50&Page=0", - "page_size": 50, - "page": 0 - }, - "conversations": [ - { - "links": { - "participants": "https://conversations.stage.twilio.com/v1/Conversations/CV5cd9d2f155da05660b5d487b1b69e27d/Participants" - }, - "sid": "CV5cd9d2f155da05660b5d487b1b69e27d", - "status": "completed", - "account_sid": "AC998c10b68cbfda9f67277f7d8f4439c9", - "date_created": "2015-05-12T21:08:50Z", - "start_time": "2015-05-12T21:08:50Z", - "end_time": "2015-05-12T21:09:50Z", - "duration": 60, - "url": "https://conversations.stage.twilio.com/v1/Conversations/CV5cd9d2f155da05660b5d487b1b69e27d" - }, - { - "links": { - "participants": "https://conversations.stage.twilio.com/v1/Conversations/CV878937a518876bece719861b02a4984a/Participants" - }, - "sid": "CV878937a518876bece719861b02a4984a", - "status": "completed", - "account_sid": "AC998c10b68cbfda9f67277f7d8f4439c9", - "date_created": "2015-05-12T16:57:03Z", - "start_time": "2015-05-12T16:57:03Z", - "end_time": "2015-05-12T16:58:03Z", - "duration": 60, - "url": "https://conversations.stage.twilio.com/v1/Conversations/CV878937a518876bece719861b02a4984a" - } - ] -} diff --git a/tests/resources/conversations/participant_instance.json b/tests/resources/conversations/participant_instance.json deleted file mode 100644 index 03fb08c041..0000000000 --- a/tests/resources/conversations/participant_instance.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "url": "https://conversations.stage.twilio.com/v1/Conversations/CVe42fecfaefadbb03cbe27d94e4cef8c2/Participants/PA97239ce0bff1491fa82986a543bcd9c9", - "account_sid": "AC998c10b68cbfda9f67277f7d8f4439c9", - "sid": "PA97239ce0bff1491fa82986a543bcd9c9", - "address": "torkel2@AC998c10b68cbfda9f67277f7d8f4439c9.endpoint.twilio.com", - "status": "disconnected", - "conversation_sid": "CVe42fecfaefadbb03cbe27d94e4cef8c2", - "date_created": "2015-05-13T23:03:12Z", - "start_time": "2015-05-13T23:03:15Z", - "end_time": "2015-05-13T23:14:40Z", - "duration": 685 -} diff --git a/tests/resources/conversations/participant_list.json b/tests/resources/conversations/participant_list.json deleted file mode 100644 index 7d41ff65d2..0000000000 --- a/tests/resources/conversations/participant_list.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "meta": { - "key": "participants", - "next_page_url": null, - "url": "https://conversations.stage.twilio.com/v1/Conversations/CVe42fecfaefadbb03cbe27d94e4cef8c2/Participants?PageSize=50&Page=0", - "previous_page_url": null, - "first_page_url": "https://conversations.stage.twilio.com/v1/Conversations/CVe42fecfaefadbb03cbe27d94e4cef8c2/Participants?PageSize=50&Page=0", - "page_size": 50, - "page": 0 - }, - "participants": [ - { - "url": "https://conversations.stage.twilio.com/v1/Conversations/CVe42fecfaefadbb03cbe27d94e4cef8c2/Participants/PA97239ce0bff1491fa82986a543bcd9c9", - "account_sid": "AC998c10b68cbfda9f67277f7d8f4439c9", - "sid": "PA97239ce0bff1491fa82986a543bcd9c9", - "address": "torkel2@AC998c10b68cbfda9f67277f7d8f4439c9.endpoint.twilio.com", - "status": "disconnected", - "conversation_sid": "CVe42fecfaefadbb03cbe27d94e4cef8c2", - "date_created": "2015-05-13T23:03:12Z", - "start_time": "2015-05-13T23:03:15Z", - "end_time": "2015-05-13T23:14:40Z", - "duration": 685 - }, - { - "url": "https://conversations.stage.twilio.com/v1/Conversations/CVe42fecfaefadbb03cbe27d94e4cef8c2/Participants/PA78810fba996f4087c8894b801669b9b2", - "account_sid": "AC998c10b68cbfda9f67277f7d8f4439c9", - "sid": "PA78810fba996f4087c8894b801669b9b2", - "address": "torkel1@AC998c10b68cbfda9f67277f7d8f4439c9.endpoint.twilio.com", - "status": "disconnected", - "conversation_sid": "CVe42fecfaefadbb03cbe27d94e4cef8c2", - "date_created": "2015-05-13T23:03:12Z", - "start_time": "2015-05-13T23:03:15Z", - "end_time": "2015-05-13T23:14:40Z", - "duration": 685 - } - ] -} \ No newline at end of file diff --git a/tests/resources/ip_messaging/channel_instance.json b/tests/resources/ip_messaging/channel_instance.json deleted file mode 100644 index d713a5111b..0000000000 --- a/tests/resources/ip_messaging/channel_instance.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "friendly_name": "update", - "attributes": "", - "date_created": "2015-08-20T09:30:24Z", - "date_updated": "2015-08-20T09:30:24Z", - "created_by": "system", - "url": "https://ip-messaging.stage.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "links": { - "members": "https://ip-messaging.stage.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Member", - "messages": "https://ip-messaging.stage.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages" - } -} diff --git a/tests/resources/ip_messaging/credential_instance.json b/tests/resources/ip_messaging/credential_instance.json deleted file mode 100644 index 9b24940277..0000000000 --- a/tests/resources/ip_messaging/credential_instance.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "account_sid":"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "sid":"CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "friendly_name":"MyApp APN Certificate", - "type":"apn", - "date_created":"2015-06-30T21:16:50Z", - "date_updated":"2015-07-30T21:16:50Z" -} diff --git a/tests/resources/ip_messaging/member_instance.json b/tests/resources/ip_messaging/member_instance.json deleted file mode 100644 index adc75ddcfe..0000000000 --- a/tests/resources/ip_messaging/member_instance.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "sid": "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "space_sid": "SPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "id": "carl@twilio.com", - "role": "admin", - "url": "/v1/Spaces/SPxx/Channels/CHxx/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" -} diff --git a/tests/resources/ip_messaging/message_instance.json b/tests/resources/ip_messaging/message_instance.json deleted file mode 100644 index acbe53124f..0000000000 --- a/tests/resources/ip_messaging/message_instance.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "sid": "IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "space_sid": "SPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "date_created": "2015-07-23T20:20:10Z", - "date_updated": "2015-07-23T20:20:10Z", - "was_edited": true, - "from": "carl@twilio.com", - "to": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "body": "Hello", - "url": "/v1/Spaces/SPxx/Channels/CHxx/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" -} diff --git a/tests/resources/ip_messaging/role_instance.json b/tests/resources/ip_messaging/role_instance.json deleted file mode 100644 index bbd604428c..0000000000 --- a/tests/resources/ip_messaging/role_instance.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "sid":"RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "account_sid":"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "space_sid": "SPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "name":"Deployment Admin", - "type":"deployment", - "permissions":[ - "createChannel", - "destroyChannel" - ] -} diff --git a/tests/resources/ip_messaging/service_instance.json b/tests/resources/ip_messaging/service_instance.json deleted file mode 100644 index bc4d56e4a9..0000000000 --- a/tests/resources/ip_messaging/service_instance.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "friendly_name": "TestService", - "date_created": "2015-10-21T04:15:36Z", - "date_updated": "2015-10-21T04:15:36Z", - "default_service_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "default_channel_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "typing_indicator_timeout": 5, - "webhooks": {}, - "url": "https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "links": { - "channels": "https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels", - "roles": "https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles", - "users": "https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users" - } -} diff --git a/tests/resources/ip_messaging/user_instance.json b/tests/resources/ip_messaging/user_instance.json deleted file mode 100644 index a2326cc20c..0000000000 --- a/tests/resources/ip_messaging/user_instance.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "date_created": "2015-08-19T18:18:00Z", - "date_updated": "2015-08-19T18:18:00Z", - "identity": "carl@twilio.com", - "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "role_sid": null, - "url": "https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" -} diff --git a/twilio/rest/conversations.py b/twilio/rest/conversations.py deleted file mode 100644 index 93f2ddc03b..0000000000 --- a/twilio/rest/conversations.py +++ /dev/null @@ -1,28 +0,0 @@ -from twilio.rest.base import TwilioClient -from twilio.rest.resources import UNSET_TIMEOUT -from twilio.rest.resources.conversations.conversations import ConversationsRoot - - -class TwilioConversationsClient(TwilioClient): - """ - A client for accessing the Twilio Conversations API. - - XXX more verbiage here - - :param str account: Your Account Sid from `your dashboard - `_ - :param str token: Your Auth Token from `your dashboard - `_ - :param float timeout: The socket and read timeout for requests to Twilio - """ - - def __init__(self, account=None, token=None, - base="https://conversations.twilio.com", version="v1", - timeout=UNSET_TIMEOUT): - - super(TwilioConversationsClient, self).__init__(account, token, base, - version, timeout) - - self.version_uri = "%s/%s" % (base, version) - self.conversations = ConversationsRoot(self.version_uri, self.auth, - timeout) diff --git a/twilio/rest/ip_messaging.py b/twilio/rest/ip_messaging.py deleted file mode 100644 index a52e8e37a6..0000000000 --- a/twilio/rest/ip_messaging.py +++ /dev/null @@ -1,29 +0,0 @@ -from twilio.rest.base import TwilioClient -from twilio.rest.resources import UNSET_TIMEOUT -from twilio.rest.resources.ip_messaging.services import Services - - -class TwilioIpMessagingClient(TwilioClient): - """ - A client for accessing the Twilio IP Messaging API. - - The Twilio IP Messaging API provides information about events. For more - information, see the - `IP Messaging API documentation `_. - - :param str account: Your Account Sid from `your dashboard - `_ - :param str token: Your Auth Token from `your dashboard - `_ - :param float timeout: The socket and read timeout for requests to Twilio - """ - - def __init__(self, account=None, token=None, - base="https://ip-messaging.twilio.com", version="v1", - timeout=UNSET_TIMEOUT): - - super(TwilioIpMessagingClient, self).__init__(account, token, base, - version, timeout) - - self.version_uri = "%s/%s" % (base, version) - self.services = Services(self.version_uri, self.auth, timeout) diff --git a/twilio/rest/resources/base.py b/twilio/rest/resources/base.py index 67285c11cc..d9a34b8886 100644 --- a/twilio/rest/resources/base.py +++ b/twilio/rest/resources/base.py @@ -244,7 +244,7 @@ def load(self, entries): del entries["uri"] for key in entries.keys(): - if ((key.startswith("date_") or key.endswith("_time")) and + if (key.startswith("date_") and isinstance(entries[key], string_types)): entries[key] = self._parse_date(entries[key]) diff --git a/twilio/rest/resources/conversations/__init__.py b/twilio/rest/resources/conversations/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/twilio/rest/resources/conversations/conversations.py b/twilio/rest/resources/conversations/conversations.py deleted file mode 100644 index 8c0adec62f..0000000000 --- a/twilio/rest/resources/conversations/conversations.py +++ /dev/null @@ -1,58 +0,0 @@ -from twilio.rest.resources import NextGenInstanceResource, NextGenListResource - - -class ConversationsRoot(object): - - def __init__(self, base_uri, *args, **kwargs): - self.uri = "%s/Conversations" % base_uri - self._instance_base = Conversations(self.uri, *args, **kwargs) - self.in_progress = Conversations("%s/InProgress" % self.uri, *args, - **kwargs) - self.completed = Conversations("%s/Completed" % self.uri, *args, - **kwargs) - - def get(self, sid): - return self._instance_base.get(sid) - - def delete_instance(self, sid): - return self._instance_base.delete_instance(sid) - - -class Conversation(NextGenInstanceResource): - """A Conversation instance representing a call - between two or more participants. - - .. attribute:: sid - - .. attribute:: account_sid - - .. attribute:: status - - .. attribute:: date_created - - .. attribute:: start_time - - .. attribute:: end_time - - .. attribute:: duration - - .. attribute:: url - """ - pass - - -class Conversations(NextGenListResource): - - name = "Conversations" - instance = Conversation - - def __init__(self, uri, *args, **kwargs): - super(Conversations, self).__init__(uri, *args, **kwargs) - # This list is exposed at two different locations: /InProgress - # and /Completed. The parent Root object will hand us the full URL - # to set up at. - self._uri = uri - - @property - def uri(self): - return self._uri diff --git a/twilio/rest/resources/conversations/participants.py b/twilio/rest/resources/conversations/participants.py deleted file mode 100644 index 65ad08801f..0000000000 --- a/twilio/rest/resources/conversations/participants.py +++ /dev/null @@ -1,34 +0,0 @@ -from twilio.rest.resources import NextGenInstanceResource, NextGenListResource - - -class Participant(NextGenInstanceResource): - """A participant in a Conversation. - - .. attribute:: sid - - .. attribute:: conversation_sid - - .. attribute:: account_sid - - .. attribute:: status - - .. attribute:: address - - .. attribute:: date_created - - .. attribute:: start_time - - .. attribute:: end_time - - .. attribute:: duration - - .. attribute:: url - """ - pass - - -class Participants(NextGenListResource): - """A list of :class:`Participant` objects.""" - - name = "Participants" - instance = Participant diff --git a/twilio/rest/resources/ip_messaging/__init__.py b/twilio/rest/resources/ip_messaging/__init__.py deleted file mode 100644 index 55f60ad203..0000000000 --- a/twilio/rest/resources/ip_messaging/__init__.py +++ /dev/null @@ -1,34 +0,0 @@ -from .services import ( - Service, - Services -) - -from .channels import ( - Channel, - Channels -) - -from .members import ( - Member, - Members -) - -from .messages import ( - Message, - Messages -) - -from .roles import ( - Role, - Roles -) - -from .users import ( - User, - Users -) - -from .credentials import ( - Credential, - Credentials -) diff --git a/twilio/rest/resources/ip_messaging/channels.py b/twilio/rest/resources/ip_messaging/channels.py deleted file mode 100644 index ad6f42ce68..0000000000 --- a/twilio/rest/resources/ip_messaging/channels.py +++ /dev/null @@ -1,54 +0,0 @@ -from .members import Members -from .messages import Messages -from twilio.rest.resources import NextGenInstanceResource, NextGenListResource - - -class Channel(NextGenInstanceResource): - - subresources = [ - Members, - Messages - ] - - def update(self, sid, **kwargs): - return self.update_instance(sid, kwargs) - - def delete(self): - """ - Delete this channel - """ - return self.delete_instance() - - -class Channels(NextGenListResource): - - name = "Channels" - instance = Channel - - def list(self, **kwargs): - """ - Returns a page of :class:`Channel` resources as a list. - For paging information see :class:`ListResource`. - - **NOTE**: Due to the potentially voluminous amount of data in an - alert, the full HTTP request and response data is only returned - in the Channel instance resource representation. - """ - return self.get_instances(kwargs) - - def create(self, **kwargs): - """ - Create a channel. - - :param str friendly_name: The friendly name of the channel. - :param str attributes: An attribute string with arbitrary - - :return: A :class:`Channel` object - """ - return self.create_instance(kwargs) - - def delete(self, sid): - """ - Delete a given Channel - """ - return self.delete_instance(sid) diff --git a/twilio/rest/resources/ip_messaging/credentials.py b/twilio/rest/resources/ip_messaging/credentials.py deleted file mode 100644 index c861dc28d7..0000000000 --- a/twilio/rest/resources/ip_messaging/credentials.py +++ /dev/null @@ -1,53 +0,0 @@ -from twilio.rest.resources import NextGenInstanceResource, NextGenListResource - - -class Credential(NextGenInstanceResource): - - def update(self, sid, **kwargs): - return self.update_instance(sid, kwargs) - - def delete(self): - """ - Delete this credential - """ - return self.delete_instance() - - -class Credentials(NextGenListResource): - - name = "Credentials" - instance = Credential - - def list(self, **kwargs): - """ - Returns a page of :class:`Credential` resources as a list. - For paging information see :class:`ListResource`. - - **NOTE**: Due to the potentially voluminous amount of data in an - alert, the full HTTP request and response data is only returned - in the Credential instance resource representation. - - :param date after: Only list alerts logged after this datetime - :param date before: Only list alerts logger before this datetime - :param log_level: If 'error', only shows errors. If 'warning', - only show warnings - """ - return self.get_instances(kwargs) - - def create(self, type, **kwargs): - """ - Make a phone call to a number. - - :param str type: The type of credential - :param str friendly_name: The friendly name of the credential. - - :return: A :class:`Credential` object - """ - kwargs["type"] = type - return self.create_instance(kwargs) - - def delete(self, sid): - """ - Delete a given Credential - """ - return self.delete_instance(sid) diff --git a/twilio/rest/resources/ip_messaging/members.py b/twilio/rest/resources/ip_messaging/members.py deleted file mode 100644 index dd3b0fae90..0000000000 --- a/twilio/rest/resources/ip_messaging/members.py +++ /dev/null @@ -1,49 +0,0 @@ -from twilio.rest.resources import NextGenInstanceResource, NextGenListResource - - -class Member(NextGenInstanceResource): - - def update(self, sid, **kwargs): - return self.update_instance(sid, kwargs) - - def delete(self): - """ - Delete this member - """ - return self.delete_instance() - - -class Members(NextGenListResource): - - name = "Members" - instance = Member - - def list(self, **kwargs): - """ - Returns a page of :class:`Member` resources as a list. - For paging information see :class:`ListResource`. - - **NOTE**: Due to the potentially voluminous amount of data in an - alert, the full HTTP request and response data is only returned - in the Member instance resource representation. - - """ - return self.get_instances(kwargs) - - def create(self, identity, **kwargs): - """ - Create a Member. - - :param str identity: The identity of the user. - :param str role: The role to assign the member. - - :return: A :class:`Member` object - """ - kwargs["identity"] = identity - return self.create_instance(kwargs) - - def delete(self, sid): - """ - Delete a given Member - """ - return self.delete_instance(sid) diff --git a/twilio/rest/resources/ip_messaging/messages.py b/twilio/rest/resources/ip_messaging/messages.py deleted file mode 100644 index d888e21004..0000000000 --- a/twilio/rest/resources/ip_messaging/messages.py +++ /dev/null @@ -1,49 +0,0 @@ -from twilio.rest.resources import NextGenInstanceResource, NextGenListResource - - -class Message(NextGenInstanceResource): - - def update(self, sid, **kwargs): - return self.update_instance(sid, kwargs) - - def delete(self): - """ - Delete this message - """ - return self.delete_instance() - - -class Messages(NextGenListResource): - - name = "Messages" - instance = Message - - def list(self, **kwargs): - """ - Returns a page of :class:`Message` resources as a list. - For paging information see :class:`ListResource`. - - **NOTE**: Due to the potentially voluminous amount of data in an - alert, the full HTTP request and response data is only returned - in the Message instance resource representation. - - """ - return self.get_instances(kwargs) - - def create(self, body, **kwargs): - """ - Create a Message. - - :param str body: The body of the message. - :param str from: The message author's identity. - - :return: A :class:`Message` object - """ - kwargs["body"] = body - return self.create_instance(kwargs) - - def delete(self, sid): - """ - Delete a given Message - """ - return self.delete_instance(sid) diff --git a/twilio/rest/resources/ip_messaging/roles.py b/twilio/rest/resources/ip_messaging/roles.py deleted file mode 100644 index bff9147821..0000000000 --- a/twilio/rest/resources/ip_messaging/roles.py +++ /dev/null @@ -1,37 +0,0 @@ -from twilio.rest.resources import NextGenInstanceResource, NextGenListResource - - -class Role(NextGenInstanceResource): - - def update(self, sid, **kwargs): - return self.update_instance(sid, kwargs) - - def delete(self): - """ - Delete this role - """ - return self.delete_instance() - - -class Roles(NextGenListResource): - - name = "Roles" - instance = Role - - def list(self, **kwargs): - """ - Returns a page of :class:`Role` resources as a list. - For paging information see :class:`ListResource`. - - **NOTE**: Due to the potentially voluminous amount of data in an - alert, the full HTTP request and response data is only returned - in the Role instance resource representation. - - """ - return self.get_instances(kwargs) - - def delete(self, sid): - """ - Delete a given Role - """ - return self.delete_instance(sid) diff --git a/twilio/rest/resources/ip_messaging/services.py b/twilio/rest/resources/ip_messaging/services.py deleted file mode 100644 index 92765677da..0000000000 --- a/twilio/rest/resources/ip_messaging/services.py +++ /dev/null @@ -1,57 +0,0 @@ -from .channels import Channels -from .roles import Roles -from .users import Users -from twilio.rest.resources import NextGenInstanceResource, NextGenListResource - - -class Service(NextGenInstanceResource): - - subresources = [ - Channels, - Roles, - Users - ] - - def update(self, sid, **kwargs): - return self.update_instance(sid, kwargs) - - def delete(self): - """ - Delete this service - """ - return self.delete_instance() - - -class Services(NextGenListResource): - - name = "Services" - instance = Service - - def list(self, **kwargs): - """ - Returns a page of :class:`Service` resources as a list. - For paging information see :class:`ListResource`. - - **NOTE**: Due to the potentially voluminous amount of data in an - alert, the full HTTP request and response data is only returned - in the Service instance resource representation. - - """ - return self.get_instances(kwargs) - - def create(self, friendly_name, **kwargs): - """ - Create a service. - - :param str friendly_name: The friendly name for the service - - :return: A :class:`Service` object - """ - kwargs["friendly_name"] = friendly_name - return self.create_instance(kwargs) - - def delete(self, sid): - """ - Delete a given Service - """ - return self.delete_instance(sid) diff --git a/twilio/rest/resources/ip_messaging/users.py b/twilio/rest/resources/ip_messaging/users.py deleted file mode 100644 index eb5c6e3501..0000000000 --- a/twilio/rest/resources/ip_messaging/users.py +++ /dev/null @@ -1,49 +0,0 @@ -from twilio.rest.resources import NextGenInstanceResource, NextGenListResource - - -class User(NextGenInstanceResource): - - def update(self, sid, **kwargs): - return self.update_instance(sid, kwargs) - - def delete(self): - """ - Delete this user - """ - return self.delete_instance() - - -class Users(NextGenListResource): - - name = "Users" - instance = User - - def list(self, **kwargs): - """ - Returns a page of :class:`User` resources as a list. - For paging information see :class:`ListResource`. - - **NOTE**: Due to the potentially voluminous amount of data in an - alert, the full HTTP request and response data is only returned - in the User instance resource representation. - - """ - return self.get_instances(kwargs) - - def create(self, id, **kwargs): - """ - Make a phone call to a number. - - :param str id: The identity of the user. - :param str role: The role to assign the user. - - :return: A :class:`User` object - """ - kwargs["id"] = id - return self.create_instance(kwargs) - - def delete(self, sid): - """ - Delete a given User - """ - return self.delete_instance(sid) From b1f7f3d75b1cdd6b5cc333e5ecb383dd2f8e68fc Mon Sep 17 00:00:00 2001 From: Jingming Niu Date: Mon, 2 Nov 2015 15:48:13 -0800 Subject: [PATCH 3/3] Remove merge artifact --- tests/test_make_request.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_make_request.py b/tests/test_make_request.py index d1e4d5d800..0eab2e8288 100644 --- a/tests/test_make_request.py +++ b/tests/test_make_request.py @@ -119,4 +119,3 @@ def test_proxy_info(http_mock, resp_mock): assert_equal(proxy_info.proxy_host, 'example.com') assert_equal(proxy_info.proxy_port, 8080) assert_equal(proxy_info.proxy_type, PROXY_TYPE_SOCKS5) ->>>>>>> parent of 6bf0e94... Merge remote-tracking branch 'origin/signal-beta' into edge