From b2cb8678f37f0c49e0df4637632106b5e1623070 Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Sat, 21 Jun 2014 12:16:00 -1000 Subject: [PATCH] Status Endpoint should Accept All HTTP Verbs Closes #32 (again) --- httpbin/core.py | 2 +- test_httpbin.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/httpbin/core.py b/httpbin/core.py index 24187be..602378f 100644 --- a/httpbin/core.py +++ b/httpbin/core.py @@ -240,7 +240,7 @@ def stream_n_messages(n): }) -@app.route('/status/') +@app.route('/status/', methods=['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'TRACE']) def view_status_code(codes): """Return status code or random status code if more than one are given""" diff --git a/test_httpbin.py b/test_httpbin.py index 8f52ea8..7b3274a 100755 --- a/test_httpbin.py +++ b/test_httpbin.py @@ -169,6 +169,19 @@ class HttpbinTestCase(unittest.TestCase): ) assert json.loads(response.data.decode('utf-8'))['form'] == {'name':'kevin'} + def test_methods__to_status_endpoint(self): + methods = [ + 'GET', + 'HEAD', + 'POST', + 'PUT', + 'DELETE', + 'PATCH', + 'TRACE', + ] + for m in methods: + response = self.app.open(path='/status/418', method=m) + self.assertEqual(response.status_code, 418) if __name__ == '__main__': unittest.main()