Skip to content

Commit 06e38d4

Browse files
Style fixes for tests
1 parent 484456b commit 06e38d4

10 files changed

+176
-127
lines changed

tests/test_call_flow.py

Lines changed: 98 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,28 @@ class TestCallFlow(unittest.TestCase):
1414
def test_get_flow(self):
1515
http_client = Mock()
1616
http_client.request.return_value = '''{
17-
"data": [
18-
{
19-
"id": "de3ed163-d5fc-45f4-b8c4-7eea7458c635",
20-
"title": "Updated call flow",
21-
"record": false,
22-
"steps": [
23-
{
24-
"id": "3538a6b8-5a2e-4537-8745-f72def6bd393",
25-
"action": "transfer",
26-
"options": {
27-
"destination": "31611223344"
17+
"data": [
18+
{
19+
"id": "de3ed163-d5fc-45f4-b8c4-7eea7458c635",
20+
"title": "Updated call flow",
21+
"record": false,
22+
"steps": [
23+
{
24+
"id": "3538a6b8-5a2e-4537-8745-f72def6bd393",
25+
"action": "transfer",
26+
"options": {
27+
"destination": "31611223344"
28+
}
29+
}
30+
],
31+
"createdAt": "2017-03-06T13:34:14Z",
32+
"updatedAt": "2017-03-06T15:02:38Z"
33+
}
34+
],
35+
"_links": {
36+
"self": "/call-flows/de3ed163-d5fc-45f4-b8c4-7eea7458c635"
2837
}
2938
}
30-
],
31-
"createdAt": "2017-03-06T13:34:14Z",
32-
"updatedAt": "2017-03-06T15:02:38Z"
33-
}
34-
],
35-
"_links": {
36-
"self": "/call-flows/de3ed163-d5fc-45f4-b8c4-7eea7458c635"
37-
}
38-
}
3939
'''
4040

4141
call_flow = Client('', http_client).call_flow('de3ed163-d5fc-45f4-b8c4-7eea7458c635')
@@ -47,56 +47,56 @@ def test_get_flow(self):
4747
def test_get_flow_list(self):
4848
http_client = Mock()
4949
http_client.request.return_value = '''{
50-
"data": [
51-
{
52-
"id": "de3ed163-d5fc-45f4-b8c4-7eea7458c635",
53-
"title": "Forward call to 31612345678",
54-
"record": false,
55-
"steps": [
56-
{
57-
"id": "3538a6b8-5a2e-4537-8745-f72def6bd393",
58-
"action": "transfer",
59-
"options": {
60-
"destination": "31612345678"
50+
"data": [
51+
{
52+
"id": "de3ed163-d5fc-45f4-b8c4-7eea7458c635",
53+
"title": "Forward call to 31612345678",
54+
"record": false,
55+
"steps": [
56+
{
57+
"id": "3538a6b8-5a2e-4537-8745-f72def6bd393",
58+
"action": "transfer",
59+
"options": {
60+
"destination": "31612345678"
61+
}
62+
}
63+
],
64+
"createdAt": "2017-03-06T13:34:14Z",
65+
"updatedAt": "2017-03-06T13:34:14Z",
66+
"_links": {
67+
"self": "/call-flows/de3ed163-d5fc-45f4-b8c4-7eea7458c635"
68+
}
69+
},
70+
{
71+
"id": "de3ed163-d5fc-45f4-b8c4-7eea7458c634",
72+
"title": "Forward call to 0600123123",
73+
"record": true,
74+
"steps": [
75+
{
76+
"id": "3538a6b8-5a2e-4537-8745-f72def6bd393",
77+
"action": "transfer",
78+
"options": {
79+
"destination": "31612345678"
80+
}
81+
}
82+
],
83+
"createdAt": "2017-03-06T13:34:14Z",
84+
"updatedAt": "2017-03-06T13:34:14Z",
85+
"_links": {
86+
"self": "/call-flows/de3ed163-d5fc-45f4-b8c4-7eea7458c634"
87+
}
88+
}
89+
],
90+
"_links": {
91+
"self": "/call-flows?page=1"
92+
},
93+
"pagination": {
94+
"totalCount": 2,
95+
"pageCount": 2,
96+
"currentPage": 1,
97+
"perPage": 10
6198
}
6299
}
63-
],
64-
"createdAt": "2017-03-06T13:34:14Z",
65-
"updatedAt": "2017-03-06T13:34:14Z",
66-
"_links": {
67-
"self": "/call-flows/de3ed163-d5fc-45f4-b8c4-7eea7458c635"
68-
}
69-
},
70-
{
71-
"id": "de3ed163-d5fc-45f4-b8c4-7eea7458c634",
72-
"title": "Forward call to 0600123123",
73-
"record": true,
74-
"steps": [
75-
{
76-
"id": "3538a6b8-5a2e-4537-8745-f72def6bd393",
77-
"action": "transfer",
78-
"options": {
79-
"destination": "31612345678"
80-
}
81-
}
82-
],
83-
"createdAt": "2017-03-06T13:34:14Z",
84-
"updatedAt": "2017-03-06T13:34:14Z",
85-
"_links": {
86-
"self": "/call-flows/de3ed163-d5fc-45f4-b8c4-7eea7458c634"
87-
}
88-
}
89-
],
90-
"_links": {
91-
"self": "/call-flows?page=1"
92-
},
93-
"pagination": {
94-
"totalCount": 2,
95-
"pageCount": 2,
96-
"currentPage": 1,
97-
"perPage": 10
98-
}
99-
}
100100
'''
101101

