mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-01-22 10:53:03 -08:00
3d378eb583
* Bump cheroot from 8.6.0 to 9.0.0 Bumps [cheroot](https://github.com/cherrypy/cheroot) from 8.6.0 to 9.0.0. - [Release notes](https://github.com/cherrypy/cheroot/releases) - [Changelog](https://github.com/cherrypy/cheroot/blob/main/CHANGES.rst) - [Commits](https://github.com/cherrypy/cheroot/compare/v8.6.0...v9.0.0) --- updated-dependencies: - dependency-name: cheroot dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * Update cheroot==9.0.0 Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> [skip ci]
52 lines
1.2 KiB
Python
52 lines
1.2 KiB
Python
"""Tests for the HTTP server."""
|
|
|
|
from cheroot.wsgi import PathInfoDispatcher
|
|
|
|
|
|
def wsgi_invoke(app, environ):
|
|
"""Serve 1 request from a WSGI application."""
|
|
response = {}
|
|
|
|
def start_response(status, headers):
|
|
response.update({
|
|
'status': status,
|
|
'headers': headers,
|
|
})
|
|
|
|
response['body'] = b''.join(
|
|
app(environ, start_response),
|
|
)
|
|
|
|
return response
|
|
|
|
|
|
def test_dispatch_no_script_name():
|
|
"""Dispatch despite lack of ``SCRIPT_NAME`` in environ."""
|
|
# Bare bones WSGI hello world app (from PEP 333).
|
|
def app(environ, start_response):
|
|
start_response(
|
|
'200 OK', [
|
|
('Content-Type', 'text/plain; charset=utf-8'),
|
|
],
|
|
)
|
|
return [u'Hello, world!'.encode('utf-8')]
|
|
|
|
# Build a dispatch table.
|
|
d = PathInfoDispatcher([
|
|
('/', app),
|
|
])
|
|
|
|
# Dispatch a request without `SCRIPT_NAME`.
|
|
response = wsgi_invoke(
|
|
d, {
|
|
'PATH_INFO': '/foo',
|
|
},
|
|
)
|
|
assert response == {
|
|
'status': '200 OK',
|
|
'headers': [
|
|
('Content-Type', 'text/plain; charset=utf-8'),
|
|
],
|
|
'body': b'Hello, world!',
|
|
}
|