Skip to content

Commit 0ff567c

Browse files
IvanAnishchukjleclanche
authored andcommitted
Fix IntegrityError in models tests (#748)
Fix data used for token fixtures.
1 parent 67a1755 commit 0ff567c

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

tests/test_models.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -300,27 +300,30 @@ class TestClearExpired(TestCase):
300300
def setUp(self):
301301
self.user = UserModel.objects.create_user("test_user", "[email protected]", "123456")
302302
# Insert two tokens on database.
303+
app = Application.objects.create(
304+
name="test_app",
305+
redirect_uris="http://localhost http://example.com http://example.org",
306+
user=self.user,
307+
client_type=Application.CLIENT_CONFIDENTIAL,
308+
authorization_grant_type=Application.GRANT_AUTHORIZATION_CODE,
309+
)
303310
AccessToken.objects.create(
304-
id=1,
305311
token="555",
306312
expires=timezone.now(),
307313
scope=2,
308-
application_id=3,
309-
user_id=1,
314+
application=app,
315+
user=self.user,
310316
created=timezone.now(),
311317
updated=timezone.now(),
312-
source_refresh_token_id="0",
313318
)
314319
AccessToken.objects.create(
315-
id=2,
316320
token="666",
317321
expires=timezone.now(),
318322
scope=2,
319-
application_id=3,
320-
user_id=1,
323+
application=app,
324+
user=self.user,
321325
created=timezone.now(),
322326
updated=timezone.now(),
323-
source_refresh_token_id="1",
324327
)
325328

326329
def test_clear_expired_tokens(self):

0 commit comments

Comments
 (0)