Skip to content

increase test coverage for drf_create_token command #5550

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 2, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion tests/test_authtoken.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
from django.contrib.admin import site
from django.contrib.auth.models import User
from django.core.management import call_command
from django.core.management import CommandError, call_command
from django.test import TestCase
from django.utils.six import StringIO

Expand Down Expand Up @@ -71,6 +71,11 @@ def test_command_do_not_reset_user_token(self):

assert first_token_key == second_token_key

def test_command_raising_error_for_invalid_user(self):
out = StringIO()
with pytest.raises(CommandError):
call_command('drf_create_token', 'not_existing_user', stdout=out)

def test_command_output(self):
out = StringIO()
call_command('drf_create_token', self.user.username, stdout=out)
Expand Down