102102
call_flow_list = Client('', http_client).call_flow_list(20, 0)
@@ -109,33 +109,34 @@ def test_get_flow_list(self):
109109
def test_numbers_list(self):
110110
http_client = Mock()
111111
http_client.request.return_value = '''{
112-
"data": [
113-
{
114-
"id": "13f38f34-7ff4-45b3-8783-8d5b1143f22b",
115-
"number": "31611111111",
116-
"callFlowId": "de3ed163-d5fc-45f4-b8c4-7eea7458c635",
117-
"createdAt": "2017-03-16T13:49:24Z",
118-
"updatedAt": "2017-09-12T08:59:50Z",
119-
"_links": {
120-
"self": "/numbers/13f38f34-7ff4-45b3-8783-8d5b1143f22b"
121-
}
122-
}
123-
],
124-
"_links": {
125-
"self": "/call-flows/de3ed163-d5fc-45f4-b8c4-7eea7458c635/numbers?page=1"
126-
},
127-
"pagination": {
128-
"totalCount": 1,
129-
"pageCount": 1,
130-
"currentPage": 1,
131-
"perPage": 10
132-
}
133-
}
112+
"data": [
113+
{
114+
"id": "13f38f34-7ff4-45b3-8783-8d5b1143f22b",
115+
"number": "31611111111",
116+
"callFlowId": "de3ed163-d5fc-45f4-b8c4-7eea7458c635",
117+
"createdAt": "2017-03-16T13:49:24Z",
118+
"updatedAt": "2017-09-12T08:59:50Z",
119+
"_links": {
120+
"self": "/numbers/13f38f34-7ff4-45b3-8783-8d5b1143f22b"
121+
}
122+
}
123+
],
124+
"_links": {
125+
"self": "/call-flows/de3ed163-d5fc-45f4-b8c4-7eea7458c635/numbers?page=1"
126+
},
127+
"pagination": {
128+
"totalCount": 1,
129+
"pageCount": 1,
130+
"currentPage": 1,
131+
"perPage": 10
132+
}
133+
}
134134
'''
135135

136136
number_list = Client('', http_client).call_flow_numbers_list('de3ed163-d5fc-45f4-b8c4-7eea7458c635')
137137

