Python unittest.mock.Mock() Examples
The following are 30
code examples of unittest.mock.Mock().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
unittest.mock
, or try the search function
.

Example #1
Source File: test_voice_webhook.py From python-rest-api with BSD 2-Clause "Simplified" License | 6 votes |
def test_voice_create_webhook(self): http_client = Mock() http_client.request.return_value = '''{ "data": [ { "id": "534e1848-235f-482d-983d-e3e11a04f58a", "url": "https://example.com/", "token": "foobar", "createdAt": "2017-03-15T14:10:07Z", "updatedAt": "2017-03-15T14:10:07Z" } ], "_links": { "self": "/webhooks/534e1848-235f-482d-983d-e3e11a04f58a" } }''' create_webhook_request = VoiceCreateWebhookRequest(url="https://example.com/", title="FooBar", token="foobar") created_webhook = Client('', http_client).voice_create_webhook(create_webhook_request) http_client.request.assert_called_once_with(VOICE_API_ROOT + '/' + VOICE_WEB_HOOKS_PATH, 'POST', create_webhook_request.__dict__()) self.assertEqual(create_webhook_request.url, created_webhook.url) self.assertEqual(create_webhook_request.token, created_webhook.token)
Example #2
Source File: test_voice_recording.py From python-rest-api with BSD 2-Clause "Simplified" License | 6 votes |
def test_voice_recording_view(self): http_client = Mock() http_client.request.return_value = '{"data":[{"id":"12345678-9012-3456-7890-123456789012","format":"wav","legId":"87654321-0987-6543-2109-876543210987","status":"done","duration":32,"type":"transfer","createdAt":"2018-01-01T00:00:01Z","updatedAt":"2018-01-01T00:00:05Z","deletedAt":null}],"_links":{"file":"/calls/12348765-4321-0987-6543-210987654321/legs/87654321-0987-6543-2109-876543210987/recordings/12345678-9012-3456-7890-123456789012.wav","self":"/calls/12345678-9012-3456-7890-123456789012/legs/12348765-4321-0987-6543-210987654321/recordings/12345678-9012-3456-7890-123456789012"},"pagination":{"totalCount":0,"pageCount":0,"currentPage":0,"perPage":0}}' voice_recording = Client('', http_client).voice_recording_view( '12348765-4321-0987-6543-210987654321', '87654321-0987-6543-2109-876543210987', '12345678-9012-3456-7890-123456789012' ) http_client.request.assert_called_once_with( 'https://voice.messagebird.com/calls/12348765-4321-0987-6543-210987654321/legs/87654321-0987-6543-2109-876543210987/recordings/12345678-9012-3456-7890-123456789012', 'GET', None) self.assertEqual('12345678-9012-3456-7890-123456789012', voice_recording.id) self.assertEqual('done', voice_recording.status) self.assertEqual('wav', voice_recording.format) self.assertEqual(datetime(2018, 1, 1, 0, 0, 1, tzinfo=tzutc()), voice_recording.createdAt) self.assertEqual(datetime(2018, 1, 1, 0, 0, 5, tzinfo=tzutc()), voice_recording.updatedAt) self.assertEqual(2, len(voice_recording._links)) self.assertIsInstance(str(voice_recording), str)
Example #3
Source File: test_conversation_webhook.py From python-rest-api with BSD 2-Clause "Simplified" License | 6 votes |
def test_conversation_webhook_update(self): http_client = Mock() http_client.request.return_value = json.dumps({"id": "985ae50937a94c64b392531ea87a0263", "url": "https://example.com/webhook", "channelId": "853eeb5348e541a595da93b48c61a1ae", "events": [ "message.created", "message.updated", ], "status": "enabled", "createdDatetime": "2018-08-29T10:04:23Z", "updatedDatetime": "2018-08-29T10:10:23Z" }) webhookRequestData = { 'events': [CONVERSATION_WEBHOOK_EVENT_CONVERSATION_CREATED, CONVERSATION_WEBHOOK_EVENT_CONVERSATION_UPDATED], 'url': 'https://example.com/webhook', 'status': 'enabled' } web_hook = Client('', http_client).conversation_update_webhook('webhook-id', webhookRequestData) http_client.request.assert_called_once_with('webhooks/webhook-id', 'PATCH', webhookRequestData)
Example #4
Source File: test_message.py From python-rest-api with BSD 2-Clause "Simplified" License | 6 votes |
def test_message_create(self): http_client = Mock() http_client.request.return_value = '{}' Client('', http_client).message_create( 'MessageBird', ['31612345678', '31687654321'], 'Hello World', {'datacoding': 'unicode'}) http_client.request.assert_called_once_with( 'messages', 'POST', { 'datacoding': 'unicode', 'originator': 'MessageBird', 'body': 'Hello World', 'recipients': '31612345678,31687654321' } )
Example #5
Source File: test_conversation_message.py From python-rest-api with BSD 2-Clause "Simplified" License | 6 votes |
def test_create_message(self): http_client = Mock() http_client.request.return_value = '{"id":"id","conversationId":"conversation-id","channelId":"channel-id","type":"text","content":{"text":"Example Text Message"},"direction":"sent","status":"pending","createdDatetime":"2019-04-02T11:57:52.142641447Z","updatedDatetime":"2019-04-02T11:57:53.142641447Z"}' data = { 'channelId': 1234, 'type': 'text', 'content': { 'text': 'this is a message' }, } msg = Client('', http_client).conversation_create_message('conversation-id', data) self.assertEqual(datetime(2019, 4, 2, 11, 57, 53, tzinfo=tzutc()), msg.updatedDatetime) self.assertEqual(datetime(2019, 4, 2, 11, 57, 52, tzinfo=tzutc()), msg.createdDatetime) http_client.request.assert_called_once_with('conversations/conversation-id/messages', 'POST', data)
Example #6
Source File: test_message.py From oslo.i18n with Apache License 2.0 | 6 votes |
def test_contextual_untranslatable(self, translation): msg_with_context = 'context' + _message.CONTEXT_SEPARATOR + 'message' lang = mock.Mock() translation.return_value = lang trans = mock.Mock() trans.return_value = msg_with_context lang.gettext = trans lang.ugettext = trans result = _message.Message._translate_msgid( ('context', 'message'), domain='domain', has_contextual_form=True, has_plural_form=False, ) self.assertEqual('message', result) trans.assert_called_with(msg_with_context)
Example #7
Source File: test_message.py From oslo.i18n with Apache License 2.0 | 6 votes |
def test_contextual(self, translation): lang = mock.Mock() translation.return_value = lang trans = mock.Mock() trans.return_value = 'translated' lang.gettext = trans lang.ugettext = trans result = _message.Message._translate_msgid( ('context', 'message'), domain='domain', has_contextual_form=True, has_plural_form=False, ) self.assertEqual('translated', result) trans.assert_called_with( 'context' + _message.CONTEXT_SEPARATOR + 'message' )
Example #8
Source File: test_voice_webhook.py From python-rest-api with BSD 2-Clause "Simplified" License | 6 votes |
def test_voice_update_webhook(self): http_client = Mock() http_client.request.return_value = '''{ "data": [ { "id": "534e1848-235f-482d-983d-e3e11a04f58a", "url": "https://example.com/baz", "token": "foobar", "createdAt": "2017-03-15T13:27:02Z", "updatedAt": "2017-03-15T13:28:01Z" } ], "_links": { "self": "/webhooks/534e1848-235f-482d-983d-e3e11a04f58a" } }''' webhook_id = '534e1848-235f-482d-983d-e3e11a04f58a' update_webhook_request = VoiceUpdateWebhookRequest(title="FooBar", token="foobar") updated_webhook = Client('', http_client).voice_update_webhook(webhook_id, update_webhook_request) http_client.request.assert_called_once_with( VOICE_API_ROOT + '/' + VOICE_WEB_HOOKS_PATH + '/' + webhook_id, 'PUT', update_webhook_request.__dict__()) self.assertEqual(update_webhook_request.token, updated_webhook.token)
Example #9
Source File: test_voice_transcription.py From python-rest-api with BSD 2-Clause "Simplified" License | 6 votes |
def test_download_voice_transcription(self): http_client = Mock() http_client.request.return_value = '' url = 'https://voice.messagebird.com/calls/' call_id = '74bd9fac-742e-4f7c-aef2-bf068c80fd00' leg_id = 'd931d0e8-3385-43b3-964b-c9dda2581213' recording_id = '4c444e1e-3cea-4b52-90f7-55dec7b2e05e' transcription_id = 'fb455b79-c4de-419f-8f72-8c199975c12a' Client('', http_client).voice_transcription_download( call_id, leg_id, recording_id, transcription_id ) http_client.request.assert_called_once_with( url + call_id + '/legs/' + leg_id + '/recordings/' + recording_id + '/transcriptions/' + transcription_id, 'GET', None )
Example #10
Source File: test_node_logicalnames.py From drydock with Apache License 2.0 | 6 votes |
def test_apply_logicalnames_else(self, input_files, deckhand_orchestrator, drydock_state, mock_get_build_data): """Test node apply_logicalnames hits the else block""" input_file = input_files.join("deckhand_fullsite.yaml") design_ref = "file://%s" % str(input_file) design_status, design_data = deckhand_orchestrator.get_effective_site( design_ref) def side_effect(**kwargs): return [] drydock_state.get_build_data = Mock(side_effect=side_effect) nodes = design_data.baremetal_nodes for n in nodes or []: n.apply_logicalnames(design_data, state_manager=drydock_state) assert n.logicalnames == {}
Example #11
Source File: test_voicemessage.py From python-rest-api with BSD 2-Clause "Simplified" License | 6 votes |
def test_voicemessages_list(self): http_client = Mock() 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" } ] } } ] }' voice_messages = Client('', http_client).voice_message_list() http_client.request.assert_called_once_with( 'voicemessages?limit=10&offset=0', 'GET', None) voice_messages_check = { '12345678-9012-3456-7890-123456789012': { "id": '12345678-9012-3456-7890-123456789012', "href": "https://rest.messagebird.com/voicemessages/12345678-9012-3456-7890-123456789012" }, '12345678-9012-3456-7890-123456789013': { "id": '12345678-9012-3456-7890-123456789013', "href": "https://rest.messagebird.com/voicemessages/12345678-9012-3456-7890-123456789013" } } for item in voice_messages.items: message_specific = voice_messages_check.get(item.id) self.assertEqual(message_specific['id'], item.id) self.assertEqual(message_specific['href'], item.href) self.assertIsInstance(str(voice_messages), str)
Example #12
Source File: conftest.py From drydock with Apache License 2.0 | 6 votes |
def mock_get_build_data(drydock_state): def side_effect(**kwargs): build_data = objects.BuildData( node_name="test", task_id="tid", generator="lshw", data_format="text/plain", data_element="<mocktest></mocktest>") return [build_data] drydock_state.real_get_build_data = drydock_state.get_build_data drydock_state.get_build_data = Mock(side_effect=side_effect) yield drydock_state.get_build_data = Mock(wraps=None, side_effect=None) drydock_state.get_build_data = drydock_state.real_get_build_data
Example #13
Source File: test_conversation.py From python-rest-api with BSD 2-Clause "Simplified" License | 6 votes |
def test_conversation_start(self): http_client = Mock() http_client.request.return_value = '{"id":"1234","contactId":"1234","contact":{"id":"1234","href":"https://contacts.messagebird.com/v2/contacts/1234","msisdn":99999999999,"displayName":"99999999999","firstName":"","lastName":"","customDetails":{},"attributes":{},"createdDatetime":"2019-04-02T08:19:37Z","updatedDatetime":"2019-04-02T08:19:38Z"},"channels":[{"id":"1234","name":"channel-name","platformId":"sms","status":"active","createdDatetime":"2019-04-01T15:25:12Z","updatedDatetime":"0001-01-01T00:00:00Z"}],"status":"active","createdDatetime":"2019-04-02T08:19:37Z","updatedDatetime":"2019-04-02T08:54:42.497114599Z","lastReceivedDatetime":"2019-04-02T08:54:42.464955904Z","lastUsedChannelId":"1234","messages":{"totalCount":1,"href":"https://conversations.messagebird.com/v1/conversations/1234/messages"}}' data = { 'channelId': '1234', 'to': '+99999999999', 'type': "text", 'content': { 'text': 'Message Example' }, } msg = Client('', http_client).conversation_start(data) http_client.request.assert_called_once_with('conversations/start', 'POST', data) self.assertEqual('1234', msg.id) self.assertEqual(99999999999, msg.contact.msisdn) self.assertEqual(datetime(2019, 4, 2, 8, 19, 37, tzinfo=tzutc()), msg.contact.createdDatetime) self.assertEqual(datetime(2019, 4, 2, 8, 19, 38, tzinfo=tzutc()), msg.contact.updatedDatetime) self.assertEqual('channel-name', msg.channels[0].name)
Example #14
Source File: test_components_repository_repository.py From skelebot with MIT License | 6 votes |
def test_execute_push_conflict_s3(self, mock_boto3_session): mock_client = mock.Mock() mock_session = mock.Mock() mock_client.list_objects_v2.return_value = {"Contents": [{"Key": "test_v1.0.0.pkl"}]} mock_session.client.return_value = mock_client mock_boto3_session.return_value = mock_session config = sb.objects.config.Config(version="1.0.0") args = argparse.Namespace(job="push", force=False, artifact='test', user='sean', token='abc123') expectedException = "This artifact version already exists. Please bump the version or use the force parameter (-f) to overwrite the artifact." try: self.s3.execute(config, args) self.fail("Exception Not Thrown") except Exception as exc: self.assertEqual(str(exc), expectedException) mock_client.list_objects_v2.assert_called_with(Bucket="my-bucket", Prefix="test_v1.0.0.pkl")
Example #15
Source File: test_number.py From python-rest-api with BSD 2-Clause "Simplified" License | 5 votes |
def test_available_numbers_list(self): http_client = Mock() http_client.request.return_value = '{"items":[{"number":"3197010260188","country":"NL","region":"","locality":"","features":["sms","voice"],"type":"mobile"}],"limit":20,"count":1}' numbers = Client('', http_client).available_numbers_list('NL', {'number': 319}) http_client.request.assert_called_once_with('available-phone-numbers/NL', 'GET', {'number': 319, 'limit': 20, 'offset': 0}) self.assertEqual(1, numbers.count) self.assertEqual(1, len(numbers.items)) self.assertEqual('3197010260188', numbers.items[0].number)
Example #16
Source File: test_verify.py From python-rest-api with BSD 2-Clause "Simplified" License | 5 votes |
def test_verify(self): http_client = Mock() http_client.request.return_value = '{"id": "verify-id","href": "https://rest.messagebird.com/verify/verify-id","recipient": 31612345678,"reference": "MyReference","messages": {"href": "https://rest.messagebird.com/messages/message-id"},"status": "verified","createdDatetime": "2017-05-30T12:39:50+00:00","validUntilDatetime": "2017-05-30T12:40:20+00:00"}' verify = Client('', http_client).verify('verify-id') http_client.request.assert_called_once_with('verify/verify-id', 'GET', None) self.assertEqual('verify-id', verify.id)
Example #17
Source File: test_number.py From python-rest-api with BSD 2-Clause "Simplified" License | 5 votes |
def test_purchased_numbers_list(self): http_client = Mock() http_client.request.return_value = '{"items":[{"number":"3197010260188","country":"NL","region":"","locality":"","features":["sms","voice"],"type":"mobile"}],"limit":20,"count":1}' numbers = Client('', http_client).purchased_numbers_list({'number': 319}, 40, 2) http_client.request.assert_called_once_with('phone-numbers', 'GET', {'number': 319, 'limit': 40, 'offset': 2}) self.assertEqual(1, numbers.count) self.assertEqual(1, len(numbers.items)) self.assertEqual('3197010260188', numbers.items[0].number)
Example #18
Source File: test_number.py From python-rest-api with BSD 2-Clause "Simplified" License | 5 votes |
def test_purchased_number(self): http_client = Mock() http_client.request.return_value = '{"number":"31612345670","country":"NL","region":"Texel","locality":"Texel","features":["sms","voice"],"tags":[],"type":"mobile","status":"active"}' number = Client('', http_client).purchased_number('31612345670') http_client.request.assert_called_once_with('phone-numbers/31612345670', 'GET', None) self.assertEqual('Texel', number.locality)
Example #19
Source File: test_verify.py From python-rest-api with BSD 2-Clause "Simplified" License | 5 votes |
def test_verify_verify(self): http_client = Mock() http_client.request.return_value = '{"id": "verify-id","href": "https://rest.messagebird.com/verify/verify-id","recipient": 31612345678,"reference": "MyReference","messages": {"href": "https://rest.messagebird.com/messages/63b168423592d681641eb07b76226648"},"status": "verified","createdDatetime": "2017-05-30T12:39:50+00:00","validUntilDatetime": "2017-05-30T12:40:20+00:00"}' verify = Client('', http_client).verify_verify('verify-id', 'secret') http_client.request.assert_called_once_with('verify/verify-id', 'GET', {'token': 'secret'}) self.assertEqual('verified', verify.status)
Example #20
Source File: test_verify.py From python-rest-api with BSD 2-Clause "Simplified" License | 5 votes |
def test_verify_create(self): http_client = Mock() http_client.request.return_value = '{}' Client('', http_client).verify_create('31612345678', {}) http_client.request.assert_called_once_with('verify', 'POST', {'recipient': '31612345678'})
Example #21
Source File: test_number.py From python-rest-api with BSD 2-Clause "Simplified" License | 5 votes |
def test_delete_number_invalid(self): http_client = Mock() http_client.request.return_value = '{"errors": [{"code": 20, "description": "number not found", "parameter": null}]}' with self.assertRaises(ErrorException): Client('', http_client).delete_number('non-existent-number') http_client.request.assert_called_once_with('phone-numbers/non-existent-number', 'DELETE', None)
Example #22
Source File: test_number.py From python-rest-api with BSD 2-Clause "Simplified" License | 5 votes |
def test_delete_number(self): http_client = Mock() http_client.request.return_value = '{}' Client('', http_client).delete_number('31971234567') http_client.request.assert_called_once_with('phone-numbers/31971234567', 'DELETE', None)
Example #23
Source File: test_conversation_webhook.py From python-rest-api with BSD 2-Clause "Simplified" License | 5 votes |
def test_conversation_webhook_delete(self): http_client = Mock() http_client.request.return_value = '' Client('', http_client).conversation_delete_webhook('webhook-id') http_client.request.assert_called_once_with('webhooks/webhook-id', 'DELETE', None)
Example #24
Source File: test_call_flow.py From python-rest-api with BSD 2-Clause "Simplified" License | 5 votes |
def test_numbers_add(self): http_client = Mock() http_client.request.return_value = '{}' Client('', http_client).call_flow_numbers_add( 'de3ed163-d5fc-45f4-b8c4-7eea7458c635', ['31611111111', '31611111112'] ) params = {'numbers': ['31611111111', '31611111112']} http_client.request.assert_called_once_with( 'call-flows/de3ed163-d5fc-45f4-b8c4-7eea7458c635/numbers', 'POST', params)
Example #25
Source File: test_call_flow.py From python-rest-api with BSD 2-Clause "Simplified" License | 5 votes |
def test_numbers_list(self): http_client = Mock() http_client.request.return_value = '''{ "data": [ { "id": "13f38f34-7ff4-45b3-8783-8d5b1143f22b", "number": "31611111111", "callFlowId": "de3ed163-d5fc-45f4-b8c4-7eea7458c635", "createdAt": "2017-03-16T13:49:24Z", "updatedAt": "2017-09-12T08:59:50Z", "_links": { "self": "/numbers/13f38f34-7ff4-45b3-8783-8d5b1143f22b" } } ], "_links": { "self": "/call-flows/de3ed163-d5fc-45f4-b8c4-7eea7458c635/numbers?page=1" }, "pagination": { "totalCount": 1, "pageCount": 1, "currentPage": 1, "perPage": 10 } } ''' number_list = Client('', http_client).call_flow_numbers_list('de3ed163-d5fc-45f4-b8c4-7eea7458c635') http_client.request.assert_called_once_with('call-flows/de3ed163-d5fc-45f4-b8c4-7eea7458c635/numbers', 'GET', None) self.assertEqual('31611111111', number_list.data[0].number) self.assertEqual(1, number_list.pagination['totalCount'])
Example #26
Source File: test_call_flow.py From python-rest-api with BSD 2-Clause "Simplified" License | 5 votes |
def test_get_flow(self): http_client = Mock() http_client.request.return_value = '''{ "data": [ { "id": "de3ed163-d5fc-45f4-b8c4-7eea7458c635", "title": "Updated call flow", "record": false, "steps": [ { "id": "3538a6b8-5a2e-4537-8745-f72def6bd393", "action": "transfer", "options": { "destination": "31611223344" } } ], "createdAt": "2017-03-06T13:34:14Z", "updatedAt": "2017-03-06T15:02:38Z" } ], "_links": { "self": "/call-flows/de3ed163-d5fc-45f4-b8c4-7eea7458c635" } } ''' call_flow = Client('', http_client).call_flow('de3ed163-d5fc-45f4-b8c4-7eea7458c635') http_client.request.assert_called_once_with('call-flows/de3ed163-d5fc-45f4-b8c4-7eea7458c635', 'GET', None) self.assertEqual('Updated call flow', call_flow.title) self.assertIsNotNone(call_flow.steps)
Example #27
Source File: test_voice_transcription.py From python-rest-api with BSD 2-Clause "Simplified" License | 5 votes |
def test_list_voice_transcription(self): http_client = Mock() http_client.request.return_value = ''' { "data": [ { "id": "fb455b79-c4de-419f-8f72-8c199975c12a", "recordingId": "4c444e1e-3cea-4b52-90f7-55dec7b2e05e", "status": "done", "createdAt": "2019-08-23T13:29:10Z", "updatedAt": "2019-08-23T13:29:21Z", "legId": "d931d0e8-3385-43b3-964b-c9dda2581213" } ], "_links": { "file": "/transcriptions/fb455b79-c4de-419f-8f72-8c199975c12a.txt", "self": "/transcriptions/fb455b79-c4de-419f-8f72-8c199975c12a" } } ''' url = 'https://voice.messagebird.com/calls/' call_id = '74bd9fac-742e-4f7c-aef2-bf068c80fd00' leg_id = 'd931d0e8-3385-43b3-964b-c9dda2581213' recording_id = '4c444e1e-3cea-4b52-90f7-55dec7b2e05e' msg = Client('', http_client).voice_transcription_list( call_id, leg_id, recording_id ) http_client.request.assert_called_once_with( url + call_id + '/legs/' + leg_id + '/recordings/' + recording_id + '/transcriptions', 'GET', None ) self.assertIsInstance(str(msg), str)
Example #28
Source File: test_voice_transcription.py From python-rest-api with BSD 2-Clause "Simplified" License | 5 votes |
def test_view_voice_transcription(self): http_client = Mock() http_client.request.return_value = ''' { "data": [ { "id": "fb455b79-c4de-419f-8f72-8c199975c12a", "recordingId": "4c444e1e-3cea-4b52-90f7-55dec7b2e05e", "status": "done", "createdAt": "2019-08-23T13:29:10Z", "updatedAt": "2019-08-23T13:29:21Z", "legId": "d931d0e8-3385-43b3-964b-c9dda2581213" } ], "_links": { "file": "/transcriptions/fb455b79-c4de-419f-8f72-8c199975c12a.txt", "self": "/transcriptions/fb455b79-c4de-419f-8f72-8c199975c12a" } } ''' url = 'https://voice.messagebird.com/calls/' call_id = '74bd9fac-742e-4f7c-aef2-bf068c80fd00' leg_id = 'd931d0e8-3385-43b3-964b-c9dda2581213' recording_id = '4c444e1e-3cea-4b52-90f7-55dec7b2e05e' transcription_id = 'fb455b79-c4de-419f-8f72-8c199975c12a' msg = Client('', http_client).voice_transcription_view( call_id, leg_id, recording_id, transcription_id ) http_client.request.assert_called_once_with( url + call_id + '/legs/' + leg_id + '/recordings/' + recording_id + '/transcriptions/' + transcription_id, 'GET', None ) self.assertIsInstance(str(msg), str)
Example #29
Source File: test_voice_transcription.py From python-rest-api with BSD 2-Clause "Simplified" License | 5 votes |
def test_create_voice_transcription(self): http_client = Mock() http_client.request.return_value = ''' { "data": [ { "id": "fb455b79-c4de-419f-8f72-8c199975c12a", "recordingId": "4c444e1e-3cea-4b52-90f7-55dec7b2e05e", "status": "done", "createdAt": "2019-08-23T13:29:10Z", "updatedAt": "2019-08-23T13:29:21Z", "legId": "d931d0e8-3385-43b3-964b-c9dda2581213" } ], "_links": { "file": "/transcriptions/fb455b79-c4de-419f-8f72-8c199975c12a.txt", "self": "/transcriptions/fb455b79-c4de-419f-8f72-8c199975c12a" } } ''' url = 'https://voice.messagebird.com/calls/' call_id = '74bd9fac-742e-4f7c-aef2-bf068c80fd00' leg_id = 'd931d0e8-3385-43b3-964b-c9dda2581213' recording_id = '4c444e1e-3cea-4b52-90f7-55dec7b2e05e' language = 'pt-Br' msg = Client('', http_client).voice_transcription_create( call_id, leg_id, recording_id, language ) http_client.request.assert_called_once_with( url + call_id + '/legs/' + leg_id + '/recordings/' + recording_id + '/transcriptions', 'POST', {'language': language} ) self.assertIsInstance(str(msg), str)
Example #30
Source File: test_group.py From python-rest-api with BSD 2-Clause "Simplified" License | 5 votes |
def test_group_remove_contact(self): http_client = Mock() http_client.request.return_value = '' Client('', http_client).group_remove_contact('group-id', 'contact-id') http_client.request.assert_called_once_with('groups/group-id/contacts/contact-id', 'DELETE', None)