Skip to content

Commit 5d71d8d

Browse files
Vasyl Dizhakcarltongibson
authored andcommitted
Increase test coverage for drf_create_token command (#5550)
1 parent 3ddc22f commit 5d71d8d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tests/test_authtoken.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pytest
22
from django.contrib.admin import site
33
from django.contrib.auth.models import User
4-
from django.core.management import call_command
4+
from django.core.management import CommandError, call_command
55
from django.test import TestCase
66
from django.utils.six import StringIO
77

@@ -71,6 +71,11 @@ def test_command_do_not_reset_user_token(self):
7171

7272
assert first_token_key == second_token_key
7373

74+
def test_command_raising_error_for_invalid_user(self):
75+
out = StringIO()
76+
with pytest.raises(CommandError):
77+
call_command('drf_create_token', 'not_existing_user', stdout=out)
78+
7479
def test_command_output(self):
7580
out = StringIO()
7681
call_command('drf_create_token', self.user.username, stdout=out)

0 commit comments

Comments
 (0)