Skip to content

Commit 657f5d1

Browse files
Serge KamelSerge Kamel
authored andcommitted
test: add voicemessages listing test case.
1 parent 82f4485 commit 657f5d1

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

tests/test_voicemessage.py

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,40 @@ def test_voicemessage(self):
1515
http_client = Mock()
1616
http_client.request.return_value = '{"body": "Hello World","createdDatetime": "2015-01-05T16:11:24+00:00","href": "https://rest.messagebird.com/voicemessages/voicemessage-id","id": "voicemessage-id","ifMachine": "continue","language": "en-gb","originator": "MessageBird","recipients": {"items": [{"recipient": 31612345678,"status": "calling","statusDatetime": "2015-01-05T16:11:24+00:00"}],"totalCount": 1,"totalDeliveredCount": 0,"totalDeliveryFailedCount": 0,"totalSentCount": 1},"reference": null,"repeat": 1,"scheduledDatetime": null,"voice": "female"}'
1717

18-
voice_message = Client('', http_client).voice_message('voicemessage-id')
18+
voice_message = Client(
19+
'', http_client).voice_message('voicemessage-id')
1920

20-
http_client.request.assert_called_once_with('voicemessages/voicemessage-id', 'GET', None)
21+
http_client.request.assert_called_once_with(
22+
'voicemessages/voicemessage-id', 'GET', None)
2123

2224
self.assertEqual('voicemessage-id', voice_message.id)
2325

26+
def test_voicemessages_list(self):
27+
http_client = Mock()
28+
http_client.request.return_value = '{ "offset": 0, "limit": 10, "count": 2, "totalCount": 2, "links": { "first": "https://rest.messagebird.com/voicemessages/?offset=0&limit=30", "previous": null, "next": null, "last": "https://rest.messagebird.com/voicemessages/?offset=0&limit=30" }, "items": [ { "id": "12345678-9012-3456-7890-123456789012", "href": "https://rest.messagebird.com/voicemessages/12345678-9012-3456-7890-123456789012", "originator": null, "body": "This is a test message.", "reference": null, "language": "en-gb", "voice": "male", "repeat": 1, "ifMachine": "continue", "machineTimeout": 7000, "scheduledDatetime": null, "createdDatetime": "2020-02-04T15:15:30+00:00", "recipients": { "totalCount": 1, "totalSentCount": 1, "totalDeliveredCount": 1, "totalDeliveryFailedCount": 0, "items": [ { "recipient": 31612345678, "originator": null, "status": "answered", "statusDatetime": "2020-02-04T15:15:57+00:00" } ] } }, { "id": "12345678-9012-3456-7890-123456789013", "href": "https://rest.messagebird.com/voicemessages/12345678-9012-3456-7890-123456789013", "originator": null, "body": "The voice message to be sent", "reference": null, "language": "en-gb", "voice": "female", "repeat": 1, "ifMachine": "delay", "machineTimeout": 7000, "scheduledDatetime": null, "createdDatetime": "2020-02-04T12:26:44+00:00", "recipients": { "totalCount": 1, "totalSentCount": 1, "totalDeliveredCount": 1, "totalDeliveryFailedCount": 0, "items": [ { "recipient": 31612345678, "originator": null, "status": "answered", "statusDatetime": "2020-02-04T12:27:32+00:00" } ] } } ] }'
29+
30+
voice_messages = Client('', http_client).voice_message_list()
31+
32+
http_client.request.assert_called_once_with(
33+
'voicemessages?limit=10&offset=0', 'GET', None)
34+
35+
voice_messages_check = {
36+
'12345678-9012-3456-7890-123456789012': {
37+
"id": '12345678-9012-3456-7890-123456789012',
38+
"href": "https://rest.messagebird.com/voicemessages/12345678-9012-3456-7890-123456789012"
39+
},
40+
'12345678-9012-3456-7890-123456789013': {
41+
"id": '12345678-9012-3456-7890-123456789013',
42+
"href": "https://rest.messagebird.com/voicemessages/12345678-9012-3456-7890-123456789013"
43+
}
44+
}
45+
46+
for item in voice_messages.items:
47+
message_specific = voice_messages_check.get(item.id)
48+
self.assertEqual(message_specific['id'], item.id)
49+
self.assertEqual(message_specific['href'], item.href)
50+
self.assertIsInstance(str(voice_messages), str)
51+
2452
def test_voicemessage_create(self):
2553
http_client = Mock()
2654
http_client.request.return_value = '{}'

0 commit comments

Comments
 (0)