def _validate_webhook(value): from GeoHealthCheck.notifications import _parse_webhook_location try: _parse_webhook_location(value) except ValueError as err: raise ValidationError('{}: {}'.format(value, err)) return value
def testWebhookNotifications(self): lhost = 'http://localhost:8000/' # identifier, url, params, no error test_data = ( ( '', None, None, False, ), ( 'http://localhost:8000/', lhost, {}, True, ), ( 'http://localhost:8000/\n\n', lhost, {}, True, ), ( 'http://localhost:8000/\n\ntest=true', lhost, { 'test': 'true' }, True, ), ) for identifier, url, params, success in test_data: try: test_url, test_params = _parse_webhook_location(identifier) self.assertTrue(success) self.assertEqual(test_url, url) self.assertEqual(test_params, params) except Exception, err: self.assertFalse(success, str(err))
def _validate_webhook(value): from GeoHealthCheck.notifications import _parse_webhook_location try: _parse_webhook_location(value) except ValueError, err: raise ValidationError('{}: {}'.format(value, err))