forked from twilio/twilio-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_messages.py
More file actions
54 lines (44 loc) · 1.51 KB
/
test_messages.py
File metadata and controls
54 lines (44 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from datetime import date
import unittest
from mock import Mock
from six import u
from twilio.rest.resources import Messages
DEFAULT = {
'From': None,
'DateSent<': None,
'DateSent>': None,
'DateSent': None,
}
class MessageTest(unittest.TestCase):
def setUp(self):
self.resource = Messages("foo", ("sid", "token"))
self.params = DEFAULT.copy()
def test_list_on(self):
self.resource.get_instances = Mock()
self.resource.list(date_sent=date(2011, 1, 1))
self.params['DateSent'] = "2011-01-01"
self.resource.get_instances.assert_called_with(self.params)
def test_list_after(self):
self.resource.get_instances = Mock()
self.resource.list(after=date(2011, 1, 1))
self.params['DateSent>'] = "2011-01-01"
self.resource.get_instances.assert_called_with(self.params)
def test_list_before(self):
self.resource.get_instances = Mock()
self.resource.list(before=date(2011, 1, 1))
self.params['DateSent<'] = "2011-01-01"
self.resource.get_instances.assert_called_with(self.params)
def test_create(self):
self.resource.create_instance = Mock()
self.resource.create(
from_='+14155551234',
to='+14155556789',
body=u('ahoy hoy'),
)
self.resource.create_instance.assert_called_with(
{
'from': '+14155551234',
'to': '+14155556789',
'body': u('ahoy hoy'),
},
)