You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by je...@apache.org on 2015/03/06 13:35:19 UTC

[12/26] allura git commit: [#7832] ticket:740 Remove result:ok from responses

[#7832] ticket:740 Remove result:ok from responses


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

Branch: refs/heads/ib/7830
Commit: 7a934faebf5d0cacf61626217fcbea0c910558f3
Parents: aa6daf7
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Feb 25 14:07:51 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Feb 27 22:40:53 2015 +0000

----------------------------------------------------------------------
 Allura/allura/tests/test_webhooks.py | 61 +++++++++++++------------------
 Allura/allura/webhooks.py            |  7 ++--
 2 files changed, 28 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/7a934fae/Allura/allura/tests/test_webhooks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_webhooks.py b/Allura/allura/tests/test_webhooks.py
index e86dbd8..d7fb75c 100644
--- a/Allura/allura/tests/test_webhooks.py
+++ b/Allura/allura/tests/test_webhooks.py
@@ -721,16 +721,14 @@ class TestWebhookRestController(TestRestApiBase):
         webhook = self.webhooks[0]
         r = self.api_get('{}/repo-push/{}'.format(self.url, webhook._id))
         expected = {
-            u'result': u'ok',
-            u'webhook': {
-                '_id': unicode(webhook._id),
-                'url': 'http://localhost/rest/adobe/adobe-1/admin'
-                       '/src/webhooks/repo-push/{}'.format(webhook._id),
-                'type': 'repo-push',
-                'hook_url': 'http://httpbin.org/post/0',
-                'mod_date': unicode(webhook.mod_date),
-            },
+            '_id': unicode(webhook._id),
+            'url': 'http://localhost/rest/adobe/adobe-1/admin'
+                   '/src/webhooks/repo-push/{}'.format(webhook._id),
+            'type': 'repo-push',
+            'hook_url': 'http://httpbin.org/post/0',
+            'mod_date': unicode(webhook.mod_date),
         }
+        dd.assert_equal(r.status_int, 200)
         dd.assert_equal(r.json, expected)
 
     def test_create_validation(self):
@@ -767,15 +765,12 @@ class TestWebhookRestController(TestRestApiBase):
         webhook = M.Webhook.query.get(hook_url=data['url'])
         assert_equal(webhook.secret, 'super-secret')  # secret generated
         expected = {
-            u'result': u'ok',
-            u'webhook': {
-                '_id': unicode(webhook._id),
-                'url': 'http://localhost/rest/adobe/adobe-1/admin'
-                       '/src/webhooks/repo-push/{}'.format(webhook._id),
-                'type': 'repo-push',
-                'hook_url': data['url'],
-                'mod_date': unicode(webhook.mod_date),
-            },
+            '_id': unicode(webhook._id),
+            'url': 'http://localhost/rest/adobe/adobe-1/admin'
+                   '/src/webhooks/repo-push/{}'.format(webhook._id),
+            'type': 'repo-push',
+            'hook_url': data['url'],
+            'mod_date': unicode(webhook.mod_date),
         }
         dd.assert_equal(r.json, expected)
         assert_equal(M.Webhook.query.find().count(), len(self.webhooks) + 1)
@@ -830,15 +825,12 @@ class TestWebhookRestController(TestRestApiBase):
         assert_equal(webhook.hook_url, data['url'])
         assert_equal(webhook.secret, 'secret-0')
         expected = {
-            u'result': u'ok',
-            u'webhook': {
-                '_id': unicode(webhook._id),
-                'url': 'http://localhost/rest/adobe/adobe-1/admin'
-                       '/src/webhooks/repo-push/{}'.format(webhook._id),
-                'type': 'repo-push',
-                'hook_url': data['url'],
-                'mod_date': unicode(webhook.mod_date),
-            },
+            '_id': unicode(webhook._id),
+            'url': 'http://localhost/rest/adobe/adobe-1/admin'
+                   '/src/webhooks/repo-push/{}'.format(webhook._id),
+            'type': 'repo-push',
+            'hook_url': data['url'],
+            'mod_date': unicode(webhook.mod_date),
         }
         dd.assert_equal(r.json, expected)
 
@@ -853,15 +845,12 @@ class TestWebhookRestController(TestRestApiBase):
         assert_equal(webhook.hook_url, 'http://hook.slack.com/abcd')
         assert_equal(webhook.secret, 'new-secret')
         expected = {
-            u'result': u'ok',
-            u'webhook': {
-                '_id': unicode(webhook._id),
-                'url': 'http://localhost/rest/adobe/adobe-1/admin'
-                       '/src/webhooks/repo-push/{}'.format(webhook._id),
-                'type': 'repo-push',
-                'hook_url': 'http://hook.slack.com/abcd',
-                'mod_date': unicode(webhook.mod_date),
-            },
+            '_id': unicode(webhook._id),
+            'url': 'http://localhost/rest/adobe/adobe-1/admin'
+                   '/src/webhooks/repo-push/{}'.format(webhook._id),
+            'type': 'repo-push',
+            'hook_url': 'http://hook.slack.com/abcd',
+            'mod_date': unicode(webhook.mod_date),
         }
         dd.assert_equal(r.json, expected)
 

http://git-wip-us.apache.org/repos/asf/allura/blob/7a934fae/Allura/allura/webhooks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/webhooks.py b/Allura/allura/webhooks.py
index 19903d5..d41f477 100644
--- a/Allura/allura/webhooks.py
+++ b/Allura/allura/webhooks.py
@@ -243,7 +243,7 @@ class WebhookRestController(BaseController):
             # refetch updated values (e.g. mod_date)
             session(webhook).expunge(webhook)
             webhook = M.Webhook.query.get(_id=webhook._id)
-            return {'result': 'ok', 'webhook': webhook}
+            return webhook.__json__()
         else:
             limits = {
                 'max': M.Webhook.max_hooks(
@@ -275,7 +275,7 @@ class WebhookRestController(BaseController):
         elif request.method == 'DELETE':
             return self._delete(wh)
         else:
-            return {'result': 'ok', 'webhook': wh}
+            return wh.__json__()
 
     def _edit(self, webhook, form, **kw):
         old_secret = webhook.secret
@@ -300,8 +300,7 @@ class WebhookRestController(BaseController):
         # refetch updated values (e.g. mod_date)
         session(webhook).expunge(webhook)
         webhook = M.Webhook.query.get(_id=webhook._id)
-        return {'result': 'ok',
-                'webhook': webhook}
+        return webhook.__json__()
 
     def _delete(self, webhook):
         webhook.delete()