Skip to content

Commit cde98e8

Browse files
committed
run_init_stage: Does not get ASGI contexts
1 parent af0b50c commit cde98e8

2 files changed

Lines changed: 1 addition & 28 deletions

File tree

aikido_zen/sources/django/run_init_stage.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@ def run_init_stage(request):
1515
# In a separate try-catch we set the context :
1616
try:
1717
context = None
18-
if (
19-
hasattr(request, "scope") and request.scope is not None
20-
): # This request is an ASGI request
21-
context = Context(req=request.scope, body=body, source="django_async")
22-
elif hasattr(request, "META") and request.META is not None: # WSGI request
18+
if hasattr(request, "META") and request.META is not None:
2319
context = Context(req=request.META, body=body, source="django")
2420
else:
2521
return

aikido_zen/sources/django/run_init_stage_test.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,6 @@
1919
"CONTENT_TYPE": "application/json",
2020
"REMOTE_ADDR": "198.51.100.23",
2121
}
22-
asgi_scope = {
23-
"method": "PUT",
24-
"headers": [
25-
(b"COOKIE", b"a=b; c=d"),
26-
(b"header1_test-2", b"testValue2198&"),
27-
(b"USER-AGENT", b"testUserAgent"),
28-
(b"USER-AGENT", b"testUserAgent2"),
29-
],
30-
"query_string": b"a=b&b=d",
31-
"client": ["1.1.1.1"],
32-
"server": ["192.168.0.1", 443],
33-
"scheme": "https",
34-
"root_path": "192.168.0.1",
35-
"path": "192.168.0.1/a/b/c/d",
36-
}
3722

3823

3924
@pytest.fixture
@@ -195,11 +180,3 @@ def test_uses_wsgi(mock_request):
195180
context: Context = get_current_context()
196181
assert "/hello" == context.route
197182

198-
199-
def test_uses_asgi_prio(mock_request):
200-
mock_request.scope = asgi_scope
201-
run_init_stage(mock_request)
202-
# Assertions
203-
context: Context = get_current_context()
204-
assert "/a/b/c/d" == context.route
205-
assert "testUserAgent2" == context.get_user_agent()

0 commit comments

Comments
 (0)