Skip to content

Commit 436ccc3

Browse files
committed
Promote the refresh endpoint fixture to the top level.
I'd like to test something with refreshed tokens outside of the views, and this seems like a reasonably simple way to get one.
1 parent b63dc86 commit 436ccc3

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

tests/conftest.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from django.contrib.auth import get_user_model
88

9+
from rest_framework.reverse import reverse
910
from rest_framework.test import APIClient
1011

1112
from rest_framework_jwt.authentication import JSONWebTokenAuthentication
@@ -80,3 +81,13 @@ def _create_user(**kwargs):
8081
return User.objects.create_user(**kwargs)
8182

8283
return _create_user
84+
85+
86+
@pytest.fixture
87+
def call_auth_refresh_endpoint(api_client, db):
88+
def _call_auth_refresh_endpoint(token):
89+
url = reverse("auth-refresh")
90+
data = {"token": token}
91+
return api_client.post(path=url, data=data)
92+
93+
return _call_auth_refresh_endpoint

tests/views/conftest.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,3 @@ def _call_auth_verify_endpoint(token):
2525
return api_client.post(path=url, data=data)
2626

2727
return _call_auth_verify_endpoint
28-
29-
30-
@pytest.fixture
31-
def call_auth_refresh_endpoint(api_client, db):
32-
def _call_auth_refresh_endpoint(token):
33-
url = reverse("auth-refresh")
34-
data = {"token": token}
35-
return api_client.post(path=url, data=data)
36-
37-
return _call_auth_refresh_endpoint

0 commit comments

Comments
 (0)