allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jetm...@apache.org
Subject [25/37] allura git commit: [#4542] ticket:723 Tweak error message
Date Mon, 16 Feb 2015 11:44:56 GMT
[#4542] ticket:723 Tweak error message


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/1b1dcfdf
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/1b1dcfdf
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/1b1dcfdf

Branch: refs/heads/ib/4542
Commit: 1b1dcfdf92874c5506f74dd5b7b1d3831694bd51
Parents: 072654c
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Tue Feb 10 11:17:11 2015 +0000
Committer: Igor Bondarenko <jetmind2@gmail.com>
Committed: Mon Feb 16 10:17:39 2015 +0000

----------------------------------------------------------------------
 Allura/allura/tests/test_webhooks.py | 19 +++++++++++++------
 Allura/allura/webhooks.py            |  7 ++++---
 2 files changed, 17 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/1b1dcfdf/Allura/allura/tests/test_webhooks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_webhooks.py b/Allura/allura/tests/test_webhooks.py
index ab82cb8..1879beb 100644
--- a/Allura/allura/tests/test_webhooks.py
+++ b/Allura/allura/tests/test_webhooks.py
@@ -430,9 +430,14 @@ class TestSendWebhookHelper(TestWebhookBase):
         assert_equal(
             self.h.log_msg('OK'),
             'OK: repo-push http://httpbin.org/post /adobe/adobe-1/src/')
+        response = Mock(
+            status_code=500,
+            text='that is why',
+            headers={'Content-Type': 'application/json'})
         assert_equal(
-            self.h.log_msg('Error', response=Mock(status_code=500, reason='that is why')),
-            'Error: repo-push http://httpbin.org/post /adobe/adobe-1/src/ 500 that is why')
+            self.h.log_msg('Error', response=response),
+            "Error: repo-push http://httpbin.org/post /adobe/adobe-1/src/ 500 "
+            "that is why {'Content-Type': 'application/json'}")
 
     @patch('allura.webhooks.SendWebhookHelper', autospec=True)
     def test_send_webhook_task(self, swh):
@@ -473,11 +478,12 @@ class TestSendWebhookHelper(TestWebhookBase):
             call('Retrying webhook in %s seconds', 240)])
         assert_equal(log.error.call_count, 4)
         log.error.assert_called_with(
-            'Webhook send error: %s %s %s %s %s' % (
+            'Webhook send error: %s %s %s %s %s %s' % (
                 self.wh.type, self.wh.hook_url,
                 self.wh.app_config.url(),
                 requests.post.return_value.status_code,
-                requests.post.return_value.reason))
+                requests.post.return_value.text,
+                requests.post.return_value.headers))
 
     @patch('allura.webhooks.time', autospec=True)
     @patch('allura.webhooks.requests', autospec=True)
@@ -491,11 +497,12 @@ class TestSendWebhookHelper(TestWebhookBase):
             log.info.assert_called_once_with('Retrying webhook in: %s', [])
             assert_equal(log.error.call_count, 1)
             log.error.assert_called_with(
-                'Webhook send error: %s %s %s %s %s' % (
+                'Webhook send error: %s %s %s %s %s %s' % (
                     self.wh.type, self.wh.hook_url,
                     self.wh.app_config.url(),
                     requests.post.return_value.status_code,
-                    requests.post.return_value.reason))
+                    requests.post.return_value.text,
+                    requests.post.return_value.headers))
 
 
 class TestRepoPushWebhookSender(TestWebhookBase):

http://git-wip-us.apache.org/repos/asf/allura/blob/1b1dcfdf/Allura/allura/webhooks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/webhooks.py b/Allura/allura/webhooks.py
index ebfb3d0..0f9b54d 100644
--- a/Allura/allura/webhooks.py
+++ b/Allura/allura/webhooks.py
@@ -256,11 +256,12 @@ class SendWebhookHelper(object):
             self.webhook.type,
             self.webhook.hook_url,
             self.webhook.app_config.url())
-        if response:
-            message = '{} {} {}'.format(
+        if response is not None:
+            message = '{} {} {} {}'.format(
                 message,
                 response.status_code,
-                response.reason)
+                response.text,
+                response.headers)
         return message
 
     def send(self):


Mime
View raw message