Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
url = "https://example.com/"
title = "FooBar"
token = "FooBarToken"
blank_string = ' '
with self.assertRaises(ValidationError):
VoiceCreateWebhookRequest(title=title)
request = VoiceCreateWebhookRequest(url=url, title=title)
self.assertEqual(url, request.url)
self.assertEqual(title, request.title)
self.assertEqual(None, request.token)
request.url = url + url
with self.assertRaises(ValidationError):
request.url = blank_string
def test_voice_create_webhook_request_validation(self):
url = "https://example.com/"
title = "FooBar"
token = "FooBarToken"
blank_string = ' '
with self.assertRaises(ValidationError):
VoiceCreateWebhookRequest(title=title)
request = VoiceCreateWebhookRequest(url=url, title=title)
self.assertEqual(url, request.url)
self.assertEqual(title, request.title)
self.assertEqual(None, request.token)
request.url = url + url
with self.assertRaises(ValidationError):
request.url = blank_string
def voice_create_webhook(self, create_webhook_request):
""" Create a voice webhook. """
if create_webhook_request is None:
raise ValidationError('Create request is empty')
uri = VOICE_API_ROOT + '/' + VOICE_WEB_HOOKS_PATH
return VoiceWebhook().load(self.request(uri, 'POST', create_webhook_request.__dict__(), VOICE_TYPE))
def voice_update_webhook(self, id, update_webhook_request):
""" Update a voice webhook. """
if update_webhook_request is None:
raise ValidationError('Update request is empty')
uri = VOICE_API_ROOT + '/' + VOICE_WEB_HOOKS_PATH + '/' + str(id)
return VoiceWebhook().load(self.request(uri, 'PUT', update_webhook_request.__dict__(), VOICE_TYPE))