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

Skip to content

Commit ca877ac

Browse files
author
Doug Black
committed
Merge branch 'master' of github.com:twilio/twilio-python
2 parents 24c7e78 + 22ef5cd commit ca877ac

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ python:
44
- "2.7"
55
- "3.2"
66
- "3.3"
7+
- "3.4"
78
install:
89
- pip install . --use-mirrors
910
- pip install -r requirements.txt --use-mirrors

tests/test_calls.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,18 @@ def test_paging(mock):
4343
mock.assert_called_with("GET", uri, params=exp_params, auth=AUTH)
4444

4545

46+
@patch("twilio.rest.resources.base.make_twilio_request")
47+
def test_paging_iter(mock):
48+
resp = create_mock_json("tests/resources/calls_list.json")
49+
mock.return_value = resp
50+
51+
uri = "%s/Calls" % (BASE_URI)
52+
next(list_resource.iter(started_before=date(2010, 12, 5)))
53+
exp_params = {'StartTime<': '2010-12-05'}
54+
55+
mock.assert_called_with("GET", uri, params=exp_params, auth=AUTH)
56+
57+
4658
@patch("twilio.rest.resources.base.make_twilio_request")
4759
def test_get(mock):
4860
resp = create_mock_json("tests/resources/calls_instance.json")

twilio/rest/resources/calls.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,25 @@ def list(self, from_=None, ended_after=None,
8585
kwargs["EndTime"] = parse_date(ended)
8686
return self.get_instances(kwargs)
8787

88+
@normalize_dates
89+
def iter(self, from_=None, ended_after=None,
90+
ended_before=None, ended=None, started_before=None,
91+
started_after=None, started=None, **kwargs):
92+
"""
93+
Returns an iterator of :class:`Call` resources.
94+
95+
:param date after: Only list calls started after this datetime
96+
:param date before: Only list calls started before this datetime
97+
"""
98+
kwargs["from"] = from_
99+
kwargs["StartTime<"] = started_before
100+
kwargs["StartTime>"] = started_after
101+
kwargs["StartTime"] = parse_date(started)
102+
kwargs["EndTime<"] = ended_before
103+
kwargs["EndTime>"] = ended_after
104+
kwargs["EndTime"] = parse_date(ended)
105+
return super(Calls, self).iter(**kwargs)
106+
88107
def create(self, to, from_, url, status_method=None, **kwargs):
89108
"""
90109
Make a phone call to a number.

0 commit comments

Comments
 (0)
0