138-
http_client.request.assert_called_once_with('call-flows/de3ed163-d5fc-45f4-b8c4-7eea7458c635/numbers', 'GET', None)
138+
http_client.request.assert_called_once_with('call-flows/de3ed163-d5fc-45f4-b8c4-7eea7458c635/numbers', 'GET',
139+
None)
139140

140141
self.assertEqual('31611111111', number_list.data[0].number)
141142
self.assertEqual(1, number_list.pagination['totalCount'])
@@ -144,9 +145,12 @@ def test_numbers_add(self):
144145
http_client = Mock()
145146
http_client.request.return_value = '{}'
146147

147-
Client('', http_client).call_flow_numbers_add('de3ed163-d5fc-45f4-b8c4-7eea7458c635',
148-
['31611111111', '31611111112'])
148+
Client('', http_client).call_flow_numbers_add(
149+
'de3ed163-d5fc-45f4-b8c4-7eea7458c635',
150+
['31611111111', '31611111112']
151+
)
149152

150153
params = {'numbers': ['31611111111', '31611111112']}
151154

152-
http_client.request.assert_called_once_with('call-flows/de3ed163-d5fc-45f4-b8c4-7eea7458c635/numbers', 'POST', params)
155+
http_client.request.assert_called_once_with(
156+
'call-flows/de3ed163-d5fc-45f4-b8c4-7eea7458c635/numbers', 'POST', params)

tests/test_contact.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ def test_contact_create(self):
3030

3131
Client('', http_client).contact_create(31612345678, {'firstName': 'Foo', 'custom3': 'Third'})
3232

33-
http_client.request.assert_called_once_with('contacts', 'POST', {'msisdn': 31612345678, 'firstName': 'Foo', 'custom3': 'Third'})
33+
http_client.request.assert_called_once_with(
34+
'contacts', 'POST', {'msisdn': 31612345678, 'firstName': 'Foo', 'custom3': 'Third'})
3435

3536
def test_contact_delete(self):
3637
http_client = Mock()
@@ -55,7 +56,9 @@ def test_contact_update(self):
5556

5657
Client('', http_client).contact_update('contact-id', {'msisdn': 31687654321, 'custom4': 'fourth'})
5758

58-
http_client.request.assert_called_once_with('contacts/contact-id', 'PATCH', {'msisdn': 31687654321, 'custom4': 'fourth'})
59+
http_client.request.assert_called_once_with(
60+
'contacts/contact-id', 'PATCH', {'msisdn': 31687654321, 'custom4': 'fourth'}
61+
)
5962

6063
def test_contact_list(self):
6164
http_client = Mock()

tests/test_conversation_webhook.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,16 @@ def test_conversation_webhook_read(self):
7070
def test_conversation_webhook_update(self):
7171
http_client = Mock()
7272
http_client.request.return_value = json.dumps({"id": "985ae50937a94c64b392531ea87a0263",
73-
"url": "https://example.com/webhook",
74-
"channelId": "853eeb5348e541a595da93b48c61a1ae",
75-
"events": [
76-
"message.created",
77-
"message.updated",
78-
],
79-
"status": "enabled",
80-
"createdDatetime": "2018-08-29T10:04:23Z",
81-
"updatedDatetime": "2018-08-29T10:10:23Z"
82-
})
73+
"url": "https://example.com/webhook",
74+
"channelId": "853eeb5348e541a595da93b48c61a1ae",
75+
"events": [
76+
"message.created",
77+
"message.updated",
78+
],
79+
"status": "enabled",
80+
"createdDatetime": "2018-08-29T10:04:23Z",
81+
"updatedDatetime": "2018-08-29T10:10:23Z"
82+
})
8383

