Ticket #17371: 17371-wip.patch
File 17371-wip.patch, 2.4 KB (added by , 13 years ago) |
---|
-
django/test/client.py
275 275 return self.request(**r) 276 276 277 277 def options(self, path, data={}, **extra): 278 "Constrict an OPTIONS request" 278 "Construct an OPTIONS request" 279 return self.generic('OPTIONS', path, data, content_type, **extra) 279 280 280 parsed = urlparse(path) 281 r = { 282 'PATH_INFO': self._get_path(parsed), 283 'QUERY_STRING': urlencode(data, doseq=True) or parsed[4], 284 'REQUEST_METHOD': 'OPTIONS', 285 } 286 r.update(extra) 287 return self.request(**r) 288 289 def put(self, path, data={}, content_type=MULTIPART_CONTENT, 290 **extra): 281 def put(self, path, data='', content_type=MULTIPART_CONTENT, **extra): 291 282 "Construct a PUT request." 283 return self.generic('PUT', path, data, content_type, **extra) 292 284 293 put_data = self._encode_data(data, content_type) 285 def delete(self, path, data='', content_type=MULTIPART_CONTENT, **extra): 286 "Construct a DELETE request." 287 return self.generic('DELETE', path, data, content_type, **extra) 294 288 289 def generic(self, method, path, data='', content_type=MULTIPART_CONTENT, 290 **extra): 295 291 parsed = urlparse(path) 296 292 r = { 297 'CONTENT_LENGTH': len(put_data),298 'CONTENT_TYPE': content_type,299 293 'PATH_INFO': self._get_path(parsed), 300 294 'QUERY_STRING': parsed[4], 301 'REQUEST_METHOD': 'PUT', 302 'wsgi.input': FakePayload(put_data), 295 'REQUEST_METHOD': method, 303 296 } 297 if data: 298 r.update({ 299 'CONTENT_LENGTH': len(data), 300 'CONTENT_TYPE': content_type, 301 'wsgi.input': FakePayload(data), 302 }) 304 303 r.update(extra) 305 304 return self.request(**r) 306 305 307 def delete(self, path, data={}, **extra):308 "Construct a DELETE request."309 310 parsed = urlparse(path)311 r = {312 'PATH_INFO': self._get_path(parsed),313 'QUERY_STRING': urlencode(data, doseq=True) or parsed[4],314 'REQUEST_METHOD': 'DELETE',315 }316 r.update(extra)317 return self.request(**r)318 319 320 306 class Client(RequestFactory): 321 307 """ 322 308 A class that can act as a client for testing purposes.