Skip to content

Commit 115f178

Browse files
committed
fixed failing test
1 parent 11a4a02 commit 115f178

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

tests/test_async_auth.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,28 +51,28 @@ async def demo_operation(request):
5151
return {"auth": request.auth}
5252

5353

54-
api = NinjaExtraAPI(csrf=True, urls_namespace="async_auth")
54+
class MockUser(str):
55+
is_authenticated = True
5556

56-
for path, auth in [
57-
("django_auth", async_django_auth),
58-
("callable", callable_auth),
59-
("apikeyquery", KeyQuery()),
60-
("apikeyheader", KeyHeader()),
61-
("apikeycookie", KeyCookie()),
62-
("basic", BasicAuth()),
63-
("bearer", BearerAuth()),
64-
]:
65-
api.get(f"/{path}", auth=auth, operation_id=path)(demo_operation)
6657

58+
BODY_UNAUTHORIZED_DEFAULT = dict(detail="Unauthorized")
6759

68-
client = TestAsyncClient(api)
60+
if django.VERSION < (3, 1):
61+
api = NinjaExtraAPI(csrf=True, urls_namespace="async_auth")
6962

70-
71-
class MockUser(str):
72-
is_authenticated = True
63+
for path, auth in [
64+
("django_auth", async_django_auth),
65+
("callable", callable_auth),
66+
("apikeyquery", KeyQuery()),
67+
("apikeyheader", KeyHeader()),
68+
("apikeycookie", KeyCookie()),
69+
("basic", BasicAuth()),
70+
("bearer", BearerAuth()),
71+
]:
72+
api.get(f"/{path}", auth=auth, operation_id=path)(demo_operation)
7373

7474

75-
BODY_UNAUTHORIZED_DEFAULT = dict(detail="Unauthorized")
75+
client = TestAsyncClient(api)
7676

7777

7878
@pytest.mark.skipif(django.VERSION < (3, 1), reason="requires django 3.1 or higher")

0 commit comments

Comments
 (0)