def test_verification_response_message(self): message = 'Some message here' response = VerificationResponse(message=message, verification_key='abc') self.assertTrue(response.is_initialized()) self.assertEqual(response.code, 200) self.assertEqual(response.message, message) self.assertEqual(response.verification_key, 'abc')
def verification(self, request): """ Immediately dispatch a Verification to a webhook """ self._validate_authentication() from tbans.models.notifications.verification import VerificationNotification notification = VerificationNotification(request.webhook.url, request.webhook.secret) from tbans.models.messages.webhook_message import WebhookMessage message = WebhookMessage(notification, request.webhook.url, request.webhook.secret) logging.info('Verification - {}'.format(str(message))) response = message.send() logging.info('Verification Response - {}'.format(str(response))) return VerificationResponse(code=response.status_code, message=response.content, verification_key=notification.verification_key)
def verification(self, request): """ Immediately dispatch a Verification to a webhook """ self._validate_authentication() from tbans.models.notifications.verification import VerificationNotification notification = VerificationNotification(request.webhook.url, request.webhook.secret) from tbans.requests.webhook_request import WebhookRequest webhook_request = WebhookRequest(notification, request.webhook.url, request.webhook.secret) logging.info('Verification - {}'.format(str(webhook_request))) webhook_request.send() logging.info('Verification Key - {}'.format(notification.verification_key)) return VerificationResponse(code=200, verification_key=notification.verification_key)
def test_verification_response_code(self): response = VerificationResponse(code=500, verification_key='abc') self.assertTrue(response.is_initialized()) self.assertEqual(response.code, 500) self.assertEqual(response.message, None) self.assertEqual(response.verification_key, 'abc')
def test_verification_response_empty(self): response = VerificationResponse() self.assertFalse(response.is_initialized())