Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add support for PUT and PATCH in prequest (#877)

  • Loading branch information...
commit cd9d7f5b3b087cb151052315ec6decf9e4786475 1 parent cb8bb94
@merwok authored
View
6 pyramid/scripts/prequest.py
@@ -59,9 +59,9 @@ class PRequestCommand(object):
parser.add_option(
'-m', '--method',
dest='method',
- choices=['GET', 'HEAD', 'POST', 'DELETE'],
+ choices=['GET', 'HEAD', 'POST', 'PUT', 'PATCH', 'DELETE'],
type='choice',
- help='Request method type (GET, POST, DELETE)',
+ help='Request method type',
)
get_app = staticmethod(get_app)
@@ -127,7 +127,7 @@ def run(self):
'paste.command_request': True,
}
- if request_method == 'POST':
+ if request_method in ('POST', 'PUT', 'PATCH'):
environ['wsgi.input'] = self.stdin
environ['CONTENT_LENGTH'] = '-1'
View
26 pyramid/tests/test_scripts/test_prequest.py
@@ -114,6 +114,32 @@ def test_command_method_post(self):
self.assertEqual(self._app_name, None)
self.assertEqual(self._out, ['abc'])
+ def test_command_method_put(self):
+ from pyramid.compat import NativeIO
+ command = self._makeOne(['', '--method=PUT', 'development.ini', '/'])
+ stdin = NativeIO()
+ command.stdin = stdin
+ command.run()
+ self.assertEqual(self._environ['CONTENT_LENGTH'], '-1')
+ self.assertEqual(self._environ['wsgi.input'], stdin)
+ self.assertEqual(self._path_info, '/')
+ self.assertEqual(self._spec, 'development.ini')
+ self.assertEqual(self._app_name, None)
+ self.assertEqual(self._out, ['abc'])
+
+ def test_command_method_patch(self):
+ from pyramid.compat import NativeIO
+ command = self._makeOne(['', '--method=PATCH', 'development.ini', '/'])
+ stdin = NativeIO()
+ command.stdin = stdin
+ command.run()
+ self.assertEqual(self._environ['CONTENT_LENGTH'], '-1')
+ self.assertEqual(self._environ['wsgi.input'], stdin)
+ self.assertEqual(self._path_info, '/')
+ self.assertEqual(self._spec, 'development.ini')
+ self.assertEqual(self._app_name, None)
+ self.assertEqual(self._out, ['abc'])
+
def test_command_with_query_string(self):
command = self._makeOne(['', 'development.ini', '/abc?a=1&b=2&c'])
command.run()
Please sign in to comment.
Something went wrong with that request. Please try again.