8484
webhookRequestData = {
8585
'events': [CONVERSATION_WEBHOOK_EVENT_CONVERSATION_CREATED,
@@ -88,4 +88,4 @@ def test_conversation_webhook_update(self):
8888
'status': 'enabled'
8989
}
9090
web_hook = Client('', http_client).conversation_update_webhook('webhook-id', webhookRequestData)
91-
http_client.request.assert_called_once_with('webhooks/webhook-id', 'PATCH', webhookRequestData)
91+
http_client.request.assert_called_once_with('webhooks/webhook-id', 'PATCH', webhookRequestData)

tests/test_group.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ def test_group_add_contacts(self):
6464

6565
Client('', http_client).group_add_contacts('group-id', ['contact-id', 'other-contact-id'])
6666

67-
http_client.request.assert_called_once_with('groups/group-id?ids[]=contact-id&ids[]=other-contact-id', 'PUT', None)
67+
http_client.request.assert_called_once_with('groups/group-id?ids[]=contact-id&ids[]=other-contact-id', 'PUT',
68+
None)
6869

6970
def test_group_remove_contact(self):
7071
http_client = Mock()

tests/test_message.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,18 @@ def test_message_create(self):
2525
http_client = Mock()
2626
http_client.request.return_value = '{}'
2727

28-
Client('', http_client).message_create('MessageBird', ['31612345678', '31687654321'], 'Hello World', {'datacoding': 'unicode'})
29-
30-
http_client.request.assert_called_once_with('messages', 'POST', {'datacoding': 'unicode', 'originator': 'MessageBird', 'body': 'Hello World', 'recipients': '31612345678,31687654321' })
28+
Client('', http_client).message_create(
29+
'MessageBird', ['31612345678', '31687654321'], 'Hello World', {'datacoding': 'unicode'})
30+
31+
http_client.request.assert_called_once_with(
32+
'messages', 'POST',
33+
{
34+
'datacoding': 'unicode',
35+
'originator': 'MessageBird',
36+
'body': 'Hello World',
37+
'recipients': '31612345678,31687654321'
38+
}
39+
)
3140

3241
def test_message_delete(self):
3342
http_client = Mock()

tests/test_mms.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ def test_create_mms(self):
1515
http_client = Mock()
1616
http_client.request.return_value = '{"originator": "test-org", "body": "Rich test message", "direction": "mt", "recipients": {"totalCount": 1, "totalSentCount": 1, "totalDeliveredCount": 0, "totalDeliveryFailedCount": 0, "items": [{"status": "sent", "statusDatetime": "2019-06-04T13:54:48+00:00", "recipient": 4915238456487}]}, "reference": null, "createdDatetime": "2019-06-04T13:54:48+00:00", "href": "https://rest.messagebird.com/mms/0a75f8f82b5d4377bd8fb5b22ac1e8ac", "mediaUrls": ["https://www.messagebird.com/assets/images/og/messagebird.gif"], "scheduledDatetime": null, "id": "0a75f8f82b5d4377bd8fb5b22ac1e8ac", "subject": null}'
1717

18-
params = {"originator": "test-org", "body": "Rich test message","recipients":"+4915238456487","mediaUrls":"https://www.messagebird.com/assets/images/og/messagebird.gif"}
18+
params = {
19+
"originator": "test-org",
20+
"body": "Rich test message",
21+
"recipients": "+4915238456487",
22+
"mediaUrls": "https://www.messagebird.com/assets/images/og/messagebird.gif"
23+
}
1924
mms = Client('', http_client).mms_create(**params)
2025

2126
params["mediaUrls"] = [params["mediaUrls"]]
@@ -24,4 +29,4 @@ def test_create_mms(self):
2429

2530
self.assertEqual(params["originator"], mms.originator)
2631
self.assertEqual(params["recipients"].strip("+"), str(mms.recipients["items"][0].recipient))
27-
self.assertEqual(1,len(mms.recipients["items"]))
32+
self.assertEqual(1, len(mms.recipients["items"]))

tests/test_verify.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,3 @@ def test_verify_delete_invalid(self):
5555
Client('', http_client).verify_delete('non-existent-verify-id')
5656

5757
http_client.request.assert_called_once_with('verify/non-existent-verify-id', 'DELETE', None)
58-

0 commit comments

Comments
 (0)