mirror of
https://github.com/frappe/gunicorn.git
synced 2026-07-01 10:11:30 +08:00
Add raw_path to mock requests in tests
This commit is contained in:
parent
ba1aaa5e33
commit
4bff2f37d1
@ -38,7 +38,9 @@ class TestASGIVersion:
|
||||
"""Create a mock HTTP request."""
|
||||
request = mock.Mock()
|
||||
request.method = kwargs.get("method", "GET")
|
||||
request.path = kwargs.get("path", "/")
|
||||
path = kwargs.get("path", "/")
|
||||
request.path = path
|
||||
request.raw_path = kwargs.get("raw_path", path.encode("latin-1") if path else b"")
|
||||
request.query = kwargs.get("query", "")
|
||||
request.version = kwargs.get("version", (1, 1))
|
||||
request.scheme = kwargs.get("scheme", "http")
|
||||
@ -137,7 +139,9 @@ class TestHTTPScopeKeys:
|
||||
"""Create a mock HTTP request."""
|
||||
request = mock.Mock()
|
||||
request.method = kwargs.get("method", "GET")
|
||||
request.path = kwargs.get("path", "/")
|
||||
path = kwargs.get("path", "/")
|
||||
request.path = path
|
||||
request.raw_path = kwargs.get("raw_path", path.encode("latin-1") if path else b"")
|
||||
request.query = kwargs.get("query", "")
|
||||
request.version = kwargs.get("version", (1, 1))
|
||||
request.scheme = kwargs.get("scheme", "http")
|
||||
@ -654,6 +658,7 @@ class TestStateSharing:
|
||||
request = mock.Mock()
|
||||
request.method = "GET"
|
||||
request.path = "/"
|
||||
request.raw_path = b"/"
|
||||
request.query = ""
|
||||
request.version = (1, 1)
|
||||
request.scheme = "http"
|
||||
|
||||
@ -39,7 +39,9 @@ class TestHTTPScopeBuilding:
|
||||
"""Create a mock HTTP request."""
|
||||
request = mock.Mock()
|
||||
request.method = kwargs.get("method", "GET")
|
||||
request.path = kwargs.get("path", "/")
|
||||
path = kwargs.get("path", "/")
|
||||
request.path = path
|
||||
request.raw_path = kwargs.get("raw_path", path.encode("latin-1") if path else b"")
|
||||
request.query = kwargs.get("query", "")
|
||||
request.version = kwargs.get("version", (1, 1))
|
||||
request.scheme = kwargs.get("scheme", "http")
|
||||
@ -113,7 +115,9 @@ class TestPathHandling:
|
||||
"""Create a mock HTTP request."""
|
||||
request = mock.Mock()
|
||||
request.method = kwargs.get("method", "GET")
|
||||
request.path = kwargs.get("path", "/")
|
||||
path = kwargs.get("path", "/")
|
||||
request.path = path
|
||||
request.raw_path = kwargs.get("raw_path", path.encode("latin-1") if path else b"")
|
||||
request.query = kwargs.get("query", "")
|
||||
request.version = kwargs.get("version", (1, 1))
|
||||
request.scheme = kwargs.get("scheme", "http")
|
||||
@ -193,7 +197,9 @@ class TestQueryStringHandling:
|
||||
"""Create a mock HTTP request."""
|
||||
request = mock.Mock()
|
||||
request.method = kwargs.get("method", "GET")
|
||||
request.path = kwargs.get("path", "/")
|
||||
path = kwargs.get("path", "/")
|
||||
request.path = path
|
||||
request.raw_path = kwargs.get("raw_path", path.encode("latin-1") if path else b"")
|
||||
request.query = kwargs.get("query", "")
|
||||
request.version = kwargs.get("version", (1, 1))
|
||||
request.scheme = kwargs.get("scheme", "http")
|
||||
@ -269,7 +275,9 @@ class TestHeaderHandling:
|
||||
"""Create a mock HTTP request."""
|
||||
request = mock.Mock()
|
||||
request.method = kwargs.get("method", "GET")
|
||||
request.path = kwargs.get("path", "/")
|
||||
path = kwargs.get("path", "/")
|
||||
request.path = path
|
||||
request.raw_path = kwargs.get("raw_path", path.encode("latin-1") if path else b"")
|
||||
request.query = kwargs.get("query", "")
|
||||
request.version = kwargs.get("version", (1, 1))
|
||||
request.scheme = kwargs.get("scheme", "http")
|
||||
@ -361,7 +369,9 @@ class TestWebSocketScope:
|
||||
"""Create a mock WebSocket upgrade request."""
|
||||
request = mock.Mock()
|
||||
request.method = "GET"
|
||||
request.path = kwargs.get("path", "/ws")
|
||||
path = kwargs.get("path", "/ws")
|
||||
request.path = path
|
||||
request.raw_path = kwargs.get("raw_path", path.encode("latin-1") if path else b"")
|
||||
request.query = kwargs.get("query", "")
|
||||
request.version = kwargs.get("version", (1, 1))
|
||||
request.scheme = kwargs.get("scheme", "http")
|
||||
@ -574,6 +584,7 @@ class TestAddressHandling:
|
||||
request = mock.Mock()
|
||||
request.method = "GET"
|
||||
request.path = "/"
|
||||
request.raw_path = b"/"
|
||||
request.query = ""
|
||||
request.version = (1, 1)
|
||||
request.scheme = "http"
|
||||
|
||||
@ -724,10 +724,11 @@ class TestASGIHTTP2Priority:
|
||||
protocol = ASGIProtocol(worker)
|
||||
|
||||
# Create mock HTTP/1.1 request (no priority attributes)
|
||||
request = mock.Mock(spec=['method', 'path', 'query', 'version',
|
||||
request = mock.Mock(spec=['method', 'path', 'raw_path', 'query', 'version',
|
||||
'scheme', 'headers'])
|
||||
request.method = "GET"
|
||||
request.path = "/test"
|
||||
request.raw_path = b"/test"
|
||||
request.query = ""
|
||||
request.version = (1, 1)
|
||||
request.scheme = "http"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user