<commit_before>from __future__ import unicode_literals


def test_simple():
    assert True
<commit_msg>Update tests.test_views<commit_after>from __future__ import unicode_literals

from django.contrib.auth import get_user_model

from .utils import APIViewTestCase

User = get_user_model()


class TestTokenObtainView(APIViewTestCase):
    view_name = 'rest_framework_simplejwt:token_obtain'

    def setUp(self):
        self.username = 'test_user'
        self.password = '<PASSWORD>'

        self.user = User.objects.create_user(
            username=self.username,
            password=self.password,
        )

    def test_fields_missing(self):
        res = self.view_post(data={})
        self.assertEqual(res.status_code, 400)
        self.assertIn(User.USERNAME_FIELD, res.data)
        self.assertIn('password', res.data)

        res = self.view_post(data={User.USERNAME_FIELD: 'test_user'})
        self.assertEqual(res.status_code, 400)
        self.assertIn('password', res.data)

        res = self.view_post(data={'password': '<PASSWORD>'})
        self.assertEqual(res.status_code, 400)
        self.assertIn(User.USERNAME_FIELD, res.data)

    def test_credentials_wrong(self):
        res = self.view_post(data={
            User.USERNAME_FIELD: 'test_user',
            'password': '<PASSWORD>',
        })
        self.assertEqual(res.status_code, 400)
        self.assertIn('non_field_errors', res.data)

    def test_user_inactive(self):
        self.user.is_active = False
        self.user.save()

        res = self.view_post(data={
            User.USERNAME_FIELD: 'test_user',
            'password': '<PASSWORD>',
        })
        self.assertEqual(res.status_code, 400)
        self.assertIn('non_field_errors', res.data)

    def test_success(self):
        res = self.view_post(data={
            User.USERNAME_FIELD: 'test_user',
            'password': '<PASSWORD>',
        })
        self.assertEqual(res.status_code, 200)
        self.assertIn('token', res.data)

{'fraction_non_alphanumeric': 0.11782326510234647, 'fraction_numerical': 0.008986520219670495, 'mean_word_length': 2.752808988764045, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5283301', 'n_tokens_mistral': 640, 'n_tokens_neox': 612, 'n_words': 100}