Skip to content

Commit d3b7007

Browse files
author
Shivam Tiwari
committed
Fixed test
1 parent a1990c8 commit d3b7007

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

apps/testclient/management/commands/create_test_user_and_application.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,19 +114,18 @@ def create_test_token(user, application):
114114

115115
now = timezone.now()
116116
expires = now + timedelta(days=1)
117+
token_value = "sample-token-string"
117118

118119
scopes = application.scope.all()
119120
scope = []
120121
for s in scopes:
121122
scope.append(s.slug)
122123

123-
if AccessToken.objects.filter(token="sample-token-string").exists():
124-
t = AccessToken.objects.get(token="sample-token-string")
125-
126-
t = AccessToken.objects.create(user=user, application=application,
127-
token="sample-token-string",
128-
expires=expires,
129-
scope=' '.join(scope))
124+
AccessToken.objects.filter(token=token_value).delete()
125+
t = AccessToken.objects.create(user=user, application=application,
126+
token=token_value,
127+
expires=expires,
128+
scope=' '.join(scope))
130129
return t
131130

132131

0 commit comments

Comments
 (0)