From bfc6ef20495d6908c91089f82c6cc6a5fb8e004a Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Tue, 23 Oct 2018 08:12:40 -0400 Subject: [PATCH] test client docs --- docs/source/tour.rst | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/docs/source/tour.rst b/docs/source/tour.rst index 5791723..ec30e34 100644 --- a/docs/source/tour.rst +++ b/docs/source/tour.rst @@ -176,11 +176,33 @@ You can easily read a Request's session data, that can be trusted to have origin **Note**: if you are using this in production, you should pass the ``secret_key`` argument to ``API(...)``. +Using Requests Test Client +-------------------------- + +Responder comes with a first-class, well supported test client for your ASGI web services: **Requests**. + +Here's an example of a test (written with pytest):: + + import myapi + + @pytest.fixture + def api(): + return myapi.api + + def test_response(api): + hello = "hello, world!" + + @api.route('/some-url') + def some_view(req, resp): + resp.text = hello + + r = api.requests.get(url=api.url_for(some_view)) + assert r.text = hello HSTS (Redirect to HTTPS) ------------------------ -Want HSTS? +Want HSTS (to redirect all traffic to HTTPS)? ::