[devtools/httptest] allow sending other types of requests besides GET
authorJulien Cristau <julien.cristau@logilab.fr>
Thu, 17 Jan 2013 15:42:09 +0100
changeset 8712 ce5ae7b80d2c
parent 8711 64a400eea6dd
child 8713 4b34dc3046e6
[devtools/httptest] allow sending other types of requests besides GET
devtools/httptest.py
--- a/devtools/httptest.py	Fri Mar 08 18:43:42 2013 +0100
+++ b/devtools/httptest.py	Thu Jan 17 15:42:09 2013 +0100
@@ -156,7 +156,7 @@
             response = self.web_get('logout')
         self._ident_cookie = None
 
-    def web_get(self, path='', headers=None):
+    def web_request(self, path='', method='GET', body=None, headers=None)
         """Return an httplib.HTTPResponse object for the specified path
 
         Use available credential if available.
@@ -166,12 +166,15 @@
         if self._ident_cookie is not None:
             assert 'Cookie' not in headers
             headers['Cookie'] = self._ident_cookie
-        self._web_test_cnx.request("GET", '/' + path, headers=headers)
+        self._web_test_cnx.request(method, '/' + path, headers=headers, body=body)
         response = self._web_test_cnx.getresponse()
         response.body = response.read() # to chain request
         response.read = lambda : response.body
         return response
 
+    def web_get(self, path='', body=None, headers=None):
+        return self.web_request(path=path, body=body, headers=headers)
+
     def setUp(self):
         super(CubicWebServerTC, self).setUp()
         self.start_server()