"""Test handlers.""" import pytest import tornado.httpclient from grass import api from grass.utils import response async def test_abort(monkeypatch, http_server_client): """Test handler abortion. When a request does not meet the minimum requirements (or if an error has occured.) The http response returns the appropriate status. The API covers all existing HTTP statuses – and more. """ url = '/test/abort/' @api.route(url, access=[lambda x: True], methods=['GET']) def _route_success(request): return response.Response(message='error', status=400) with pytest.raises(tornado.httpclient.HTTPError) as exc: await http_server_client.fetch(url) assert exc.value.code == 400