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/02/25 16:33:21 UTC

[22/28] allura git commit: [#7832] ticket:731 Add support for DELETE to test app

[#7832] ticket:731 Add support for DELETE to test app


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

Branch: refs/heads/ib/7832
Commit: 0302bd844ab7f12ecf78cb4f427a457bacdbb984
Parents: ac74d02
Author: Igor Bondarenko <je...@gmail.com>
Authored: Fri Feb 20 16:28:30 2015 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Feb 25 13:51:05 2015 +0000

----------------------------------------------------------------------
 AlluraTest/alluratest/controller.py | 11 +++++++----
 AlluraTest/alluratest/validation.py |  7 +++++++
 2 files changed, 14 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/0302bd84/AlluraTest/alluratest/controller.py
----------------------------------------------------------------------
diff --git a/AlluraTest/alluratest/controller.py b/AlluraTest/alluratest/controller.py
index 4237624..4398a82 100644
--- a/AlluraTest/alluratest/controller.py
+++ b/AlluraTest/alluratest/controller.py
@@ -209,7 +209,7 @@ class TestRestApiBase(TestController):
 
         return self._token_cache[username]
 
-    def _api_getpost(self, method, path, wrap_args=None, user='test-admin', status=None, **params):
+    def _api_call(self, method, path, wrap_args=None, user='test-admin', status=None, **params):
         '''
         If you need to use one of the method kwargs as a URL parameter,
         pass params={...} as a dict instead of **kwargs
@@ -224,7 +224,7 @@ class TestRestApiBase(TestController):
 
         params['access_token'] = self.token(user).api_key
 
-        fn = self.app.post if method == 'POST' else self.app.get
+        fn = getattr(self.app, method.lower())
 
         response = fn(
             str(path),
@@ -236,7 +236,10 @@ class TestRestApiBase(TestController):
             return response
 
     def api_get(self, path, wrap_args=None, user='test-admin', status=None, **params):
-        return self._api_getpost('GET', path, wrap_args, user, status, **params)
+        return self._api_call('GET', path, wrap_args, user, status, **params)
 
     def api_post(self, path, wrap_args=None, user='test-admin', status=None, **params):
-        return self._api_getpost('POST', path, wrap_args, user, status, **params)
+        return self._api_call('POST', path, wrap_args, user, status, **params)
+
+    def api_delete(self, path, wrap_args=None, user='test-admin', status=None, **params):
+        return self._api_call('DELETE', path, wrap_args, user, status, **params)

http://git-wip-us.apache.org/repos/asf/allura/blob/0302bd84/AlluraTest/alluratest/validation.py
----------------------------------------------------------------------
diff --git a/AlluraTest/alluratest/validation.py b/AlluraTest/alluratest/validation.py
index 1bf6b22..97691df 100644
--- a/AlluraTest/alluratest/validation.py
+++ b/AlluraTest/alluratest/validation.py
@@ -315,3 +315,10 @@ class ValidatingTestApp(PostParamCheckingTestApp):
         if not self.validate_skip and not val_params['validate_skip']:
             self._validate(resp, 'post', val_params)
         return resp
+
+    def delete(self, *args, **kw):
+        val_params, kw = self._get_validation_params(kw)
+        resp = super(ValidatingTestApp, self).delete(*args, **kw)
+        if not self.validate_skip and not val_params['validate_skip']:
+            self._validate(resp, 'delete', val_params)
+        return resp