8000 Merge branch 'master' of github.com:twilio/python-private · Twilio-api/twilio-python@58850d7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 58850d7

Browse files
author
Kevin Burke
committed
Merge branch 'master' of github.com:twilio/python-private
2 parents f429698 + 2d36bff commit 58850d7

File tree

6 files changed

+33
-74
lines changed

6 files changed

+33
-74
lines changed

docs/index.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,11 @@ phone numbers.
139139

140140
faq
141141

142+
Changelog
143+
=========
144+
145+
See the :doc:`/changelog` for version history.
146+
142147

143148
Support and Development
144149
==========================
@@ -155,6 +160,3 @@ Report bugs using the Github
155160

156161
If you have questions that aren't answered by this documentation,
157162
ask the `#twilio IRC channel <irc://irc.freenode.net/#twilio>`_
158-
159-
See the :doc:`/changelog` for version history.
160-

tests/test_base_resource.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,23 @@ def testInstanceLoading(self):
8787
self.assertIsInstance(instance, InstanceResource)
8888
self.assertEquals(instance.sid, "foo")
8989

90+
def testListResourceCreateResponse200(self):
91+
"""We should accept 200 OK in response to a POST creating a resource."""
92+
self.r.request = Mock()
93+
return_value = Mock()
94+
return_value.status_code = 200
95+
self.r.request.return_value = return_value, {'sid': 'foo'}
96+
self.r.create_instance({})
97+
self.r.request.assert_called_with("POST", "https://api.twilio.com/2010-04-01/Resources", data={})
98+
99+
def testListResourceCreateResponse201(self):
100+
"""We should accept 201 Created in response to a POST creating a resource."""
101+
self.r.request = Mock()
102+
return_value = Mock()
103+
return_value.status_code = 201
104+
self.r.request.return_value = return_value, {'sid': 'foo'}
105+
self.r.create_instance({})
106+
self.r.request.assert_called_with("POST", "https://api.twilio.com/2010-04-01/Resources", data={})
90107

91108
class testInstanceResourceInit(unittest.TestCase):
92109

tests/test_core.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from twilio.rest.resources import convert_case
1212
from twilio.rest.resources import convert_boolean
1313
from twilio.rest.resources import normalize_dates
14-
from werkzeug.datastructures import MultiDict
1514

1615

1716
class CoreTest(unittest.TestCase):
@@ -38,20 +37,18 @@ def test_string_date_false(self):
3837

3938
def test_fparam(self):
4039
d = {"HEY": None, "YOU": 3}
41-
ed = MultiDict({"YOU": 3})
42-
self.assertEquals(transform_params(d).to_dict(flat=False), ed.to_dict(flat=False))
40+
ed = {"YOU": 3}
41+
self.assertEquals(transform_params(d), ed)
4342

4443
def test_multi_param(self):
4544
d = {"Normal": 3, "Multiple": ["One", "Two"]}
46-
ed = MultiDict({"Normal": 3})
47-
ed.add('Multiple', 'One')
48-
ed.add('Multiple', 'Two')
49-
self.assertEquals(transform_params(d).to_dict(flat=False), ed.to_dict(flat=False))
45+
ed = {"Normal": 3, "Multiple": ["One", "Two"]}
46+
self.assertEquals(transform_params(d), ed)
5047

5148
def test_fparam_booleans(self):
5249
d = {"HEY": None, "YOU": 3, "Activated": False}
53-
ed = MultiDict({"YOU": 3, "Activated": "false"})
54-
self.assertEquals(transform_params(d).to_dict(flat=False), ed.to_dict(flat=False))
50+
ed = {"YOU": 3, "Activated": "false"}
51+
self.assertEquals(transform_params(d), ed)
5552

5653
def test_normalize_dates(self):
5754

twilio/rest/resources/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,8 @@ def create_instance(self, body):
313313
resp, instance = self.request("POST", self.uri,
314314
data=transform_params(body))
315315

316-
if resp.status_code != 201:
317-
raise TwilioRestException(resp.status,
316+
if resp.status_code not in (200, 201):
317+
raise TwilioRestException(resp.status_code,
318318
self.uri, "Resource not created")
319319

320320
return self.load_instance(instance)

twilio/rest/resources/sip.py

Lines changed: 0 additions & 60 deletions
This file was deleted.

twilio/rest/resources/sip/__init__.py

Lines changed: 3 additions & 0 deletions
+
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99

1010
class Sip(object):
1111
"""Holds all the SIP resources."""
12+
name = "SIP"
13+
key = "sip"
14
1215
def __init__(self, base_uri, auth, timeout):
1316
self.uri = "%s/SIP" % base_uri
1417
self.auth = auth

0 commit comments

Comments
 (0)
0