8000 Merge branch 'master' of github.com:twilio/twilio-python · jseims/twilio-python@e770205 · GitHub
[go: up one dir, main page]

Skip to content

Commit e770205

Browse files
author
Kevin Burke
committed
Merge branch 'master' of github.com:twilio/twilio-python
2 parents fd89fec + bacffdf commit e770205

File tree

8 files changed

+48
-7
lines changed

8 files changed

+48
-7
lines changed

CHANGES

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ twilio-python Changelog
33

44
Here you can see the full list of changes between each twilio-python release.
55

6+
Version 3.3.5
7+
-------------
8+
9+
Released on January 18, 2011
10+
11+
- Fix a bug with the depreacted `TwilioRestClient.request` method
12+
- Fix a bug in filtering SMS messages by DateSent
13+
614
Version 3.3.4
715
-------------
816

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
# The short X.Y version.
5858
version = '3.3'
5959
# The full version, including alpha/beta/rc tags.
60-
release = '3.3.4'
60+
release = '3.3.5'
6161

6262
# The language for content autogenerated by Sphinx. Refer to documentation
6363
# for a list of supported languages.

tests/test_client.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,32 @@
11
import unittest
22
from twilio.rest import TwilioRestClient
33
from twilio.rest import resources
4-
4+
from mock import patch, Mock
55

66
class RestClientTest(unittest.TestCase):
77

88
def setUp(self):
99
self.client = TwilioRestClient("ACCOUNT_SID", "AUTH_TOKEN")
1010

11+
12+
@patch("twilio.rest.make_request")
13+
def test_request(self, mock):
14+
self.client.request("2010-04-01", method="GET")
15+
mock.assert_called_with("GET", "https://api.twilio.com/2010-04-01",
16+
headers={"User-Agent": 'twilio-python'}, params={},
17+
auth=("ACCOUNT_SID", "AUTH_TOKEN"), data=None)
18+
1119
def test_connect_apps(self):
1220
self.assertIsInstance(self.client.connect_apps,
1321
resources.ConnectApps)
1422

1523
def test_authorized_apps(self):
1624
self.assertIsInstance(self.client.authorized_connect_apps,
1725
resources.AuthorizedConnectApps)
26+
27+
@patch("twilio.rest.resources.make_request")
28+
def test_conferences(self, mock):
29+
mock.return_value = Mock()
30+
mock.return_value.ok = True
31+
mock.return_value.content = '{"conferences": []}'
32+
self.client.conferences.list()

tests/test_conferences.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ class ConferenceTest(unittest.TestCase):
99
def setUp(self):
1010
self.resource = Conferences("foo", ("sid", "token"))
1111

12+
def test_list(self):
13+
self.resource.get_instances = Mock()
14+
self.resource.list()
15+
self.resource.get_instances.assert_called_with(params={})
16+
1217
def test_list_after(self):
1318
self.resource.get_instances = Mock()
1419
self.resource.list(created_after=date(2011, 1, 1))

tests/test_sms_messages.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ class SmsTest(unittest.TestCase):
99
def setUp(self):
1010
self.resource = SmsMessages("foo", ("sid", "token"))
1111

12+
def test_list_on(self):
13+
self.resource.get_instances = Mock()
14+
self.resource.list(date_sent=date(2011, 1, 1))
15+
self.resource.get_instances.assert_called_with(params={
16+
"DateSent": "2011-01-01"})
17+
1218
def test_list_after(self):
1319
self.resource.get_instances = Mock()
1420
self.resource.list(after=date(2011, 1, 1))

twilio/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version_info__ = ('3', '3', '4')
1+
__version_info__ = ('3', '3', '5')
22
__version__ = '.'.join(__version_info__)
33

44

twilio/rest/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ def request(self, path, method=None, vars=None):
6565
'HTTP %s method not implemented' % method)
6666

6767
if path[0] == '/':
68-
uri = _TWILIO_API_URL + path
68+
uri = self.base + path
6969
else:
70-
uri = _TWILIO_API_URL + '/' + path
70+
uri = self.base + '/' + path
7171

7272
if method == "GET":
7373
params = vars
@@ -108,7 +108,8 @@ def __init__(self, account=None, token=None, base="https://api.twilio.com",
108108
and be sure to replace the values for the Account SID and auth token with the
109109
values from your Twilio Account at https://www.twilio.com/user/account.
110110
""")
111-
111+
112+
self.base = base
112113
auth = (account, token)
113114
version_uri = "%s/%s" % (base, version)
114115
account_uri = "%s/%s/Accounts/%s" % (base, version, account)

twilio/rest/resources.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1062,12 +1062,17 @@ def create(self, to=None, from_=None, body=None, status_callback=None,
10621062
return self.create_instance(params)
10631063

10641064
@normalize_dates
1065-
def list(self, to=None, from_=None, before=None, after=None, **kwargs):
1065+
def list(self, to=None, from_=None, before=None, after=None,
1066+
date_sent=None, **kwargs):
10661067
"""
10671068
Returns a page of :class:`SMSMessage` resources as a list. For
10681069
paging informtion see :class:`ListResource`.
10691070
10701071
:param to: Only show SMS messages to this phone number.
1072+
:param from_: Only show SMS messages from this phone number.
1073+
:param date after: Only list SMS messages sent after this date.
1074+
:param date before: Only list SMS message sent before this date.
1075+
:param date date_sent: Only list SMS message sent on this date.
10711076
:param `from_`: Only show SMS messages from this phone number.
10721077
:param date after: Only list recordings logged after this datetime
10731078
:param date before: Only list recordings logged before this datetime
@@ -1077,6 +1082,7 @@ def list(self, to=None, from_=None, before=None, after=None, **kwargs):
10771082
"From": from_,
10781083
"DateSent<": before,
10791084
"DateSent>": after,
1085+
"DateSent": parse_date(date_sent),
10801086
})
10811087
return self.get_instances(params=params, **kwargs)
10821088

0 commit comments

Comments
 (0)
0